@@ -14,7 +14,7 @@ internal class ImportHook
14
14
static CLRModule root ;
15
15
static MethodWrapper hook ;
16
16
17
- #if ( PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36 )
17
+ #if PYTHON3
18
18
static IntPtr py_clr_module ;
19
19
static IntPtr module_def ;
20
20
#endif
@@ -30,10 +30,10 @@ internal static void Initialize()
30
30
// but it provides the most "Pythonic" way of dealing with CLR
31
31
// modules (Python doesn't provide a way to emulate packages).
32
32
IntPtr dict = Runtime . PyImport_GetModuleDict ( ) ;
33
- #if ( PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36 )
33
+ #if PYTHON3
34
34
IntPtr mod = Runtime . PyImport_ImportModule ( "builtins" ) ;
35
35
py_import = Runtime . PyObject_GetAttrString ( mod , "__import__" ) ;
36
- #else
36
+ #elif PYTHON2
37
37
IntPtr mod = Runtime . PyDict_GetItemString ( dict , "__builtin__" ) ;
38
38
py_import = Runtime . PyObject_GetAttrString ( mod , "__import__" ) ;
39
39
#endif
@@ -43,7 +43,7 @@ internal static void Initialize()
43
43
44
44
root = new CLRModule ( ) ;
45
45
46
- #if ( PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36 )
46
+ #if PYTHON3
47
47
// create a python module with the same methods as the clr module-like object
48
48
module_def = ModuleDefOffset . AllocModuleDef ( "clr" ) ;
49
49
py_clr_module = Runtime . PyModule_Create2 ( module_def , 3 ) ;
@@ -56,7 +56,7 @@ internal static void Initialize()
56
56
Runtime . PyDict_Update ( mod_dict , clr_dict ) ;
57
57
Runtime . PyDict_SetItemString ( dict , "CLR" , py_clr_module ) ;
58
58
Runtime . PyDict_SetItemString ( dict , "clr" , py_clr_module ) ;
59
- #else
59
+ #elif PYTHON2
60
60
Runtime . XIncref ( root . pyHandle ) ; // we are using the module two times
61
61
Runtime . PyDict_SetItemString ( dict , "CLR" , root . pyHandle ) ;
62
62
Runtime . PyDict_SetItemString ( dict , "clr" , root . pyHandle ) ;
@@ -70,13 +70,13 @@ internal static void Initialize()
70
70
71
71
internal static void Shutdown ( )
72
72
{
73
- #if ( PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36 )
73
+ #if PYTHON3
74
74
if ( 0 != Runtime . Py_IsInitialized ( ) ) {
75
75
Runtime . XDecref ( py_clr_module ) ;
76
76
Runtime . XDecref ( root . pyHandle ) ;
77
77
}
78
78
ModuleDefOffset . FreeModuleDef ( module_def ) ;
79
- #else
79
+ #elif PYTHON2
80
80
if ( 0 != Runtime . Py_IsInitialized ( ) )
81
81
{
82
82
Runtime . XDecref ( root . pyHandle ) ;
@@ -95,7 +95,7 @@ internal static void Shutdown()
95
95
public static IntPtr GetCLRModule ( IntPtr ? fromList = null )
96
96
{
97
97
root . InitializePreload ( ) ;
98
- #if ( PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36 )
98
+ #if PYTHON3
99
99
// update the module dictionary with the contents of the root dictionary
100
100
root . LoadNames ( ) ;
101
101
IntPtr py_mod_dict = Runtime . PyModule_GetDict ( py_clr_module ) ;
@@ -136,7 +136,7 @@ public static IntPtr GetCLRModule(IntPtr? fromList = null)
136
136
137
137
Runtime . XIncref ( py_clr_module ) ;
138
138
return py_clr_module ;
139
- #else
139
+ #elif PYTHON2
140
140
Runtime . XIncref ( root . pyHandle ) ;
141
141
return root . pyHandle ;
142
142
#endif
@@ -368,4 +368,4 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw)
368
368
return mod . pyHandle ;
369
369
}
370
370
}
371
- }
371
+ }
0 commit comments