Work around a Nose import bug on PyPy
This commit is contained in:
parent
2b11b9be20
commit
36324e9499
@ -30,6 +30,7 @@ import marshal
|
||||
import struct
|
||||
import imp
|
||||
import sys
|
||||
import platform
|
||||
import ast
|
||||
import os
|
||||
import __future__
|
||||
@ -111,13 +112,17 @@ def import_file_to_module(module_name, fpath, loader=None):
|
||||
module = imp.new_module(module_name)
|
||||
module.__file__ = fpath
|
||||
code = ast_compile(_ast, fpath, "exec")
|
||||
try:
|
||||
write_code_as_pyc(fpath, code)
|
||||
except (IOError, OSError):
|
||||
# We failed to save the bytecode, probably because of a
|
||||
# permissions issue. The user only asked to import the file, so
|
||||
# don't bug them about it.
|
||||
pass
|
||||
if not (platform.python_implementation() == 'PyPy' and
|
||||
'nosetests' in sys.argv[0] and
|
||||
is_package(module_name)):
|
||||
# Nose can generate spurious errors in this specific situation.
|
||||
try:
|
||||
write_code_as_pyc(fpath, code)
|
||||
except (IOError, OSError):
|
||||
# We failed to save the bytecode, probably because of a
|
||||
# permissions issue. The user only asked to import the
|
||||
# file, so don't bug them about it.
|
||||
pass
|
||||
eval(code, module.__dict__)
|
||||
except (HyTypeError, LexException) as e:
|
||||
if e.source is None:
|
||||
|
Loading…
Reference in New Issue
Block a user