From 2ac5de2a56f74026d3f82e014e564b884d06c8f2 Mon Sep 17 00:00:00 2001 From: Facundo Batista Date: Mon, 7 Jul 2008 18:24:11 +0000 Subject: [PATCH] Issue 3314. The sys module is used in an error case. --- Lib/test/test_urlparse.py | 4 ++++ Lib/urllib/parse.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index c92b5aad64..dbb7c36bc1 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -310,6 +310,10 @@ class UrlParseTestCase(unittest.TestCase): self.assertEqual(urllib.parse.urlparse("http://example.com?blahblah=/foo"), ('http', 'example.com', '', '', 'blahblah=/foo', '')) + def test_usingsys(self): + # Issue 3314: sys module is used in the error + self.assertRaises(TypeError, urllib.parse.urlencode, "foo") + def test_main(): support.run_unittest(UrlParseTestCase) diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index 8edc9635d3..fe02db5e00 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -4,6 +4,8 @@ See RFC 1808: "Relative Uniform Resource Locators", by R. Fielding, UC Irvine, June 1995. """ +import sys + __all__ = ["urlparse", "urlunparse", "urljoin", "urldefrag", "urlsplit", "urlunsplit"] @@ -599,7 +601,6 @@ test_input = """ """ def test(): - import sys base = '' if sys.argv[1:]: fn = sys.argv[1] -- 2.40.0