File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -888,6 +888,46 @@ assert sys.my_obj is not None
888
888
foo = sys.my_obj.Inner()
889
889
print(foo)
890
890
891
+ " ,
892
+ } ,
893
+ new TestCase
894
+ {
895
+ // The C# code for this test doesn't matter.
896
+ Name = "import_after_reload" ,
897
+ DotNetBefore = @"
898
+ namespace TestNamespace
899
+ {
900
+ [System.Serializable]
901
+ public class Cls
902
+ {
903
+ }
904
+ }" ,
905
+ DotNetAfter = @"
906
+ namespace TestNamespace
907
+ {
908
+ [System.Serializable]
909
+ public class WithNestedType
910
+ {
911
+ [System.Serializable]
912
+ public class Cls
913
+ {
914
+ }
915
+ }
916
+ }" ,
917
+ PythonCode = @"
918
+ import sys
919
+
920
+ def before_reload():
921
+ import clr
922
+ import System
923
+
924
+
925
+ def after_reload():
926
+ assert 'System' in sys.modules
927
+ assert 'clr' in sys.modules
928
+ import clr
929
+ import System
930
+
891
931
" ,
892
932
} ,
893
933
} ;
Original file line number Diff line number Diff line change @@ -86,3 +86,7 @@ def test_out_to_ref_param():
86
86
@pytest .mark .skipif (platform .system () == 'Darwin' , reason = 'FIXME: macos can\' t find the python library' )
87
87
def test_nested_type ():
88
88
_run_test ("nested_type" )
89
+
90
+ @pytest .mark .skipif (platform .system () == 'Darwin' , reason = 'FIXME: macos can\' t find the python library' )
91
+ def test_import_after_reload ():
92
+ _run_test ("import_after_reload" )
Original file line number Diff line number Diff line change @@ -134,6 +134,9 @@ internal static void RestoreRuntimeData(RuntimeDataStorage storage)
134
134
storage . GetValue ( "py_clr_module" , out py_clr_module ) ;
135
135
var rootHandle = storage . GetValue < IntPtr > ( "root" ) ;
136
136
root = ( CLRModule ) ManagedType . GetManagedObject ( rootHandle ) ;
137
+ IntPtr dict = Runtime . PyImport_GetModuleDict ( ) ;
138
+ Runtime . PyDict_SetItemString ( dict , "CLR" , py_clr_module ) ;
139
+ Runtime . PyDict_SetItemString ( dict , "clr" , py_clr_module ) ;
137
140
SetupNamespaceTracking ( ) ;
138
141
}
139
142
You can’t perform that action at this time.
0 commit comments