diff options
author | Mickaël Schoentgen <contact@tiger-222.fr> | 2018-11-01 17:28:20 +0100 |
---|---|---|
committer | Mickaël Schoentgen <contact@tiger-222.fr> | 2018-11-09 10:29:21 +0100 |
commit | d406e718d7ef23c2cb83bb38bc156f3cccffcf6f (patch) | |
tree | 4070d0fa86037b0269c8dac79d1e7a8f27a2e060 /ply/lex.py | |
parent | 0f398b72618c1564d71f7dc0558e6722b241875a (diff) | |
download | ply-d406e718d7ef23c2cb83bb38bc156f3cccffcf6f.tar.gz |
Fix several ResourceWarning: unclosed file
Diffstat (limited to 'ply/lex.py')
-rw-r--r-- | ply/lex.py | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -1055,9 +1055,8 @@ def runmain(lexer=None, data=None): if not data: try: filename = sys.argv[1] - f = open(filename) - data = f.read() - f.close() + with open(filename) as f: + data = f.read() except IndexError: sys.stdout.write('Reading from standard input (type EOF to end):\n') data = sys.stdin.read() |