diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2014-07-24 10:05:26 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2014-07-24 10:05:26 +0200 |
commit | 23ef32ac1627f160b2bef43645a7d7a00faee8ff (patch) | |
tree | f87deb16f99d389313d25d5fae9465702d3714bc /builder.py | |
parent | f9fd32902a2920bfb4679bc542f9a11689f38fc1 (diff) | |
download | astroid-git-23ef32ac1627f160b2bef43645a7d7a00faee8ff.tar.gz |
Use the with statement to prevent resource warnings.
Diffstat (limited to 'builder.py')
-rw-r--r-- | builder.py | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -41,9 +41,8 @@ if sys.version_info >= (3, 0): from tokenize import detect_encoding def open_source_file(filename): - byte_stream = open(filename, 'bU') - encoding = detect_encoding(byte_stream.readline)[0] - byte_stream.close() + with open(filename, 'bU') as byte_stream: + encoding = detect_encoding(byte_stream.readline)[0] stream = open(filename, 'U', encoding=encoding) try: data = stream.read() |