@@ -200,19 +200,26 @@ def test_obj_call():
200200 const string name = "test_domain_reload_mod" ;
201201 using ( Py . GIL ( ) )
202202 {
203+ // Create a new module
203204 IntPtr module = PyRuntime . PyModule_New ( name ) ;
204205 Assert . That ( module != IntPtr . Zero ) ;
205206 IntPtr globals = PyRuntime . PyObject_GetAttrString ( module , "__dict__" ) ;
206207 Assert . That ( globals != IntPtr . Zero ) ;
207208 try
208209 {
210+ // import builtins
211+ // module.__dict__[__builtins__] = builtins
209212 int res = PyRuntime . PyDict_SetItemString ( globals , "__builtins__" ,
210213 PyRuntime . PyEval_GetBuiltins ( ) ) ;
211214 PythonException . ThrowIfIsNotZero ( res ) ;
212215
216+ // Execute the code in the module's scope
213217 PythonEngine . Exec ( code , globals ) ;
218+ // import sys
219+ // modules = sys.modules
214220 IntPtr modules = PyRuntime . PyImport_GetModuleDict ( ) ;
215- res = PyRuntime . PyDict_SetItemString ( modules , name , modules ) ;
221+ // modules[name] = module
222+ res = PyRuntime . PyDict_SetItemString ( modules , name , module ) ;
216223 PythonException . ThrowIfIsNotZero ( res ) ;
217224 }
218225 catch
@@ -251,6 +258,11 @@ public override ValueType Execute(ValueType arg)
251258
252259
253260 [ Test ]
261+ /// <summary>
262+ /// Create a new Python module, define a function in it.
263+ /// Unload the domain, load a new one.
264+ /// Make sure the function (and module) still exists.
265+ /// </summary>
254266 public void TestClassReference ( )
255267 {
256268 RunDomainReloadSteps < ReloadClassRefStep1 , ReloadClassRefStep2 > ( ) ;
0 commit comments