Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
5d6e5d5
use reference types instead of IntPtr where possible in runtime.cs
lostmsu Oct 17, 2021
2d33902
switched converter.cs to the new style references
lostmsu Oct 17, 2021
f8b761a
switched most of classbase.cs to the new style references (except cro…
lostmsu Oct 17, 2021
09d8e41
switched pyobject.cs to the new style references
lostmsu Oct 17, 2021
1b58cf4
mostly switched moduleobject.cs to the new style references
lostmsu Oct 17, 2021
c05c6ec
switched methodbinder.cs to the new style references
lostmsu Oct 17, 2021
d626f7e
partially switched classderived.cs to the new reference style
lostmsu Oct 17, 2021
ff60ec4
switched arrayobject.cs to the new style references
lostmsu Oct 17, 2021
0010fa0
switched delegatemanager.cs to the new style references
lostmsu Oct 17, 2021
178a359
partially switched metatype.cs to the new style references
lostmsu Oct 18, 2021
9764b25
switched typemanager.cs to the new style references
lostmsu Oct 18, 2021
11edcc3
switched pytype.cs to the new style references
lostmsu Oct 18, 2021
2e71874
mass enable nullable types
lostmsu Oct 18, 2021
3076040
fixed nullablity in arrayobject.cs
lostmsu Oct 18, 2021
56f3bd5
fixed nullability in assemblymanager.cs
lostmsu Oct 18, 2021
58cb0e6
switched classmanager.cs to the new style references
lostmsu Oct 18, 2021
2095b46
switched classobject.cs to the new style references
lostmsu Oct 18, 2021
f6b84da
partially switched managedtype.cs to the new style references
lostmsu Oct 18, 2021
ee65632
partially switched classmanager.cs to the new style references
lostmsu Oct 18, 2021
5266dc4
PyIdentifier public members to return borrowed references
lostmsu Oct 6, 2021
0bc3670
added nullability annotations to methodbinder.cs
lostmsu Oct 18, 2021
de9a8cb
switched methodbinding.cs and methodobject.cs to the new style refere…
lostmsu Oct 18, 2021
9195c30
switched overload.cs to the new style references
lostmsu Oct 18, 2021
590de7a
switched propertyobject.cs to the new style references
lostmsu Oct 18, 2021
7fa537a
switched delegateobject.cs to the new style references
lostmsu Oct 18, 2021
49124fc
switched module.cs to the new style references
lostmsu Oct 18, 2021
9db9b0b
nullability annotations for PyObject
lostmsu Oct 18, 2021
00fd17a
switched modulefunctionobject.cs to the new style references
lostmsu Oct 18, 2021
5798b41
minor refactorings
lostmsu Oct 18, 2021
ebdf7c5
partially switched moduleobject.cs and importhook.cs to the new style…
lostmsu Oct 18, 2021
5ad09e4
switched exceptions.cs to the new style references
lostmsu Oct 18, 2021
d1abd9a
switched interfaceobject.cs to the new style references
lostmsu Oct 18, 2021
43a862a
switched pythonexception.cs to the new style references
lostmsu Oct 18, 2021
1d80162
switched pytuple.cs to the new style references
lostmsu Oct 18, 2021
0241b38
switched eventobject.cs and eventbiding.cs to the new style references
lostmsu Oct 18, 2021
2ac952a
switched all PyObject derived classes to the new style references
lostmsu Oct 18, 2021
7adf98a
implemented non-confusing PyModule_AddObject
lostmsu Oct 18, 2021
2dd3f8f
switched pythonengine.cs to the new style references
lostmsu Oct 18, 2021
3b79019
switched fieldobject.cs and constructorbinding.cs to the new style re…
lostmsu Oct 18, 2021
9b990c1
switched finalizer.cs to the new style references
lostmsu Oct 19, 2021
027e529
switched debughelper.cs to the new style references
lostmsu Oct 19, 2021
4793818
switched converter extensions and sample codecs to the new style refe…
lostmsu Oct 19, 2021
0d60500
switched collection wrappers (from sample codec) to the new style ref…
lostmsu Oct 19, 2021
cf606a2
switched iterator.cs and indexer.cs to the new style references
lostmsu Oct 19, 2021
bb84c48
getting rid of a few minor warnings and compile errors
lostmsu Oct 19, 2021
e295679
switched to new references in some tests
lostmsu Oct 19, 2021
7a9e411
switched state serialization to new reference types (untested)
lostmsu Oct 19, 2021
9a9ed3b
minor error fixes
lostmsu Oct 19, 2021
581f695
assume remaning manual refcounting is not needed, because we use smar…
lostmsu Oct 19, 2021
07f1657
fixed new reference uses, that are not allowed in C#
lostmsu Oct 19, 2021
7deebd4
renamed parameter in tp_dealloc functions for clarity
lostmsu Oct 19, 2021
8619e77
allowed untested calls to PyObject_GC_Del and XDecref (3 in total)
lostmsu Oct 19, 2021
672aef6
fixed compile errors in TypeMethod (untested)
lostmsu Oct 19, 2021
c4909d4
workaround for analyzer not permitting copying a reference as the las…
lostmsu Oct 19, 2021
6fa2004
switched tests to match the new reference changes
lostmsu Oct 19, 2021
14949fb
fixed thunk loading for slots, that use new reference types
lostmsu Oct 19, 2021
0728e21
fixed PyObject_DelAttr load from DLL failing
lostmsu Oct 19, 2021
fe4c481
fixed uses of Marshal.Read/Marshal.Write overloads with first argumen…
lostmsu Oct 19, 2021
4346d41
fixed OnSerialized and OnDeserialized in PyObject not being typed cor…
lostmsu Oct 19, 2021
62e193a
fixed bad equality comparisons
lostmsu Oct 20, 2021
2fa8b9c
improved reliability of Clean and Dealloc implementations
lostmsu Oct 20, 2021
d6607b0
bad if condition
lostmsu Oct 20, 2021
6335d97
improved GetThunk reliability
lostmsu Oct 20, 2021
d649d6c
fixed circular dependency in Runtime PyMembers and InternString initi…
lostmsu Oct 20, 2021
d1bc193
tiny refactor
lostmsu Oct 20, 2021
32c4bb6
switched generictype.cs to the new style references
lostmsu Oct 20, 2021
a1427ac
increfs in OnSave are no longer necessary with the new references
lostmsu Oct 20, 2021
cd97a46
fixed MethodBinding failing for reference types
lostmsu Oct 20, 2021
05ecbcf
nullability annotation fix in MaybeMethodBase
lostmsu Oct 20, 2021
a3591b6
minor improvements
lostmsu Oct 20, 2021
7ed0c7a
WIP
lostmsu Oct 24, 2021
d6a853f
avoid generating and handling useless SerializationException when May…
lostmsu Oct 28, 2021
b0c25c1
finalizer does not attempt to finalize objects when runtime is shut down
lostmsu Oct 28, 2021
5ca474a
PyType Dict and MRO properties to assist debugging
lostmsu Oct 28, 2021
48078b3
WIP 2
lostmsu Oct 28, 2021
a624dd8
fixed PyObject disposal crashing when runtime is still finalizing
lostmsu Oct 29, 2021
e7ab071
arrays: use 64 bit indexing, and avoid first chance .NET exceptions o…
lostmsu Oct 29, 2021
cbe1dd2
refactored conditional ClassBase slot initialization
lostmsu Oct 29, 2021
d5f1c48
removed DisposePythonWrappersForClrTypes
lostmsu Oct 29, 2021
74d87c5
simplified outdated condition in ClassBase.tp_clear
lostmsu Oct 29, 2021
82d6c33
sprinkled a few DebuggerHidden to make debugging easier
lostmsu Oct 29, 2021
eeebcd7
fixed derived classes not inheriting slots correctly
lostmsu Oct 29, 2021
8ee8d3d
remove unused TypeManager._slotImpls
lostmsu Oct 29, 2021
1a4ada7
fixed TestRuntime not building in Release mode
lostmsu Oct 30, 2021
a610aa3
can't really clear managed references to Python objects from ManagedT…
lostmsu Oct 30, 2021
03f32cb
PythonException is serializable
lostmsu Oct 30, 2021
b1c9f5b
EventObject no longer used for static events. EventBinding is constru…
lostmsu Oct 30, 2021
cb4bb9a
use a special class to stub .NET types that no longer exist after a d…
lostmsu Nov 2, 2021
652f946
make EventHandlerCollection serializable
lostmsu Nov 2, 2021
84db670
fixed MaybeMemberInfo always failing for properties
lostmsu Nov 2, 2021
56fafe3
fixed construct_removed_class domain reload test case
lostmsu Nov 2, 2021
d33dcdd
domain reload test runner can run test by index
lostmsu Nov 2, 2021
b737e10
minor docs change
lostmsu Nov 2, 2021
d3e4fba
assert check in GetUnmanagedBaseType for null base
lostmsu Nov 2, 2021
e003e12
PythonEngine .Exec and .Eval no longer work with raw pointers
lostmsu Nov 9, 2021
d0a6f44
a few annotation to ease debugging
lostmsu Nov 9, 2021
e31f7ba
ensure Python types continue to exist when registered decoders for th…
lostmsu Nov 9, 2021
48c0dfc
GC-related WIP
lostmsu Nov 9, 2021
44d65d9
merge latest master
lostmsu Nov 23, 2021
cb58147
merge latest changes from upstream
lostmsu Nov 23, 2021
2fdbf0e
added TraceAlloc solution configuration
lostmsu Nov 24, 2021
a8ef06c
fixed sending PyObject across domain boundary
lostmsu Nov 24, 2021
7167229
fixed accidental premature disposal of Runtime.PyNone
lostmsu Nov 24, 2021
ab11fa2
made freeing GCHandles more robust
lostmsu Nov 24, 2021
7a4daeb
removed bad assert in generated constructor for derived classes
lostmsu Nov 24, 2021
e422367
fixed __pyobj__ access
lostmsu Nov 24, 2021
a74ea86
minor
lostmsu Nov 24, 2021
0325a8c
fixed Python derived types trying to double-free GCHandle when collec…
lostmsu Nov 24, 2021
85fab3b
reinstate collection assert on shutdown from Python
lostmsu Nov 24, 2021
932fce2
fixed crash when Python derived class instances survive past early sh…
lostmsu Nov 24, 2021
c2e207a
delay nulling GC handles of reflected instances until the last moment…
lostmsu Nov 24, 2021
c8f0f09
fixed assert in XDecref in case _Py_IsFinalizing is not present
lostmsu Nov 24, 2021
e269cf0
when initialized from Python, reset slots implemented in CLR: CLR mig…
lostmsu Nov 25, 2021
d7d5cb7
fixed minor warnings
lostmsu Nov 25, 2021
d6edace
fixed line endings in intern_.cs
lostmsu Nov 25, 2021
a86994f
use NonCopyableAnalyzer 0.7.0-m05
lostmsu Nov 25, 2021
2e040ea
Merge pull request #2 from losttech/ManagedType-DontKeepBorrowedRefs
lostmsu Dec 9, 2021
b614dba
merge latest master
lostmsu Dec 9, 2021
f09a48b
fixed MacOS bad assembly test by using PythonDLL (which is never a .N…
lostmsu Dec 9, 2021
3794fea
Merge branch 'master' into precise-API-references
lostmsu Dec 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
partially switched moduleobject.cs and importhook.cs to the new style…
… references
  • Loading branch information
lostmsu committed Oct 18, 2021
commit ebdf7c529a05ee2b2c74e10b0667f00c10233221
94 changes: 35 additions & 59 deletions src/runtime/importhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ namespace Python.Runtime
/// </summary>
internal static class ImportHook
{
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
// set in Initialize
private static CLRModule root;
private static IntPtr py_clr_module;
static BorrowedReference ClrModuleReference => new BorrowedReference(py_clr_module);
private static PyModule py_clr_module;
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
static BorrowedReference ClrModuleReference => py_clr_module.Reference;

private const string LoaderCode = @"
import importlib.abc
Expand Down Expand Up @@ -54,13 +57,13 @@ internal static unsafe void Initialize()
root = new CLRModule();

// create a python module with the same methods as the clr module-like object
py_clr_module = Runtime.PyModule_New("clr").DangerousMoveToPointer();
py_clr_module = new PyModule(Runtime.PyModule_New("clr").StealOrThrow());

// both dicts are borrowed references
BorrowedReference mod_dict = Runtime.PyModule_GetDict(ClrModuleReference);
using var clr_dict = Runtime.PyObject_GenericGetDict(root.ObjectReference);

Runtime.PyDict_Update(mod_dict, clr_dict);
Runtime.PyDict_Update(mod_dict, clr_dict.BorrowOrThrow());
BorrowedReference dict = Runtime.PyImport_GetModuleDict();
Runtime.PyDict_SetItemString(dict, "CLR", ClrModuleReference);
Runtime.PyDict_SetItemString(dict, "clr", ClrModuleReference);
Expand All @@ -79,11 +82,10 @@ internal static void Shutdown()
}

TeardownNameSpaceTracking();
Runtime.XDecref(py_clr_module);
py_clr_module = IntPtr.Zero;
Runtime.Py_CLEAR(ref py_clr_module!);

Runtime.XDecref(root.pyHandle);
root = null;
root = null!;
CLRModule.Reset();
}

Expand All @@ -110,32 +112,32 @@ internal static void RestoreRuntimeData(RuntimeDataStorage storage)
static void SetupImportHook()
{
// Create the import hook module
var import_hook_module = Runtime.PyModule_New("clr.loader");
using var import_hook_module = Runtime.PyModule_New("clr.loader");
BorrowedReference mod_dict = Runtime.PyModule_GetDict(import_hook_module.BorrowOrThrow());

// Run the python code to create the module's classes.
var builtins = Runtime.PyEval_GetBuiltins();
var exec = Runtime.PyDict_GetItemString(builtins, "exec");
using var args = NewReference.DangerousFromPointer(Runtime.PyTuple_New(2));

var codeStr = NewReference.DangerousFromPointer(Runtime.PyString_FromString(LoaderCode));
Runtime.PyTuple_SetItem(args, 0, codeStr);
var mod_dict = Runtime.PyModule_GetDict(import_hook_module);
using var args = Runtime.PyTuple_New(2);
PythonException.ThrowIfIsNull(args);
using var codeStr = Runtime.PyString_FromString(LoaderCode);
Runtime.PyTuple_SetItem(args.Borrow(), 0, codeStr.StealOrThrow());

// reference not stolen due to overload incref'ing for us.
Runtime.PyTuple_SetItem(args, 1, mod_dict);
Runtime.PyObject_Call(exec, args, default).Dispose();
Runtime.PyTuple_SetItem(args.Borrow(), 1, mod_dict);
Runtime.PyObject_Call(exec, args.Borrow(), default).Dispose();
// Set as a sub-module of clr.
if(Runtime.PyModule_AddObject(ClrModuleReference, "loader", import_hook_module.DangerousGetAddress()) != 0)
if(Runtime.PyModule_AddObject(ClrModuleReference, "loader", import_hook_module) != 0)
{
Runtime.XDecref(import_hook_module.DangerousGetAddress());
throw PythonException.ThrowLastAsClrException();
}

// Finally, add the hook to the meta path
var findercls = Runtime.PyDict_GetItemString(mod_dict, "DotNetFinder");
var finderCtorArgs = NewReference.DangerousFromPointer(Runtime.PyTuple_New(0));
var finder_inst = Runtime.PyObject_CallObject(findercls, finderCtorArgs);
using var finderCtorArgs = Runtime.PyTuple_New(0);
using var finder_inst = Runtime.PyObject_CallObject(findercls, finderCtorArgs.Borrow());
var metapath = Runtime.PySys_GetObject("meta_path");
Runtime.PyList_Append(metapath, finder_inst);
PythonException.ThrowIfIsNotZero(Runtime.PyList_Append(metapath, finder_inst.BorrowOrThrow()));
}

/// <summary>
Expand All @@ -149,12 +151,12 @@ static void SetupNamespaceTracking()
using var newset = Runtime.PySet_New(default);
foreach (var ns in AssemblyManager.GetNamespaces())
{
using var pyNs = NewReference.DangerousFromPointer(Runtime.PyString_FromString(ns));
if (Runtime.PySet_Add(newset, pyNs) != 0)
using var pyNs = Runtime.PyString_FromString(ns);
if (Runtime.PySet_Add(newset.Borrow(), pyNs.BorrowOrThrow()) != 0)
{
throw PythonException.ThrowLastAsClrException();
}
if (Runtime.PyDict_SetItemString(root.dict, availableNsKey, newset) != 0)
if (Runtime.PyDict_SetItemString(root.dict, availableNsKey, newset.Borrow()) != 0)
{
throw PythonException.ThrowLastAsClrException();
}
Expand Down Expand Up @@ -187,22 +189,15 @@ internal static int AddPendingNamespaces()

internal static void AddNamespaceWithGIL(string name)
{
var pyNs = Runtime.PyString_FromString(name);
try
using var pyNs = Runtime.PyString_FromString(name);
var nsSet = Runtime.PyDict_GetItemString(root.dict, availableNsKey);
if (!(nsSet.IsNull || nsSet == Runtime.PyNone))
{
var nsSet = Runtime.PyDict_GetItemString(root.dict, availableNsKey);
if (!(nsSet.IsNull || nsSet.DangerousGetAddress() == Runtime.PyNone))
if (Runtime.PySet_Add(nsSet, pyNs.BorrowOrThrow()) != 0)
{
if (Runtime.PySet_Add(nsSet, new BorrowedReference(pyNs)) != 0)
{
throw PythonException.ThrowLastAsClrException();
}
throw PythonException.ThrowLastAsClrException();
}
}
finally
{
Runtime.XDecref(pyNs);
}
}


Expand All @@ -218,8 +213,7 @@ internal static void UpdateCLRModuleDict()
root.LoadNames();
BorrowedReference py_mod_dict = Runtime.PyModule_GetDict(ClrModuleReference);
using var clr_dict = Runtime.PyObject_GenericGetDict(root.ObjectReference);

Runtime.PyDict_Update(py_mod_dict, clr_dict);
Runtime.PyDict_Update(py_mod_dict, clr_dict.BorrowOrThrow());
}

/// <summary>
Expand All @@ -228,15 +222,14 @@ internal static void UpdateCLRModuleDict()
public static unsafe NewReference GetCLRModule()
{
UpdateCLRModuleDict();
Runtime.XIncref(py_clr_module);
return NewReference.DangerousFromPointer(py_clr_module);
return new NewReference(py_clr_module);
}

/// <summary>
/// The hook to import a CLR module into Python. Returns a new reference
/// to the module.
/// </summary>
public static ModuleObject Import(string modname)
public static PyObject Import(string modname)
{
// Traverse the qualified module name to get the named module.
// Note that if
Expand All @@ -248,7 +241,7 @@ public static ModuleObject Import(string modname)
// enable preloading in a non-interactive python processing by
// setting clr.preload = True

ModuleObject head = null;
ModuleObject? head = null;
ModuleObject tail = root;
root.InitializePreload();

Expand All @@ -271,24 +264,7 @@ public static ModuleObject Import(string modname)
tail.LoadNames();
}
}
tail.IncrRefCount();
return tail;
}

private static bool IsLoadAll(BorrowedReference fromList)
{
if (fromList == null) throw new ArgumentNullException(nameof(fromList));

if (CLRModule.preload)
{
return false;
}
if (Runtime.PySequence_Size(fromList) != 1)
{
return false;
}
using var fp = Runtime.PySequence_GetItem(fromList, 0);
return Runtime.GetManagedString(fp) == "*";
return new PyObject(tail.ObjectReference);
}
}
}
33 changes: 16 additions & 17 deletions src/runtime/moduleobject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class ModuleObject : ExtensionType
private Dictionary<string, ManagedType> cache;

internal string moduleName;
private readonly PyDict dict;
internal readonly PyDict dict;
protected string _namespace;
private readonly PyList __all__ = new ();

Expand Down Expand Up @@ -69,10 +69,9 @@ public ModuleObject(string name)
/// namespace (or null if the name is not found). This method does
/// not increment the Python refcount of the returned object.
/// </summary>
public ManagedType GetAttribute(string name, bool guess)
public ManagedType? GetAttribute(string name, bool guess)
{
ManagedType cached = null;
cache.TryGetValue(name, out cached);
cache.TryGetValue(name, out var cached);
if (cached != null)
{
return cached;
Expand Down Expand Up @@ -130,7 +129,7 @@ public ManagedType GetAttribute(string name, bool guess)
string gname = GenericUtil.GenericNameForBaseName(_namespace, name);
if (gname != null)
{
ManagedType o = GetAttribute(gname, false);
ManagedType? o = GetAttribute(gname, false);
if (o != null)
{
StoreAttribute(name, o);
Expand Down Expand Up @@ -169,10 +168,9 @@ private void StoreAttribute(string name, ManagedType ob)
/// </summary>
public void LoadNames()
{
ManagedType m = null;
foreach (string name in AssemblyManager.GetNames(_namespace))
{
cache.TryGetValue(name, out m);
cache.TryGetValue(name, out var m);
if (m != null)
{
continue;
Expand Down Expand Up @@ -252,7 +250,7 @@ internal void InitializeModuleMembers()
/// </summary>
public static NewReference tp_getattro(BorrowedReference ob, BorrowedReference key)
{
var self = (ModuleObject)GetManagedObject(ob);
var self = (ModuleObject)GetManagedObject(ob)!;

if (!Runtime.PyString_Check(key))
{
Expand All @@ -266,7 +264,7 @@ public static NewReference tp_getattro(BorrowedReference ob, BorrowedReference k
return new NewReference(op);
}

string name = InternString.GetManagedString(key);
string? name = InternString.GetManagedString(key);
if (name == "__dict__")
{
return new NewReference(self.dict);
Expand All @@ -278,10 +276,11 @@ public static NewReference tp_getattro(BorrowedReference ob, BorrowedReference k
return new NewReference(self.__all__);
}

ManagedType attr = null;
ManagedType? attr;

try
{
if (name is null) throw new ArgumentNullException();
attr = self.GetAttribute(name, true);
}
catch (Exception e)
Expand All @@ -305,13 +304,13 @@ public static NewReference tp_getattro(BorrowedReference ob, BorrowedReference k
/// </summary>
public static NewReference tp_repr(BorrowedReference ob)
{
var self = (ModuleObject)GetManagedObject(ob);
var self = (ModuleObject)GetManagedObject(ob)!;
return Runtime.PyString_FromString($"<module '{self.moduleName}'>");
}

public static int tp_traverse(BorrowedReference ob, IntPtr visit, IntPtr arg)
{
var self = (ModuleObject)GetManagedObject(ob);
var self = (ModuleObject)GetManagedObject(ob)!;
int res = PyVisit(self.dict, visit, arg);
if (res != 0) return res;
foreach (var attr in self.cache.Values)
Expand Down Expand Up @@ -346,7 +345,7 @@ protected override void Clear()
if ((settableAttributes.Contains(managedKey)) ||
(ManagedType.GetManagedObject(val)?.GetType() == typeof(ModuleObject)) )
{
var self = (ModuleObject)ManagedType.GetManagedObject(ob);
var self = (ModuleObject)ManagedType.GetManagedObject(ob)!;
return Runtime.PyDict_SetItem(self.dict, key, val);
}

Expand Down Expand Up @@ -493,7 +492,7 @@ public static Assembly AddReference(string name)
{
AssemblyManager.UpdatePath();
var origNs = AssemblyManager.GetNamespaces();
Assembly assembly = null;
Assembly? assembly = null;
assembly = AssemblyManager.FindLoadedAssembly(name);
if (assembly == null)
{
Expand Down Expand Up @@ -579,11 +578,11 @@ public static string[] ListAssemblies(bool verbose)
/// <returns>A new reference to the imported module, as a PyObject.</returns>
[ModuleFunction]
[ForbidPythonThreads]
public static ModuleObject _load_clr_module(PyObject spec)
public static PyObject _load_clr_module(PyObject spec)
{
ModuleObject mod = null;
using var modname = spec.GetAttr("name");
mod = ImportHook.Import(modname.ToString());
string name = modname.As<string?>() ?? throw new ArgumentException("name must not be None");
var mod = ImportHook.Import(name);
return mod;
}

Expand Down