Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | From 19f6bd06af3c7fc0db5f96878aaa68f5589ff13e Mon Sep 17 00:00:00 2001 |
| 2 | From: Pablo Galindo <Pablogsal@gmail.com> |
| 3 | Date: Thu, 24 May 2018 23:20:44 +0100 |
| 4 | Subject: [PATCH] bpo-33354: Fix test_ssl when a filename cannot be encoded |
| 5 | (GH-6613) |
| 6 | |
| 7 | Skip test_load_dh_params() of test_ssl when Python filesystem encoding |
| 8 | cannot encode the provided path. |
| 9 | |
| 10 | Upstream-Status: Backport [https://github.com/python/cpython/commit/19f6bd06af3c7fc0db5f96878aaa68f5589ff13e] |
| 11 | Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> |
| 12 | --- |
| 13 | Lib/test/test_ssl.py | 9 ++++++++- |
| 14 | .../next/Tests/2018-04-26-22-39-17.bpo-33354.g35-44.rst | 2 ++ |
| 15 | 2 files changed, 10 insertions(+), 1 deletion(-) |
| 16 | create mode 100644 Misc/NEWS.d/next/Tests/2018-04-26-22-39-17.bpo-33354.g35-44.rst |
| 17 | |
| 18 | diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py |
| 19 | index b59fe73f04..7ced90fdf6 100644 |
| 20 | --- a/Lib/test/test_ssl.py |
| 21 | +++ b/Lib/test/test_ssl.py |
| 22 | @@ -989,6 +989,13 @@ class ContextTests(unittest.TestCase): |
| 23 | |
| 24 | |
| 25 | def test_load_dh_params(self): |
| 26 | + filename = u'dhpäräm.pem' |
| 27 | + fs_encoding = sys.getfilesystemencoding() |
| 28 | + try: |
| 29 | + filename.encode(fs_encoding) |
| 30 | + except UnicodeEncodeError: |
| 31 | + self.skipTest("filename %r cannot be encoded to the filesystem encoding %r" % (filename, fs_encoding)) |
| 32 | + |
| 33 | ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) |
| 34 | ctx.load_dh_params(DHFILE) |
| 35 | if os.name != 'nt': |
| 36 | @@ -1001,7 +1008,7 @@ class ContextTests(unittest.TestCase): |
| 37 | with self.assertRaises(ssl.SSLError) as cm: |
| 38 | ctx.load_dh_params(CERTFILE) |
| 39 | with support.temp_dir() as d: |
| 40 | - fname = os.path.join(d, u'dhpäräm.pem') |
| 41 | + fname = os.path.join(d, filename) |
| 42 | shutil.copy(DHFILE, fname) |
| 43 | ctx.load_dh_params(fname) |
| 44 | |
| 45 | diff --git a/Misc/NEWS.d/next/Tests/2018-04-26-22-39-17.bpo-33354.g35-44.rst b/Misc/NEWS.d/next/Tests/2018-04-26-22-39-17.bpo-33354.g35-44.rst |
| 46 | new file mode 100644 |
| 47 | index 0000000000..c66cecac32 |
| 48 | --- /dev/null |
| 49 | +++ b/Misc/NEWS.d/next/Tests/2018-04-26-22-39-17.bpo-33354.g35-44.rst |
| 50 | @@ -0,0 +1,2 @@ |
| 51 | +Skip ``test_ssl.test_load_dh_params`` when Python filesystem encoding cannot encode the |
| 52 | +provided path. |
| 53 | -- |
| 54 | 2.17.1 |
| 55 | |