This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Python2: test_ssl fails on non-ASCII path
Type: Stage: resolved
Components: SSL Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: christian.heimes, vstinner
Priority: normal Keywords: patch

Created on 2018-04-25 14:14 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 6613 merged pablogsal, 2018-04-26 21:35
PR 7697 closed python-dev, 2018-06-14 20:42
Messages (5)
msg315734 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-04-25 14:14
The FreeBSD 2.7 buildbot is failing because of test_ssl:

test test_ssl failed -- Traceback (most recent call last):
  File "/usr/home/buildbot/python/2.7.koobs-freebsd10/build/Lib/test/test_ssl.py", line 1005, in test_load_dh_params
    shutil.copy(DHFILE, fname)
  File "/usr/home/buildbot/python/2.7.koobs-freebsd10/build/Lib/shutil.py", line 131, in copy
    if os.path.isdir(dst):
  File "/usr/home/buildbot/python/2.7.koobs-freebsd10/build/Lib/genericpath.py", line 49, in isdir
    st = os.stat(s)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 18: ordinal not in range(128)

======================================================================
ERROR: test_load_dh_params (test.test_ssl.ContextTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/buildbot/python/2.7.koobs-freebsd10/build/Lib/test/test_ssl.py", line 1005, in test_load_dh_params
    shutil.copy(DHFILE, fname)
  File "/usr/home/buildbot/python/2.7.koobs-freebsd10/build/Lib/shutil.py", line 131, in copy
    if os.path.isdir(dst):
  File "/usr/home/buildbot/python/2.7.koobs-freebsd10/build/Lib/genericpath.py", line 49, in isdir
    st = os.stat(s)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 18: ordinal not in range(128)


test.pythoninfo:

* os.cwd: /usr/home/buildbot/python/2.7.koobs-freebsd10/build
* sys.filesystem_encoding: US-ASCII


The failure is likely related to the commit 6e8f395001b026daea047cf225dcca5a973ae824, bpo-25404:
---
commit 6e8f395001b026daea047cf225dcca5a973ae824
Author: Christian Heimes <christian@python.org>
Date:   Sun Feb 25 09:48:02 2018 +0100

    bpo-25404: SSLContext.load_dh_params() non-ASCII path (GH-3459)
    
    SSLContext.load_dh_params() now supports non-ASCII path.
    
    Signed-off-by: Christian Heimes <christian@python.org>
---


Maybe the test should be skipped if the filesystem encoding cannot encode the path?
msg315735 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-04-25 14:16
The issue is not specific to FreeBSD, it depends on the locale (on the Python filesystem encoding).

I reproduced the issue on Linux:

vstinner@apu$ LC_ALL=C ./python -m test test_ssl
Run tests sequentially
0:00:00 load avg: 0.27 [1/1] test_ssl
test test_ssl failed -- Traceback (most recent call last):
  File "/home/vstinner/prog/python/2.7/Lib/test/test_ssl.py", line 1005, in test_load_dh_params
    shutil.copy(DHFILE, fname)
  File "/home/vstinner/prog/python/2.7/Lib/shutil.py", line 131, in copy
    if os.path.isdir(dst):
  File "/home/vstinner/prog/python/2.7/Lib/genericpath.py", line 49, in isdir
    st = os.stat(s)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 18: ordinal not in range(128)

1 test failed:
    test_ssl

Total duration: 1 sec
Tests result: FAILURE
msg317623 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-05-24 20:53
Oh. I approved the PR but it's not merged yet :-/
msg317631 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-05-24 22:20
New changeset 19f6bd06af3c7fc0db5f96878aaa68f5589ff13e by Victor Stinner (Pablo Galindo) in branch '2.7':
bpo-33354: Fix test_ssl when a filename cannot be encoded (GH-6613)
https://github.com/python/cpython/commit/19f6bd06af3c7fc0db5f96878aaa68f5589ff13e
msg317632 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-05-24 22:22
Thanks Pablo for your fix!
History
Date User Action Args
2022-04-11 14:58:59adminsetgithub: 77535
2018-06-14 20:42:09python-devsetpull_requests: + pull_request7312
2018-05-24 22:22:12vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg317632

stage: patch review -> resolved
2018-05-24 22:20:47vstinnersetmessages: + msg317631
2018-05-24 20:53:08vstinnersetmessages: + msg317623
2018-04-26 21:35:13pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request6309
2018-04-25 14:16:26vstinnersettitle: Python2, FreeBSD: test_ssl fails on non-ASCII path -> Python2: test_ssl fails on non-ASCII path
nosy: - koobs

messages: + msg315735

components: - FreeBSD
2018-04-25 14:14:15vstinnercreate