Title: Incorrect return types for xml.dom.minidom.Node.{toxml,toprettyxml} · Issue #10060 · python/typeshed · GitHub
Open Graph Title: Incorrect return types for xml.dom.minidom.Node.{toxml,toprettyxml} · Issue #10060 · python/typeshed
X Title: Incorrect return types for xml.dom.minidom.Node.{toxml,toprettyxml} · Issue #10060 · python/typeshed
Description: It looks like #9917 added the -> str return type to these functions, but the documentation indicates that may return bytes: Return a string or byte string containing the XML represented by the DOM node. With an explicit encoding 1 argume...
Open Graph Description: It looks like #9917 added the -> str return type to these functions, but the documentation indicates that may return bytes: Return a string or byte string containing the XML represented by the DOM ...
X Description: It looks like #9917 added the -> str return type to these functions, but the documentation indicates that may return bytes: Return a string or byte string containing the XML represented by the D...
Opengraph URL: https://github.com/python/typeshed/issues/10060
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect return types for xml.dom.minidom.Node.{toxml,toprettyxml}","articleBody":"It looks like #9917 added the `-> str` return type to these functions, but the [documentation](https://docs.python.org/3/library/xml.dom.minidom.html#xml.dom.minidom.Node.toxml) indicates that _may_ return `bytes`:\r\n\r\n> Return a string or byte string containing the XML represented by the DOM node.\r\n>\r\n> With an explicit encoding 1 argument, the result is a byte string in the specified encoding. With no encoding argument, the result is a Unicode string, and the XML declaration in the resulting string does not specify an encoding. Encoding this string in an encoding other than UTF-8 is likely incorrect, since UTF-8 is the default encoding of XML.\r\n\r\nThis small example seems to confirm that it can return `bytes`:\r\n\r\n```py\r\nfrom xml.dom.minidom import Document\r\n\r\ndoc = Document()\r\ndoc.appendChild(doc.createElement(\"foo\"))\r\nprint(doc.toprettyxml(indent=\"\\t\", encoding=\"UTF-8\"))\r\n# output: b'\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n\u003cfoo/>\\n'\r\n```\r\n","author":{"url":"https://github.com/wesleywright","@type":"Person","name":"wesleywright"},"datePublished":"2023-04-18T20:35:48Z","url":"https://github.com/python/typeshed/issues/10060"}
| 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:ef1ac4c1-c4d3-40a3-35a8-6d8a5b785135 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED78:34D7A7:A9BB44:E45844:6B004C06 |
| html-safe-nonce | 2631b16d401b3b31372f091233cb7af0870b49adac56e7c6340aeb6e014b8693 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDc4OjM0RDdBNzpBOUJCNDQ6RTQ1ODQ0OjZCMDA0QzA2IiwidmlzaXRvcl9pZCI6IjQ0Njc3MDUzNTgwODkxMjM5MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ade283dd3ff0dda117edd986cc9f65c0777c3b49489a8b630dcc3785bd830f6d |
| hovercard-subject-tag | issue:1673798297 |
| 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/typeshed/10060/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d2187e1b2999b0973504704b4fccc7ff751d8bae92f6cef05d6897628e3f92a9/python/typeshed/issues/10060 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d2187e1b2999b0973504704b4fccc7ff751d8bae92f6cef05d6897628e3f92a9/python/typeshed/issues/10060 |
| og:image:alt | It looks like #9917 added the -> str return type to these functions, but the documentation indicates that may return bytes: Return a string or byte string containing the XML represented by the DOM ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wesleywright |
| hostname | github.com |
| expected-hostname | github.com |
| None | f9517bf360d46638a1e5e7daee7158842fe5ef43c9000afa0e127564a7c2f39b |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| 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 | b27c5dde30676028abd5c5fc53ce5c9b625f8281 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width