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.

Author vstinner
Recipients ncoghlan, serhiy.storchaka, vstinner
Date 2017-11-20.14:57:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1511189840.42.0.213398074469.issue32089@psf.upfronthosting.co.za>
In-reply-to
Content
The -X dev mode currently *hides* some ResourceWarning warnings:

$ cat x.py 
def func():
    open('/etc/issue')

func()
func()

$ ./python x.py 
x.py:2: ResourceWarning: unclosed file <_io.TextIOWrapper name='/etc/issue' mode='r' encoding='UTF-8'>
  open('/etc/issue')
x.py:2: ResourceWarning: unclosed file <_io.TextIOWrapper name='/etc/issue' mode='r' encoding='UTF-8'>
  open('/etc/issue')

haypo@selma$ ./python -X dev x.py 
x.py:2: ResourceWarning: unclosed file <_io.TextIOWrapper name='/etc/issue' mode='r' encoding='UTF-8'>
  open('/etc/issue')


The problem is that the "-W default" inserted by -X dev overrides the final filter on ResourceWarning:

$ ./python -X dev -c 'import warnings, pprint; pprint.pprint(warnings.filters)'
[('default',
  re.compile('', re.IGNORECASE),
  <class 'Warning'>,
  re.compile(''),
  0),
 ('ignore', None, <class 'BytesWarning'>, None, 0),
 ('always', None, <class 'ResourceWarning'>, None, 0)]
History
Date User Action Args
2017-11-20 14:57:20vstinnersetrecipients: + vstinner, ncoghlan, serhiy.storchaka
2017-11-20 14:57:20vstinnersetmessageid: <1511189840.42.0.213398074469.issue32089@psf.upfronthosting.co.za>
2017-11-20 14:57:20vstinnerlinkissue32089 messages
2017-11-20 14:57:20vstinnercreate