Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9)

#23840: tokenize.open() leaks an open binary file on TextIOWrapper error

Can't Edit
Can't Publish+Mail
Start Review
Created:
4 years, 10 months ago by vstinner
Modified:
4 years, 9 months ago
Reviewers:
storchaka
CC:
haypo, devnull_psf.upfronthosting.co.za, introom, itsmemattchung
Visibility:
Public.

Patch Set 1 #

Total comments: 2

Patch Set 2 #

Total comments: 3

Patch Set 3 #

Patch Set 4 #

Total comments: 2

Patch Set 5 #

Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Lib/tokenize.py View 1 2 3 4 1 chunk +9 lines, -5 lines 0 comments Download

Messages

Total messages: 4
victor.stinner_gmail.com
http://bugs.python.org/review/23840/diff/14417/Lib/test/test_tokenize.py File Lib/test/test_tokenize.py (right): http://bugs.python.org/review/23840/diff/14417/Lib/test/test_tokenize.py#newcode1035 Lib/test/test_tokenize.py:1035: # test close file of unrecognized encoding You should ...
4 years, 10 months ago #1
victor.stinner_gmail.com
http://bugs.python.org/review/23840/diff/14418/Lib/tokenize.py File Lib/tokenize.py (right): http://bugs.python.org/review/23840/diff/14418/Lib/tokenize.py#newcode442 Lib/tokenize.py:442: text.mode = 'r' You may leave text.mode = 'r' ...
4 years, 10 months ago #2
storchaka_gmail.com
https://bugs.python.org/review/23840/diff/14418/Lib/tokenize.py File Lib/tokenize.py (right): https://bugs.python.org/review/23840/diff/14418/Lib/tokenize.py#newcode438 Lib/tokenize.py:438: buffer = _builtin_open(filename, 'rb') This line should be outside ...
4 years, 10 months ago #3
victor.stinner_gmail.com
4 years, 9 months ago #4
https://bugs.python.org/review/23840/diff/14421/Lib/test/test_tokenize.py
File Lib/test/test_tokenize.py (right):

https://bugs.python.org/review/23840/diff/14421/Lib/test/test_tokenize.py#new...
Lib/test/test_tokenize.py:1069: except:
If you expect an error, you should use assertRaises(<excepted exception>).

"except: pass" is a bad practice.

https://bugs.python.org/review/23840/diff/14421/Lib/tokenize.py
File Lib/tokenize.py (right):

https://bugs.python.org/review/23840/diff/14421/Lib/tokenize.py#newcode443
Lib/tokenize.py:443: buffer.seek(0)
Why not catching exceptions on this line?

Please put the 3 instructions in the try/except.
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+