Browse files

remove RessourceWarning from Python3 tests

  • Loading branch information...
1 parent 8ce2633 commit 1d3ee0237ea737f4062b81111a167d983326e654 @davidhalter committed Nov 20, 2012
Showing with 6 additions and 3 deletions.
  1. +5 −3 jedi/builtin.py
  2. +1 −0 jedi/imports.py
View
8 jedi/builtin.py
@@ -1,3 +1,4 @@
+from __future__ import with_statement
from _compatibility import exec_function, is_py3k
import re
@@ -92,7 +93,7 @@ class Parser(CachedModule):
}
if is_py3k:
- map_types['file object'] = 'import io; return io.TextIOWrapper(file)'
+ map_types['file object'] = 'import io; return io.TextIOWrapper()'
module_cache = {}
@@ -193,11 +194,12 @@ def process_code(code, depth=0):
if name == '__builtin__' and not is_py3k:
name = 'builtins'
path = os.path.dirname(os.path.abspath(__file__))
- f = open(os.path.sep.join([path, 'mixin', name]) + '.py')
+ with open(os.path.sep.join([path, 'mixin', name]) + '.py') as f:
+ s = f.read()
except IOError:
return {}
else:
- mixin_dct = process_code(f.read())
+ mixin_dct = process_code(s)
if is_py3k and self.name == Builtin.name:
# in the case of Py3k xrange is now range
mixin_dct['range'] = mixin_dct['xrange']
View
1 jedi/imports.py
@@ -239,6 +239,7 @@ def follow_str(ns, string):
source = f.read()
else:
source = current_namespace[0].read()
+ current_namespace[0].close()
if path.endswith('.py'):
f = modules.Module(path, source)
else:

0 comments on commit 1d3ee02

Please sign in to comment.