Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

test_file failed on Windows with a longer repo path intest_urllib2 #133448

Open
Labels
OS-windowstestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error
@aisk

Description

@aisk

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)----------------------------------------------------------------------Traceback (most recent call last):  File "C:\Users\xxxxx\Source\cpython\Lib\encodings\idna.py", line 219, in encode    result.extend(ToASCII(label))                  ~~~~~~~^^^^^^^  File "C:\Users\xxxxx\Source\cpython\Lib\encodings\idna.py", line 115, in ToASCII    raise UnicodeEncodeError("idna", label, 0, len(label), "label too long")UnicodeEncodeError: 'idna' codec can't encode characters in position 0-64: label too longDuring handling of the above exception, another exception occurred:Traceback (most recent call last):  File "C:\Users\xxxxx\Source\cpython\Lib\test\test_urllib2.py", line 872, in test_file    self.assertRaises(urllib.error.URLError,    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^                      h.file_open, Request(url))                      ^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\xxxxx\Source\cpython\Lib\unittest\case.py", line 813, in assertRaises    return context.handle('assertRaises', args, kwargs)           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\xxxxx\Source\cpython\Lib\unittest\case.py", line 247, in handle    callable_obj(*args, **kwargs)    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^  File "C:\Users\xxxxx\Source\cpython\Lib\urllib\request.py", line 1469, in open_local_file    localfile = url2pathname(req.full_url, require_scheme=True)  File "C:\Users\xxxxx\Source\cpython\Lib\urllib\request.py", line 1658, in url2pathname    if not _is_local_authority(authority):           ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^  File "C:\Users\xxxxx\Source\cpython\Lib\urllib\request.py", line 1498, in _is_local_authority    address = socket.gethostbyname(authority)  File "C:\Users\xxxxx\Source\cpython\Lib\encodings\idna.py", line 222, in encode    raise UnicodeEncodeError(    ...<5 lines>...    )UnicodeEncodeError: 'idna' codec can't encode characters in position 8-72: label too longencoding with 'idna' codec failed

See:

"file://%s:80%s/%s"% (socket.gethostbyname('localhost'),
os.getcwd(),TESTFN),
"file://somerandomhost.ontheinternet.com%s/%s"%
(os.getcwd(),TESTFN),

These two URLs will become:

  • file://127.0.0.1:80C:\Users\xxxxx\Source\cpython\build\test_python_worker_17208æ/@test_17208_tmpæ
  • file://somerandomhost.ontheinternet.comC:\Users\xxxxx\Source\cpython\build\test_python_worker_4676æ/@test_4676_tmpæ

Here,127.0.0.1:80C:\Users\xxxxx\Source\cpython\build\test_python_worker_17208æ is treated as the domain and passed tosocket.gethostbyname. However, the part1:80C:\Users\xxxxx\Source\cpython\build\test_python_worker_17208æ is too long to be a valid domain label. As a result, theidna codec raises an exception, indicating the label is too long.

A patch is on the way.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowstestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp