summaryrefslogtreecommitdiff
path: root/checkers/misc.py
diff options
context:
space:
mode:
authorClaudiu Popa <cpopa@cloudbasesolutions.com>2015-01-03 10:00:00 +0200
committerClaudiu Popa <cpopa@cloudbasesolutions.com>2015-01-03 10:00:00 +0200
commit4ad0921cb4e75f0fab120c845d73990075da152d (patch)
treebadab4ca72cf7d8cc6af18f38776dddffa1ae4da /checkers/misc.py
parent98f292601d5db900732842031db3b22366f799aa (diff)
downloadpylint-4ad0921cb4e75f0fab120c845d73990075da152d.tar.gz
Use the new Module.stream, since Module.file_stream is deprecated.
Diffstat (limited to 'checkers/misc.py')
-rw-r--r--checkers/misc.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/checkers/misc.py b/checkers/misc.py
index d4adfd7..7fbe70b 100644
--- a/checkers/misc.py
+++ b/checkers/misc.py
@@ -82,8 +82,6 @@ class EncodingChecker(BaseChecker):
"""inspect the source file to find encoding problem or fixmes like
notes
"""
- stream = module.file_stream
- stream.seek(0) # XXX may be removed with astroid > 0.23
if self.config.notes:
notes = re.compile(
r'.*?#\s*(%s)(:*\s*.+)' % "|".join(self.config.notes))
@@ -94,10 +92,11 @@ class EncodingChecker(BaseChecker):
else:
encoding = 'ascii'
- for lineno, line in enumerate(stream):
- line = self._check_encoding(lineno + 1, line, encoding)
- if line is not None and notes:
- self._check_note(notes, lineno + 1, line)
+ with module.stream() as stream:
+ for lineno, line in enumerate(stream):
+ line = self._check_encoding(lineno + 1, line, encoding)
+ if line is not None and notes:
+ self._check_note(notes, lineno + 1, line)
def register(linter):