Author xtreak
Recipients alexandre.vassalotti, xtreak
Date 2020-07-25.14:12:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1595686330.63.0.838691465271.issue41395@roundup.psfhosted.org>
In-reply-to
Content
pickle and pickletools use argparse with FileType which is not automatically closed. Other cli interfaces like json [0], ast [1] use context manager to close filetype objects.

pickle : https://github.com/python/cpython/blob/af08db7bac3087aac313d052c1a6302bee7c9c89/Lib/pickle.py#L1799

mypickle

>>> import pickle
>>> with open("mypickle", "wb") as f: pickle.dump({"a": 1}, f)

./python -Wall -m pickle mypickle                    
{'a': 1}
sys:1: ResourceWarning: unclosed file <_io.BufferedReader name='mypickle'>

pickletools : https://github.com/python/cpython/blob/af08db7bac3087aac313d052c1a6302bee7c9c89/Lib/pickletools.py#L2850-L2855

./python -Wall -m pickletools mypickle -o mypickle.py
sys:1: ResourceWarning: unclosed file <_io.BufferedReader name='mypickle'>
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='mypickle.py' mode='w' encoding='UTF-8'>


[0] https://github.com/python/cpython/blob/af08db7bac3087aac313d052c1a6302bee7c9c89/Lib/json/tool.py#L61
[1] https://github.com/python/cpython/blob/af08db7bac3087aac313d052c1a6302bee7c9c89/Lib/ast.py#L1510
History
Date User Action Args
2020-07-25 14:12:10xtreaksetrecipients: + xtreak, alexandre.vassalotti
2020-07-25 14:12:10xtreaksetmessageid: <1595686330.63.0.838691465271.issue41395@roundup.psfhosted.org>
2020-07-25 14:12:10xtreaklinkissue41395 messages
2020-07-25 14:12:10xtreakcreate