summaryrefslogtreecommitdiff
path: root/builder.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2014-07-24 10:05:26 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2014-07-24 10:05:26 +0200
commit23ef32ac1627f160b2bef43645a7d7a00faee8ff (patch)
treef87deb16f99d389313d25d5fae9465702d3714bc /builder.py
parentf9fd32902a2920bfb4679bc542f9a11689f38fc1 (diff)
downloadastroid-git-23ef32ac1627f160b2bef43645a7d7a00faee8ff.tar.gz
Use the with statement to prevent resource warnings.
Diffstat (limited to 'builder.py')
-rw-r--r--builder.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/builder.py b/builder.py
index 7ea1f8dd..f419ae3b 100644
--- a/builder.py
+++ b/builder.py
@@ -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()