8000 Revert "(WIP) import hook in the pytohn module" · pythonnet/pythonnet@73958ed · GitHub
[go: up one dir, main page]

Skip to content

Commit 73958ed

Browse files
committed
Revert "(WIP) import hook in the pytohn module"
This reverts commit 4684523.
1 parent be81364 commit 73958ed

File tree

5 files changed

+14
-47
lines changed

5 files changed

+14
-47
lines changed

pythonnet/util/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from ..find_libpython import find_libpython
1+
from .find_libpython import find_libpython

pythonnet/util/import_hook.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/runtime/importhook.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ internal static unsafe void Initialize()
6969

7070
// Add/create the MetaPathLoader
7171
SetupNamespaceTracking();
72-
PythonEngine.Exec("import pythonnet.util.import_hook;pythonnet.util.import_hook.init_import_hook()");
72+
PythonEngine.Exec(LoaderCode);
7373
}
7474

7575

@@ -225,7 +225,7 @@ public static unsafe NewReference GetCLRModule()
225225
/// <summary>
226226
/// The hook to import a CLR module into Python
227227
/// </summary>
228-
public static ModuleObject Import(string modname)
228+
public static ModuleObject __import__(string modname)
229229
{
230230
// Traverse the qualified module name to get the named module.
231231
// Note that if

src/runtime/moduleobject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ public static PyObject _LoadClrModule(PyObject spec)
598598
ModuleObject mod = null;
599599
using (var modname = spec.GetAttr("name"))
600600
{
601-
mod = ImportHook.Import(modname.ToString());
601+
mod = ImportHook.__import__(modname.ToString());
602602
}
603603
// We can't return directly a ModuleObject, because the tpHandle is
604604
// not set, but we can return a PyObject.

src/runtime/runtime.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,6 @@ internal static void Initialize(bool initSigs = false, ShutdownMode mode = Shutd
153153
ClassDerivedObject.Reset();
154154
TypeManager.Initialize();
155155

156-
// Need to add the runtime directory to sys.path so that we
157-
// can find built-in assemblies like System.Data, et. al.
158-
string rtdir = RuntimeEnvironment.GetRuntimeDirectory();
159-
IntPtr path = PySys_GetObject("path").DangerousGetAddress();
160-
IntPtr item = PyString_FromString(rtdir);
161-
if (PySequence_Contains(path, item) == 0)
162-
{
163-
PyList_Append(new BorrowedReference(path), item);
164-
}
165-
XDecref(item);
166156
// Initialize modules that depend on the runtime class.
167157
AssemblyManager.Initialize();
168158
OperatorMethod.Initialize();
@@ -177,6 +167,16 @@ internal static void Initialize(bool initSigs = false, ShutdownMode mode = Shutd
177167
}
178168
Exceptions.Initialize();
179169

170+
// Need to add the runtime directory to sys.path so that we
171+
// can find built-in assemblies like System.Data, et. al.
172+
string rtdir = RuntimeEnvironment.GetRuntimeDirectory();
173+
IntPtr path = PySys_GetObject("path").DangerousGetAddress();
174+
IntPtr item = PyString_FromString(rtdir);
175+
if (PySequence_Contains(path, item) == 0)
176+
{
177+
PyList_Append(new BorrowedReference(path), item);
178+
}
179+
XDecref(item);
180180
AssemblyManager.UpdatePath();
181181
}
182182

0 commit comments

Comments
 (0)
0