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: DeprecationWarning/SyntaxError in test_import
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: anish.shah, benjamin.peterson, brett.cannon, eric.snow, mbussonn, ncoghlan, serhiy.storchaka
Priority: normal Keywords: easy

Created on 2017-03-02 13:31 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 421 merged anish.shah, 2017-03-03 07:25
Messages (6)
msg288799 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-02 13:31
$ ./python -Wa -m test.regrtest test_import
Run tests sequentially
0:00:00 [1/1] test_import
/home/serhiy/py/cpython/Lib/test/test_import/__init__.py:88: DeprecationWarning: invalid escape sequence \(
  self.assertRegex(str(cm.exception), "cannot import name 'i_dont_exist' from 'os' \(.*os.py\)")
/home/serhiy/py/cpython/Lib/test/test_import/__init__.py:96: DeprecationWarning: invalid escape sequence \(
  self.assertRegex(str(cm.exception), "cannot import name 'i_dont_exist' from 'select' \(.*\.(so|pyd)\)")
1 test OK.

Total duration: 2 sec
Tests result: SUCCESS

$ ./python -We -m test.regrtest test_import
Run tests sequentially
0:00:00 [1/1] test_import
test test_import crashed -- Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/test/libregrtest/runtest.py", line 152, in runtest_inner
    the_module = importlib.import_module(abstest)
  File "/home/serhiy/py/cpython/Lib/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 675, in exec_module
  File "<frozen importlib._bootstrap_external>", line 782, in get_code
  File "<frozen importlib._bootstrap_external>", line 742, in source_to_code
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/home/serhiy/py/cpython/Lib/test/test_import/__init__.py", line 88
    self.assertRegex(str(cm.exception), "cannot import name 'i_dont_exist' from 'os' \(.*os.py\)")
                                       ^
SyntaxError: invalid escape sequence \(

test_import failed

1 test failed:
    test_import

Total duration: 244 ms
Tests result: FAILURE
msg288820 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2017-03-02 18:43
Looks like the 'r' prefix is missing on the regex string. Marking this as "easy" if someone wants to try and solve this.

And FYI I double-checked that this is only in 3.7.
msg288864 - (view) Author: Anish Shah (anish.shah) * Date: 2017-03-03 07:12
I will try to work on this! :)
msg288867 - (view) Author: Anish Shah (anish.shah) * Date: 2017-03-03 07:22
I'm not able to reproduce the SyntaxError on latest commit 902e9c50e31209e796b6bbe26f8d2f57ec12071b on master branch.
msg288872 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-03 08:13
Thanks Anish. DeprecationWarning is converted to SyntaxError when run Python with -We.
msg290330 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-24 23:05
New changeset 15aa4c88f6052af6279e6be3fcd2f968f1c53eae by Serhiy Storchaka (Anish Shah) in branch 'master':
bpo-29693: Fix for DeprecationWarning in test_import (#421)
https://github.com/python/cpython/commit/15aa4c88f6052af6279e6be3fcd2f968f1c53eae
History
Date User Action Args
2022-04-11 14:58:43adminsetgithub: 73879
2017-03-24 23:05:51serhiy.storchakasetmessages: + msg290330
2017-03-03 08:13:21serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg288872

stage: needs patch -> resolved
2017-03-03 07:25:46anish.shahsetpull_requests: + pull_request350
2017-03-03 07:22:03anish.shahsetmessages: + msg288867
2017-03-03 07:12:51anish.shahsetnosy: + anish.shah
messages: + msg288864
2017-03-03 07:01:16mbussonnsetnosy: + mbussonn
2017-03-02 18:43:31brett.cannonsetkeywords: + easy

messages: + msg288820
2017-03-02 13:31:49serhiy.storchakacreate