2019-07-31 13:34:43 +01:00
|
|
|
# test overriding __import__ combined with importing from the filesystem
|
|
|
|
|
2020-03-23 02:26:08 +00:00
|
|
|
|
2019-07-31 13:34:43 +01:00
|
|
|
def custom_import(name, globals, locals, fromlist, level):
|
2020-03-23 02:26:08 +00:00
|
|
|
print("import", name, fromlist, level)
|
|
|
|
|
2019-07-31 13:34:43 +01:00
|
|
|
class M:
|
|
|
|
var = 456
|
2020-03-23 02:26:08 +00:00
|
|
|
|
2019-07-31 13:34:43 +01:00
|
|
|
return M
|
|
|
|
|
2020-03-23 02:26:08 +00:00
|
|
|
|
2019-07-31 13:34:43 +01: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
|
2020-03-23 02:26:08 +00:00
|
|
|
orig_import("import1a")
|