Title: `test_file` failed on Windows with a longer repo path in `test_urllib2` · Issue #133448 · python/cpython · GitHub
Open Graph Title: `test_file` failed on Windows with a longer repo path in `test_urllib2` · Issue #133448 · python/cpython
X Title: `test_file` failed on Windows with a longer repo path in `test_urllib2` · Issue #133448 · python/cpython
Description: On Windows, when the CPython repository is cloned to a slightly longer path, for example, C:\Users\xxxxx\Source\cpython — this test case will fail: ERROR: test_file (test.test_urllib2.HandlerTests.test_file) -----------------------------...
Open Graph Description: On Windows, when the CPython repository is cloned to a slightly longer path, for example, C:\Users\xxxxx\Source\cpython — this test case will fail: ERROR: test_file (test.test_urllib2.HandlerTests....
X Description: On Windows, when the CPython repository is cloned to a slightly longer path, for example, C:\Users\xxxxx\Source\cpython — this test case will fail: ERROR: test_file (test.test_urllib2.HandlerTests....
Opengraph URL: https://github.com/python/cpython/issues/133448
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`test_file` failed on Windows with a longer repo path in `test_urllib2`","articleBody":"On Windows, when the CPython repository is cloned to a slightly longer path, for example, `C:\\Users\\xxxxx\\Source\\cpython` — this test case will fail:\n\n```\nERROR: test_file (test.test_urllib2.HandlerTests.test_file)\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File \"C:\\Users\\xxxxx\\Source\\cpython\\Lib\\encodings\\idna.py\", line 219, in encode\n result.extend(ToASCII(label))\n ~~~~~~~^^^^^^^\n File \"C:\\Users\\xxxxx\\Source\\cpython\\Lib\\encodings\\idna.py\", line 115, in ToASCII\n raise UnicodeEncodeError(\"idna\", label, 0, len(label), \"label too long\")\nUnicodeEncodeError: 'idna' codec can't encode characters in position 0-64: label too long\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"C:\\Users\\xxxxx\\Source\\cpython\\Lib\\test\\test_urllib2.py\", line 872, in test_file\n self.assertRaises(urllib.error.URLError,\n ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^\n h.file_open, Request(url))\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"C:\\Users\\xxxxx\\Source\\cpython\\Lib\\unittest\\case.py\", line 813, in assertRaises\n return context.handle('assertRaises', args, kwargs)\n ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"C:\\Users\\xxxxx\\Source\\cpython\\Lib\\unittest\\case.py\", line 247, in handle\n callable_obj(*args, **kwargs)\n ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^\n File \"C:\\Users\\xxxxx\\Source\\cpython\\Lib\\urllib\\request.py\", line 1469, in open_local_file\n localfile = url2pathname(req.full_url, require_scheme=True)\n File \"C:\\Users\\xxxxx\\Source\\cpython\\Lib\\urllib\\request.py\", line 1658, in url2pathname\n if not _is_local_authority(authority):\n ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^\n File \"C:\\Users\\xxxxx\\Source\\cpython\\Lib\\urllib\\request.py\", line 1498, in _is_local_authority\n address = socket.gethostbyname(authority)\n File \"C:\\Users\\xxxxx\\Source\\cpython\\Lib\\encodings\\idna.py\", line 222, in encode\n raise UnicodeEncodeError(\n ...\u003c5 lines>...\n )\nUnicodeEncodeError: 'idna' codec can't encode characters in position 8-72: label too long\nencoding with 'idna' codec failed\n```\n\nSee:\n[https://github.com/python/cpython/blob/c336f1c3126203fd6c38050df94e9fe8c0d7f2e2/Lib/test/test\\_urllib2.py#L857-L860](https://github.com/python/cpython/blob/c336f1c3126203fd6c38050df94e9fe8c0d7f2e2/Lib/test/test_urllib2.py#L857-L860)\n\nThese two URLs will become:\n\n* `file://127.0.0.1:80C:\\Users\\xxxxx\\Source\\cpython\\build\\test_python_worker_17208æ/@test_17208_tmpæ`\n* `file://somerandomhost.ontheinternet.comC:\\Users\\xxxxx\\Source\\cpython\\build\\test_python_worker_4676æ/@test_4676_tmpæ`\n\nHere, `127.0.0.1:80C:\\Users\\xxxxx\\Source\\cpython\\build\\test_python_worker_17208æ` is treated as the domain and passed to `socket.gethostbyname`. However, the part `1:80C:\\Users\\xxxxx\\Source\\cpython\\build\\test_python_worker_17208æ` is too long to be a valid domain label. As a result, the `idna` codec raises an exception, indicating the label is too long.\n\nA patch is on the way.\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-133449\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/aisk","@type":"Person","name":"aisk"},"datePublished":"2025-05-05T15:15:43Z","url":"https://github.com/python/cpython/issues/133448"}
| 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:fc32467a-979d-f5fc-24a0-698844ec0294 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 93A2:2E9831:1E5C783:2808C88:6B022F3A |
| html-safe-nonce | ff378aaf19d3ce90c24ef30fb40f686683ac30cfe2f6e21208302f33e58caaa6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5M0EyOjJFOTgzMToxRTVDNzgzOjI4MDhDODg6NkIwMjJGM0EiLCJ2aXNpdG9yX2lkIjoiNzM5ODMxMjQ1MzE0NDE5NDg3NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b46c9424fe51017ddbedc6d522441b1e7e6c5e4a4272d83fe4b8653f2917cdfc |
| hovercard-subject-tag | issue:3040004742 |
| 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/133448/issue_layout |
| twitter:image | https://opengraph.githubassets.com/134d2d4e1fee0e69f375252a5f03e0f3f4049584c23771702efba0e95f88587c/python/cpython/issues/133448 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/134d2d4e1fee0e69f375252a5f03e0f3f4049584c23771702efba0e95f88587c/python/cpython/issues/133448 |
| og:image:alt | On Windows, when the CPython repository is cloned to a slightly longer path, for example, C:\Users\xxxxx\Source\cpython — this test case will fail: ERROR: test_file (test.test_urllib2.HandlerTests.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | aisk |
| 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