Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Add patch901 to fix test_ssl when a filename cannot be encoded
Browse files Browse the repository at this point in the history
  • Loading branch information
carlwgeorge committed Aug 17, 2018
1 parent 0b9da75 commit aef1b4f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
49 changes: 49 additions & 0 deletions SOURCES/00901-fix-test_ssl-when-a-filename-cannot-be-encoded.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From 19f6bd06af3c7fc0db5f96878aaa68f5589ff13e Mon Sep 17 00:00:00 2001
From: Pablo Galindo <Pablogsal@gmail.com>
Date: Thu, 24 May 2018 23:20:44 +0100
Subject: [PATCH] bpo-33354: Fix test_ssl when a filename cannot be encoded
(GH-6613)

Skip test_load_dh_params() of test_ssl when Python filesystem encoding
cannot encode the provided path.
---
Lib/test/test_ssl.py | 9 ++++++++-
.../next/Tests/2018-04-26-22-39-17.bpo-33354.g35-44.rst | 2 ++
2 files changed, 10 insertions(+), 1 deletion(-)
create mode 100644 Misc/NEWS.d/next/Tests/2018-04-26-22-39-17.bpo-33354.g35-44.rst

diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index b59fe73f04c7..7ced90fdf678 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -989,6 +989,13 @@ def test_load_verify_cadata(self):


def test_load_dh_params(self):
+ filename = u'dhpäräm.pem'
+ fs_encoding = sys.getfilesystemencoding()
+ try:
+ filename.encode(fs_encoding)
+ except UnicodeEncodeError:
+ self.skipTest("filename %r cannot be encoded to the filesystem encoding %r" % (filename, fs_encoding))
+
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
ctx.load_dh_params(DHFILE)
if os.name != 'nt':
@@ -1001,7 +1008,7 @@ def test_load_dh_params(self):
with self.assertRaises(ssl.SSLError) as cm:
ctx.load_dh_params(CERTFILE)
with support.temp_dir() as d:
- fname = os.path.join(d, u'dhpäräm.pem')
+ fname = os.path.join(d, filename)
shutil.copy(DHFILE, fname)
ctx.load_dh_params(fname)

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
new file mode 100644
index 000000000000..c66cecac32e7
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2018-04-26-22-39-17.bpo-33354.g35-44.rst
@@ -0,0 +1,2 @@
+Skip ``test_ssl.test_load_dh_params`` when Python filesystem encoding cannot encode the
+provided path.
7 changes: 7 additions & 0 deletions SPECS/python27.spec
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,11 @@ Patch156: 00156-gdb-autoload-safepath.patch
# (rhbz#697470)
Patch157: 00157-uid-gid-overflows.patch

# 00901 #
# Fix test_ssl when a filename cannot be encoded.
# https://github.com/python/cpython/commit/19f6bd06af3c7fc0db5f96878aaa68f5589ff13e
Patch901: 00901-fix-test_ssl-when-a-filename-cannot-be-encoded.patch

# (New patches go here ^^^)
#
# When adding new patches to "python2" and "python3" in Fedora, EL, etc.,
Expand Down Expand Up @@ -827,6 +832,7 @@ done
%patch155 -p1
%patch156 -p1
%patch157 -p1 -b .uid-gid-overflows
%patch901 -p1

# This shouldn't be necesarry, but is right now (2.2a3)
find -name "*~" |xargs rm -f
Expand Down Expand Up @@ -1640,6 +1646,7 @@ CheckPython \
%changelog
* Fri Aug 17 2018 Carl George <carl@george.computer> - 2.7.15-1.ius
- Latest upstream
- Add patch901 to fix test_ssl when a filename cannot be encoded

* Thu Sep 21 2017 Carl George <carl@george.computer> - 2.7.14-1.ius
- Latest upstream
Expand Down

0 comments on commit aef1b4f

Please sign in to comment.