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: No warning with '-W always' and cached import
Type: behavior Stage: resolved
Components: Versions: Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: jayman, serhiy.storchaka
Priority: normal Keywords:

Created on 2021-09-11 21:10 by jayman, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
Bug reproduction.zip jayman, 2021-09-11 21:10 The scripts used in steps to reproduce
Messages (2)
msg401648 - (view) Author: Jason Yundt (jayman) Date: 2021-09-11 21:10
I have a script which always produces a warning when you run it. If I import always_warns from another script, that script will only produce a warning once.

Steps to reproduce:
$ python -W always always_warns.py
/tmp/Bug reproduction/always_warns.py:1: DeprecationWarning: invalid escape sequence \ 
  "\ "
$ python -W always always_warns.py
/tmp/Bug reproduction/always_warns.py:1: DeprecationWarning: invalid escape sequence \ 
  "\ "
$ python -W always imports_always_warns.py
/tmp/Bug reproduction/always_warns.py:1: DeprecationWarning: invalid escape sequence \ 
  "\ "
$ python -W always imports_always_warns.py
$

There should be a warning for that last one, but there isn’t. If I delete __pycache__, imports_always_warns.py makes the warning appear again.
msg401649 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-09-11 21:19
This warning is produced by the compiler when it compiles the source code. If it is already compiled, no compiler is involved.
History
Date User Action Args
2022-04-11 14:59:49adminsetgithub: 89338
2021-09-11 21:19:34serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg401649

resolution: not a bug
stage: resolved
2021-09-11 21:10:06jaymancreate