Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e469a8a

Browse files
committed
fixups, add docs
1 parent d821c0f commit e469a8a

4 files changed

Lines changed: 23 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ One must now either use enum members (e.g. `MyEnum.Option`), or use enum constru
7373
- Providing an invalid type parameter to a generic type or method produces a helpful Python error
7474
- Empty parameter names (as can be generated from F#) do not cause crashes
7575

76-
7776
### Removed
7877

7978
- implicit assembly loading (you have to explicitly `clr.AddReference` before doing import)

src/runtime/importhook.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import clr
3434
class DotNetFinder(importlib.abc.MetaPathFinder):
3535
3636
def __init__(self):
37-
print('DotNetFinder init')
3837
super(DotNetFinder, self).__init__()
3938
4039
@classmethod
@@ -115,6 +114,12 @@ internal static void RestoreRuntimeData(RuntimeDataStorage storage)
115114
SetupNamespaceTracking();
116115
}
117116

117+
/// <summary>
118+
/// Sets up the tracking of loaded namespaces. This makes available to
119+
/// Python, as a Python object, the loaded namespaces. The set of loaded
120+
/// namespaces is used during the import to verify if we can import a
121+
/// CLR assembly as a module or not. The set is stored on the clr module.
122+
/// </summary>
118123
static void SetupNamespaceTracking ()
119124
{
120125
var newset = Runtime.PySet_New(IntPtr.Zero);
@@ -150,6 +155,10 @@ static void SetupNamespaceTracking ()
150155
PythonEngine.AddShutdownHandler(()=>AssemblyManager.namespaceAdded -= OnNamespaceAdded);
151156
}
152157

158+
/// <summary>
159+
/// Removes the set of available namespaces from the clr module and
160+
/// removes the callback on the OnNamespaceAdded event.
161+
/// </summary>
153162
static void TeardownNameSpaceTracking()
154163
{
155164
AssemblyManager.namespaceAdded -= OnNamespaceAdded;

src/runtime/moduleobject.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,15 @@ public static int _AtExit()
582582
return Runtime.AtExit();
583583
}
584584

585+
586+
/// <summary>
587+
/// Note: This should *not* be called directly.
588+
/// The function that get/import a CLR assembly as a python module.
589+
/// This function should only be called by the import machinery as seen
590+
/// in importhook.cs
591+
/// </summary>
592+
/// <param name="spec">A ModuleSpec Python object</param>
593+
/// <returns>A new reference to the imported module, as a PyObject.</returns>
585594
[ModuleFunction]
586595
[ForbidPythonThreads]
587596
public static PyObject _LoadClrModule(PyObject spec)

tests/domain_tests/TestRunner.cs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,28 +1096,11 @@ assert sys.my_obj is not None
10961096
},
10971097
new TestCase
10981098
{
1099-
// The C# code for this test doesn't matter.
1099+
// The C# code for this test doesn't matter; we're testing
1100+
// that the import hook behaves properly after a domain reload
11001101
Name = "import_after_reload",
1101-
DotNetBefore = @"
1102-
namespace TestNamespace
1103-
{
1104-
[System.Serializable]
1105-
public class Cls
1106-
{
1107-
}
1108-
}",
1109-
DotNetAfter = @"
1110-
namespace TestNamespace
1111-
{
1112-
[System.Serializable]
1113-
public class WithNestedType
1114-
{
1115-
[System.Serializable]
1116-
public class Cls
1117-
{
1118-
}
1119-
}
1120-
}",
1102+
DotNetBefore = "",
1103+
DotNetAfter = "",
11211104
PythonCode = @"
11221105
import sys
11231106

0 commit comments

Comments
 (0)