python / python/cpython

Fix proxy usage in `test_urllib2_localnet` on macOS

オープン
#137,942 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

OS-mac tests type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug description:

On macos run:

make test

Error:

...
ERROR: test_proxy_with_bad_password_raises_httperror (test.test_urllib2_localnet.ProxyAuthTests.test_proxy_with_bad_password_raises_httperror)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 1321, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              encode_chunked=req.has_header('Transfer-encoding'))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1342, in request
    self._send_request(method, url, body, headers, encode_chunked)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1388, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1337, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1097, in _send_output
    self.send(msg)
    ~~~~~~~~~^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1041, in send
    self.connect()
    ~~~~~~~~~~~~^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1007, in connect
    self.sock = self._create_connection(
                ~~~~~~~~~~~~~~~~~~~~~~~^
        (self.host,self.port), self.timeout, self.source_address)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/socket.py", line 879, in create_connection
    raise exceptions[0]
  File "/Users/hyi/prs/cpython/Lib/socket.py", line 864, in create_connection
    sock.connect(sa)
    ~~~~~~~~~~~~^^^^
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/test/test_urllib2_localnet.py", line 368, in test_proxy_with_bad_password_raises_httperror
    self.opener.open(self.URL)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 487, in open
    response = self._open(req, data)
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 504, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
                              '_open', req)
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 464, in _call_chain
    result = func(*args)
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 1350, in http_open
    return self.do_open(http.client.HTTPConnection, req)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 1324, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 61] Connection refused>

======================================================================
ERROR: test_proxy_with_no_password_raises_httperror (test.test_urllib2_localnet.ProxyAuthTests.test_proxy_with_no_password_raises_httperror)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 1321, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              encode_chunked=req.has_header('Transfer-encoding'))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1342, in request
    self._send_request(method, url, body, headers, encode_chunked)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1388, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1337, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1097, in _send_output
    self.send(msg)
    ~~~~~~~~~^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1041, in send
    self.connect()
    ~~~~~~~~~~~~^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1007, in connect
    self.sock = self._create_connection(
                ~~~~~~~~~~~~~~~~~~~~~~~^
        (self.host,self.port), self.timeout, self.source_address)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/socket.py", line 879, in create_connection
    raise exceptions[0]
  File "/Users/hyi/prs/cpython/Lib/socket.py", line 864, in create_connection
    sock.connect(sa)
    ~~~~~~~~~~~~^^^^
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/test/test_urllib2_localnet.py", line 374, in test_proxy_with_no_password_raises_httperror
    self.opener.open(self.URL)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 487, in open
    response = self._open(req, data)
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 504, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
                              '_open', req)
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 464, in _call_chain
    result = func(*args)
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 1350, in http_open
    return self.do_open(http.client.HTTPConnection, req)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 1324, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 61] Connection refused>

----------------------------------------------------------------------
Ran 3 tests in 0.311s

FAILED (errors=3)
test test_urllib2_localnet failed
CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs
  • gh-137943

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Lib/test/test_urllib2_localnet.py と、レポートに示されている ProxyAuthTests の失敗から始め、すでに進行中の作業についてはリンクされている PR gh-137943 を確認してください。make test を実行したときに、macOS でプロキシテストが正常に完了することを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
networking, testing-qa
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。