@@ -14,7 +14,7 @@ internal class ImportHook
1414 static CLRModule root ;
1515 static MethodWrapper hook ;
1616
17- #if ( PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36 )
17+ #if PYTHON3
1818 static IntPtr py_clr_module ;
1919 static IntPtr module_def ;
2020#endif
@@ -30,10 +30,10 @@ internal static void Initialize()
3030 // but it provides the most "Pythonic" way of dealing with CLR
3131 // modules (Python doesn't provide a way to emulate packages).
3232 IntPtr dict = Runtime . PyImport_GetModuleDict ( ) ;
33- #if ( PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36 )
33+ #if PYTHON3
3434 IntPtr mod = Runtime . PyImport_ImportModule ( "builtins" ) ;
3535 py_import = Runtime . PyObject_GetAttrString ( mod , "__import__" ) ;
36- #else
36+ #elif PYTHON2
3737 IntPtr mod = Runtime . PyDict_GetItemString ( dict , "__builtin__" ) ;
3838 py_import = Runtime . PyObject_GetAttrString ( mod , "__import__" ) ;
3939#endif
@@ -43,7 +43,7 @@ internal static void Initialize()
4343
4444 root = new CLRModule ( ) ;
4545
46- #if ( PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36 )
46+ #if PYTHON3
4747 // create a python module with the same methods as the clr module-like object
4848 module_def = ModuleDefOffset . AllocModuleDef ( "clr" ) ;
4949 py_clr_module = Runtime . PyModule_Create2 ( module_def , 3 ) ;
@@ -56,7 +56,7 @@ internal static void Initialize()
5656 Runtime . PyDict_Update ( mod_dict , clr_dict ) ;
5757 Runtime . PyDict_SetItemString ( dict , "CLR" , py_clr_module ) ;
5858 Runtime . PyDict_SetItemString ( dict , "clr" , py_clr_module ) ;
59- #else
59+ #elif PYTHON2
6060 Runtime . XIncref ( root . pyHandle ) ; // we are using the module two times
6161 Runtime . PyDict_SetItemString ( dict , "CLR" , root . pyHandle ) ;
6262 Runtime . PyDict_SetItemString ( dict , "clr" , root . pyHandle ) ;
@@ -70,13 +70,13 @@ internal static void Initialize()
7070
7171 internal static void Shutdown ( )
7272 {
73- #if ( PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36 )
73+ #if PYTHON3
7474 if ( 0 != Runtime . Py_IsInitialized ( ) ) {
7575 Runtime . XDecref ( py_clr_module ) ;
7676 Runtime . XDecref ( root . pyHandle ) ;
7777 }
7878 ModuleDefOffset . FreeModuleDef ( module_def ) ;
79- #else
79+ #elif PYTHON2
8080 if ( 0 != Runtime . Py_IsInitialized ( ) )
8181 {
8282 Runtime . XDecref ( root . pyHandle ) ;
@@ -95,7 +95,7 @@ internal static void Shutdown()
9595 public static IntPtr GetCLRModule ( IntPtr ? fromList = null )
9696 {
9797 root . InitializePreload ( ) ;
98- #if ( PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36 )
98+ #if PYTHON3
9999 // update the module dictionary with the contents of the root dictionary
100100 root . LoadNames ( ) ;
101101 IntPtr py_mod_dict = Runtime . PyModule_GetDict ( py_clr_module ) ;
@@ -136,7 +136,7 @@ public static IntPtr GetCLRModule(IntPtr? fromList = null)
136136
137137 Runtime . XIncref ( py_clr_module ) ;
138138 return py_clr_module ;
139- #else
139+ #elif PYTHON2
140140 Runtime . XIncref ( root . pyHandle ) ;
141141 return root . pyHandle ;
142142#endif
@@ -368,4 +368,4 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw)
368368 return mod . pyHandle ;
369369 }
370370 }
371- }
371+ }
0 commit comments