[New-bugs-announce] [issue45175] No warning with '-W always' and cached import

Jason Yundt report at bugs.python.org
Sat Sep 11 17:10:06 EDT 2021


New submission from Jason Yundt <swagfortress at gmail.com>:

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.

----------
files: Bug reproduction.zip
messages: 401648
nosy: jayman
priority: normal
severity: normal
status: open
title: No warning with '-W always' and cached import
type: behavior
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9
Added file: https://bugs.python.org/file50278/Bug reproduction.zip

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45175>
_______________________________________


More information about the New-bugs-announce mailing list