Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:

This causes buildbot failure (AMD64 FreeBSD 10-STABLE Non-Debug 3.x and AMD64 
Debian root 3.x). I tried debugging and it's reproducible on my mac machine 
that has python not built with ssl and not reproducible on Ubuntu machine built 
with ssl. 

The failed tests use https scheme and as I can see from the file there is one 
another test (test_cafile_and_context) which is skipped and has skip test if 
ssl is absent @unittest.skipUnless(ssl, "ssl module required"). It seems 
perhaps wrapping these machines don't have ssl built with skip test might help. 
Since primary CI has ssl built it would have been caught.

On trying to add a print statement for lookup variable at 
https://github.com/python/cpython/blob/c4e671eec20dfcb29b18596a89ef075f826c9f96/Lib/urllib/request.py#L485
 I can see the below output where httpshandler was not defined for machines 
without built ssl. HTTPSConnection was not present as part of http.client due 
to import ssl causing ImportError.

Ubuntu with ssl

{'unknown': [<urllib.request.UnknownHandler object at 0x7f855d2fe7e8>], 'http': 
[<urllib.request.HTTPHandler object at 0x7f855d2fe878>], 'ftp': 
[<urllib.request.FTPHandler object at 0x7f855d2fe6c8>], 'file': 
[<urllib.request.FileHandler object at 0x7f855d2fe908>], 'data': 
[<urllib.request.DataHandler object at 0x7f855d2fe998>], 'https': 
[<urllib.request.HTTPSHandler object at 0x7f855d2fea28>]}

Mac without ssl (https handler missing causing unknown to be taken up for the 
test)

{'unknown': [<urllib.request.UnknownHandler object at 0x108824c68>], 'http': 
[<urllib.request.HTTPHandler object at 0x108824cb0>], 'ftp': 
[<urllib.request.FTPHandler object at 0x108824cf8>], 'file': 
[<urllib.request.FileHandler object at 0x108824d88>], 'data': 
[<urllib.request.DataHandler object at 0x108824e60>]}

Gregory, I can create a PR with below patch if my analysis right to see if it 
helps or you can try a buildbot-custom branch to see if this works with 
buildbots since my PR won't have any effect on primary CI which have ssl built 
version of Python. I am not sure I have privileges to trigger a custom buildbot 
run. I tested it on my Mac without ssl and it has no failures since the tests 
are skipped.

diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index e87c85b928..c5b23f935b 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -329,6 +329,7 @@ class urlopen_HttpTests(unittest.TestCase, FakeHTTPMixin, 
FakeFTPMixin):
         finally:
             self.unfakehttp()

+    @unittest.skipUnless(ssl, "ssl module required")
     def test_url_with_control_char_rejected(self):
         for char_no in list(range(0, 0x21)) + [0x7f]:
             char = chr(char_no)
@@ -354,6 +355,7 @@ class urlopen_HttpTests(unittest.TestCase, FakeHTTPMixin, 
FakeFTPMixin):
             finally:
                 self.unfakehttp()

+    @unittest.skipUnless(ssl, "ssl module required")
     def test_url_with_newline_header_injection_rejected(self):
         self.fakehttp(b"HTTP/1.1 200 OK\r\n\r\nHello.")
         host = "localhost:7777?a=1 HTTP/1.1\r\nX-injected: header\r\nTEST: 123"

----------
assignee:  -> gregory.p.smith
stage: backport needed -> patch review
versions: +Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue30458>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to