Title: HTTPError fp.read returns string instead of bytes · Issue #101936 · python/cpython · GitHub
Open Graph Title: HTTPError fp.read returns string instead of bytes · Issue #101936 · python/cpython
X Title: HTTPError fp.read returns string instead of bytes · Issue #101936 · python/cpython
Description: Due to https://github.com/python/cpython/pull/99966/files However, this returns a bytes stream on the live run: from http import HTTPStatus from mailbox import Message from urllib.error import HTTPError from urllib.request import urlopen...
Open Graph Description: Due to https://github.com/python/cpython/pull/99966/files However, this returns a bytes stream on the live run: from http import HTTPStatus from mailbox import Message from urllib.error import HTTP...
X Description: Due to https://github.com/python/cpython/pull/99966/files However, this returns a bytes stream on the live run: from http import HTTPStatus from mailbox import Message from urllib.error import HTTP...
Opengraph URL: https://github.com/python/cpython/issues/101936
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"HTTPError fp.read returns string instead of bytes ","articleBody":"Due to https://github.com/python/cpython/pull/99966/files\r\n\r\nHowever, this returns a bytes stream on the live run:\r\n\r\n```python\r\nfrom http import HTTPStatus\r\nfrom mailbox import Message\r\nfrom urllib.error import HTTPError\r\nfrom urllib.request import urlopen\r\n\r\ntry:\r\n urlopen(\"http://asadsad.sd\")\r\nexcept HTTPError as exception:\r\n content = exception.fp.read()\r\n print(type(content))\r\n\r\nerror = HTTPError(url=\"url\", code=HTTPStatus.IM_A_TEAPOT, msg=\"msg\", hdrs=Message(), fp=None)\r\nprint(type(error.fp.read()))\r\n```\r\n```\r\n\u003cclass 'bytes'\u003e\r\n\u003cclass 'str'\u003e\r\n```\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-102100\n* gh-102117\n* gh-102118\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/gaborbernat","@type":"Person","name":"gaborbernat"},"datePublished":"2023-02-15T17:56:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/101936/cpython/issues/101936"}
| 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:07872296-c14b-e7bc-05ed-19d1895458df |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E3C4:DBE5:FFE352:155AC7A:696992C1 |
| html-safe-nonce | 0979f6112a2c531e7ca65e83e9cc45cdbe70cf73e3e46b63a3b4873de7e2d577 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0M0OkRCRTU6RkZFMzUyOjE1NUFDN0E6Njk2OTkyQzEiLCJ2aXNpdG9yX2lkIjoiMjU1MDU5MjkyOTIzMDU5MDY1NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d986086ce14e604b06985c129bcf2aa66d3ef2b940d491201aec2f14df6e4c6d |
| hovercard-subject-tag | issue:1586299879 |
| 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/101936/issue_layout |
| twitter:image | https://opengraph.githubassets.com/654ae494919dd6b7a47b1e77cf4ec7e8c7ab3d2dcd5674d44fd0fb2066792801/python/cpython/issues/101936 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/654ae494919dd6b7a47b1e77cf4ec7e8c7ab3d2dcd5674d44fd0fb2066792801/python/cpython/issues/101936 |
| og:image:alt | Due to https://github.com/python/cpython/pull/99966/files However, this returns a bytes stream on the live run: from http import HTTPStatus from mailbox import Message from urllib.error import HTTP... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gaborbernat |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3542e147982176a7ebaa23dfb559c8af16f721c03ec560c68c56b64a0f35e751 |
| 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 | af80af7cc9e3de9c336f18b208a600950a3c187c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width