Title: xml.dom.minidom: serializing a comment ending in '-' silently produces non-well-formed XML · Issue #156812 · python/cpython · GitHub
Open Graph Title: xml.dom.minidom: serializing a comment ending in '-' silently produces non-well-formed XML · Issue #156812 · python/cpython
X Title: xml.dom.minidom: serializing a comment ending in '-' silently produces non-well-formed XML · Issue #156812 · python/cpython
Description: Bug report Bug description: xml.dom.minidom guards comment serialization against -- (illegal inside an XML comment): Comment.writexml raises ValueError if "--" in self.data (test testSerializeCommentNodeWithDoubleHyphen). It misses a com...
Open Graph Description: Bug report Bug description: xml.dom.minidom guards comment serialization against -- (illegal inside an XML comment): Comment.writexml raises ValueError if "--" in self.data (test testSerializeComme...
X Description: Bug report Bug description: xml.dom.minidom guards comment serialization against -- (illegal inside an XML comment): Comment.writexml raises ValueError if "--" in self.data (test testSeri...
Opengraph URL: https://github.com/python/cpython/issues/156812
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"xml.dom.minidom: serializing a comment ending in '-' silently produces non-well-formed XML","articleBody":"# Bug report\n\n### Bug description:\n\n`xml.dom.minidom` guards comment serialization against `--` (illegal inside an XML comment): `Comment.writexml` raises `ValueError` if `\"--\" in self.data` (test `testSerializeCommentNodeWithDoubleHyphen`). It misses a comment whose data ends with `-`: the trailing `-` fuses with the closing `-->` into `--->`, which contains `--`.\n\n```python\nimport xml.dom.minidom as m\ndoc = m.getDOMImplementation().createDocument(None, None, None)\ndoc.appendChild(doc.createComment(\"see note-\"))\nout = doc.toxml() # '\u003c?xml version=\"1.0\" ?>\u003c!--see note--->'\nm.parseString(out) # xml.parsers.expat.ExpatError: not well-formed\n```\n\nminidom silently emits XML it cannot reparse. The existing `--` guard already takes the stance that serialization must fail loudly on comment content it cannot represent; the trailing-`-` case is a gap in that guard.\n\n### CPython versions tested on:\n\nCPython main\n\n### Operating systems tested on:\n\nLinux, macOS\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-156813\n* gh-161830\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/tonghuaroot","@type":"Person","name":"tonghuaroot"},"datePublished":"2026-09-02T09:34:47Z","url":"https://github.com/python/cpython/issues/156812"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d96460d0-b369-d208-12f7-8456830c06e7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E34E:211F05:1E192F:260EA6:6B02038A |
| html-safe-nonce | a4a4a6831eaa9296c5b56c99bb45ac44fdbcc3efa9fdfc4b5bb552c5354eae3d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzRFOjIxMUYwNToxRTE5MkY6MjYwRUE2OjZCMDIwMzhBIiwidmlzaXRvcl9pZCI6IjcyNzEyMzQ3NjQ2NzY0MDAwMTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d9fd1c0463f102b868b1f4806b26d19b6bfe049cb81832a1bea066961903ae28 |
| hovercard-subject-tag | issue:5322233949 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/156812/issue_layout |
| twitter:image | https://opengraph.githubassets.com/69277132131ea3d48ac36a25e0c529d99e46b7c1a5fc8a4d5178e6cdf16d9344/python/cpython/issues/156812 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/69277132131ea3d48ac36a25e0c529d99e46b7c1a5fc8a4d5178e6cdf16d9344/python/cpython/issues/156812 |
| og:image:alt | Bug report Bug description: xml.dom.minidom guards comment serialization against -- (illegal inside an XML comment): Comment.writexml raises ValueError if "--" in self.data (test testSerializeComme... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tonghuaroot |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width