2019-07-31 08:34:43 -04:00
|
|
|
# test overriding __import__ combined with importing from the filesystem
|
|
|
|
|
2020-03-22 22:26:08 -04:00
|
|
|
|
2019-07-31 08:34:43 -04:00
|
|
|
def custom_import(name, globals, locals, fromlist, level):
|
|
|
|
print("import", name, fromlist, level)
|
2020-03-22 22:26:08 -04:00
|
|
|
|
2019-07-31 08:34:43 -04:00
|
|
|
class M:
|
|
|
|
var = 456
|
2020-03-22 22:26:08 -04:00
|
|
|
|
2019-07-31 08:34:43 -04:00
|
|
|
return M
|
|
|
|
|
2020-03-22 22:26:08 -04:00
|
|
|
|
2019-07-31 08:34:43 -04:00
|
|
|
orig_import = __import__
|
|
|
|
try:
|
|
|
|
__import__("builtins").__import__ = custom_import
|
|
|
|
except AttributeError:
|
|
|
|
print("SKIP")
|
|
|
|
raise SystemExit
|
|
|
|
|
|
|
|
# import1a will be done via normal import which will import1b via our custom import
|
|
|
|
orig_import("import1a")
|