Update fimport.py
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
# Arbitrary file importing utility. Does NOT modify sys.modules
|
||||
#
|
||||
#===========================================================================
|
||||
import importlib
|
||||
#import importlib
|
||||
import os
|
||||
import types
|
||||
|
||||
def fimport( filePath ):
|
||||
# Read the file and compile the code. This will fail if the file
|
||||
@@ -19,7 +20,7 @@ def fimport( filePath ):
|
||||
rootName, ext = os.path.splitext( fileName )
|
||||
|
||||
# Create a new module and exec the code in it's context.
|
||||
m = importlib.import_module( rootName )
|
||||
m = types.ModuleType( rootName )
|
||||
m.__file__ = absPath
|
||||
exec(code, m.__dict__)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user