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: test_trace fails with -S
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.7, Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: pitrou, python-dev, serhiy.storchaka, tdsmith, terry.reedy, vajrasky
Priority: low Keywords: patch

Created on 2013-10-25 19:43 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
emergency_patch_for_test_trace.patch vajrasky, 2013-10-26 04:52 review
remove_extra_slash_from_sys_path.patch vajrasky, 2013-10-26 06:05 review
remove_extra_slash_from_sys_path_v2.patch vajrasky, 2013-11-02 04:35 review
remove_extra_slash_from_sys_path_v3.patch serhiy.storchaka, 2016-11-10 10:16 review
Pull Requests
URL Status Linked Edit
PR 552 closed dstufft, 2017-03-31 16:36
Messages (7)
msg201286 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-10-25 19:43
$ ./python -S -m test test_trace
[1/1] test_trace
test test_trace failed -- Traceback (most recent call last):
  File "/home/antoine/cpython/default/Lib/test/test_trace.py", line 313, in test_coverage
    self.assertTrue("pprint.cover" in files)
AssertionError: False is not true
msg201313 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-10-26 04:52
This is the "emergency" patch to solve this issue.

The main issue is,

[sky@localhost cpython]$ ./python -Sc "import sys; print(sys.path)"
['', '/usr/local/lib/python34.zip', '/home/sky/Code/python/programming_language/cpython/Lib/', '/home/sky/Code/python/programming_language/cpython/Lib/plat-linux', '/home/sky/Code/python/programming_language/cpython/build/lib.linux-x86_64-3.4-pydebug']
[sky@localhost cpython]$ ./python -c "import sys; print(sys.path)"
['', '/usr/local/lib/python34.zip', '/home/sky/Code/python/programming_language/cpython/Lib', '/home/sky/Code/python/programming_language/cpython/Lib/plat-linux', '/home/sky/Code/python/programming_language/cpython/build/lib.linux-x86_64-3.4-pydebug', '/home/sky/.local/lib/python3.4/site-packages']

Let me "zoom" it for you.

[sky@localhost cpython]$ ./python -Sc "import sys; print(sys.path[2])"
/home/sky/Code/python/programming_language/cpython/Lib/
[sky@localhost cpython]$ ./python -c "import sys; print(sys.path[2])"
/home/sky/Code/python/programming_language/cpython/Lib

The "extra" slash is the culprit. I need to investigate whether this is deliberate or not.
msg201314 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-10-26 06:05
I finally found the main culprit which puts extra '/' in my sys.path. The patch removed the extra '/' and also fixed this test automatically.
msg201947 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-11-01 22:39
The test should use the more specific assertXyz method:
self.assertIn("pprint.cover", files)

The error message would then be the more informative
AssertionError: 'pprint.cover' not found in <files listed>
msg201962 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-11-02 04:35
Attached the patch to accommodate Terry J. Reedy's request.
msg280500 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-11-10 10:16
The separator is needed if the relative path is not empty and the prefix doesn't end with the separator.

This patch seems also fixes most problems of issue28655.
msg280572 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-11-11 10:12
New changeset db220f2df5a9 by Serhiy Storchaka in branch '3.5':
Issue #19398: Extra slash no longer added to sys.path components in case of
https://hg.python.org/cpython/rev/db220f2df5a9

New changeset 1a88baaed7a0 by Serhiy Storchaka in branch '3.6':
Issue #19398: Extra slash no longer added to sys.path components in case of
https://hg.python.org/cpython/rev/1a88baaed7a0

New changeset 82607e7c24c7 by Serhiy Storchaka in branch 'default':
Issue #19398: Extra slash no longer added to sys.path components in case of
https://hg.python.org/cpython/rev/82607e7c24c7

New changeset 237ef36fb1bb by Serhiy Storchaka in branch '2.7':
Issue #19398: Extra slash no longer added to sys.path components in case of
https://hg.python.org/cpython/rev/237ef36fb1bb
History
Date User Action Args
2022-04-11 14:57:52adminsetgithub: 63597
2017-03-31 16:36:09dstufftsetpull_requests: + pull_request846
2016-11-11 12:02:17serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: resolved
2016-11-11 10:12:27python-devsetnosy: + python-dev
messages: + msg280572
2016-11-10 10:16:27serhiy.storchakasetfiles: + remove_extra_slash_from_sys_path_v3.patch

nosy: + serhiy.storchaka
versions: + Python 3.5, Python 3.6, Python 3.7, - Python 3.4
messages: + msg280500

assignee: serhiy.storchaka
2016-10-04 02:51:52tdsmithsetnosy: + tdsmith

versions: + Python 2.7
2013-11-02 04:35:56vajraskysetfiles: + remove_extra_slash_from_sys_path_v2.patch

messages: + msg201962
2013-11-01 22:39:42terry.reedysetnosy: + terry.reedy
messages: + msg201947
2013-10-26 06:05:34vajraskysetfiles: + remove_extra_slash_from_sys_path.patch

messages: + msg201314
2013-10-26 04:52:42vajraskysetfiles: + emergency_patch_for_test_trace.patch

nosy: + vajrasky
messages: + msg201313

keywords: + patch
2013-10-25 19:43:53pitroucreate