| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -84,7 +84,7 @@ internal static IntPtr GetPythonTypeByAlias(Type op) | |||
| 84 | 84 | { | |
| 85 | 85 | return Runtime.PyUnicodeType; | |
| 86 | 86 | } | |
| 87 | - #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 87 | + #if PYTHON3 | ||
| 88 | 88 | else if ((op == int16Type) || | |
| 89 | 89 | (op == int32Type) || | |
| 90 | 90 | (op == int64Type)) { | |
@@ -450,7 +450,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result, | |||
| 450 | 450 | return true; | |
| 451 | 451 | ||
| 452 | 452 | case TypeCode.Int32: | |
| 453 | - #if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 453 | + #if PYTHON2 | ||
| 454 | 454 | // Trickery to support 64-bit platforms. | |
| 455 | 455 | if (IntPtr.Size == 4) | |
| 456 | 456 | { | |
@@ -478,7 +478,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result, | |||
| 478 | 478 | } | |
| 479 | 479 | else | |
| 480 | 480 | { | |
| 481 | - #else | ||
| 481 | + #elif PYTHON3 | ||
| 482 | 482 | // When using Python3 always use the PyLong API | |
| 483 | 483 | { | |
| 484 | 484 | #endif | |
@@ -511,7 +511,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result, | |||
| 511 | 511 | return true; | |
| 512 | 512 | ||
| 513 | 513 | case TypeCode.Byte: | |
| 514 | - #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 514 | + #if PYTHON3 | ||
| 515 | 515 | if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType)) | |
| 516 | 516 | { | |
| 517 | 517 | if (Runtime.PyBytes_Size(value) == 1) | |
@@ -522,7 +522,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result, | |||
| 522 | 522 | } | |
| 523 | 523 | goto type_error; | |
| 524 | 524 | } | |
| 525 | - #else | ||
| 525 | + #elif PYTHON2 | ||
| 526 | 526 | if (Runtime.PyObject_TypeCheck(value, Runtime.PyStringType)) | |
| 527 | 527 | { | |
| 528 | 528 | if (Runtime.PyString_Size(value) == 1) | |
@@ -556,7 +556,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result, | |||
| 556 | 556 | return true; | |
| 557 | 557 | ||
| 558 | 558 | case TypeCode.SByte: | |
| 559 | - #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 559 | + #if PYTHON3 | ||
| 560 | 560 | if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType)) { | |
| 561 | 561 | if (Runtime.PyBytes_Size(value) == 1) { | |
| 562 | 562 | op = Runtime.PyBytes_AS_STRING(value); | |
@@ -565,7 +565,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result, | |||
| 565 | 565 | } | |
| 566 | 566 | goto type_error; | |
| 567 | 567 | } | |
| 568 | - #else | ||
| 568 | + #elif PYTHON2 | ||
| 569 | 569 | if (Runtime.PyObject_TypeCheck(value, Runtime.PyStringType)) | |
| 570 | 570 | { | |
| 571 | 571 | if (Runtime.PyString_Size(value) == 1) | |
@@ -599,7 +599,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result, | |||
| 599 | 599 | return true; | |
| 600 | 600 | ||
| 601 | 601 | case TypeCode.Char: | |
| 602 | - #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 602 | + #if PYTHON3 | ||
| 603 | 603 | if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType)) { | |
| 604 | 604 | if (Runtime.PyBytes_Size(value) == 1) { | |
| 605 | 605 | op = Runtime.PyBytes_AS_STRING(value); | |
@@ -608,7 +608,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result, | |||
| 608 | 608 | } | |
| 609 | 609 | goto type_error; | |
| 610 | 610 | } | |
| 611 | - #else | ||
| 611 | + #elif PYTHON2 | ||
| 612 | 612 | if (Runtime.PyObject_TypeCheck(value, Runtime.PyStringType)) | |
| 613 | 613 | { | |
| 614 | 614 | if (Runtime.PyString_Size(value) == 1) | |
@@ -935,4 +935,4 @@ public static PyObject ToPython(this object o) | |||
| 935 | 935 | return new PyObject(Converter.ToPython(o, o?.GetType())); | |
| 936 | 936 | } | |
| 937 | 937 | } | |
| 938 | - } | ||
| 938 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -102,7 +102,7 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw) | |||
| 102 | 102 | //==================================================================== | |
| 103 | 103 | // Implements __cmp__ for reflected delegate types. | |
| 104 | 104 | //==================================================================== | |
| 105 | - #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 105 | + #if PYTHON3 | ||
| 106 | 106 | public static new IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op) { | |
| 107 | 107 | if (op != Runtime.Py_EQ && op != Runtime.Py_NE) | |
| 108 | 108 | { | |
@@ -131,7 +131,7 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw) | |||
| 131 | 131 | Runtime.XIncref(pyfalse); | |
| 132 | 132 | return pyfalse; | |
| 133 | 133 | } | |
| 134 | - #else | ||
| 134 | + #elif PYTHON2 | ||
| 135 | 135 | public static new int tp_compare(IntPtr ob, IntPtr other) | |
| 136 | 136 | { | |
| 137 | 137 | Delegate d1 = GetTrueDelegate(ob); | |
@@ -144,4 +144,4 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw) | |||
| 144 | 144 | } | |
| 145 | 145 | #endif | |
| 146 | 146 | } | |
| 147 | - } | ||
| 147 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -84,9 +84,9 @@ private Exceptions() | |||
| 84 | 84 | ||
| 85 | 85 | internal static void Initialize() | |
| 86 | 86 | { | |
| 87 | - #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 87 | + #if PYTHON3 | ||
| 88 | 88 | exceptions_module = Runtime.PyImport_ImportModule("builtins"); | |
| 89 | - #else | ||
| 89 | + #elif PYTHON2 | ||
| 90 | 90 | exceptions_module = Runtime.PyImport_ImportModule("exceptions"); | |
| 91 | 91 | #endif | |
| 92 | 92 | Exceptions.ErrorCheck(exceptions_module); | |
@@ -164,7 +164,7 @@ internal static void SetArgsAndCause(IntPtr ob) | |||
| 164 | 164 | ||
| 165 | 165 | Marshal.WriteIntPtr(ob, ExceptionOffset.args, args); | |
| 166 | 166 | ||
| 167 | - #if !(PYTHON25 || PYTHON26 || PYTHON27) | ||
| 167 | + #if PYTHON3 | ||
| 168 | 168 | if (e.InnerException != null) | |
| 169 | 169 | { | |
| 170 | 170 | IntPtr cause = CLRObject.GetInstHandle(e.InnerException); | |
@@ -375,7 +375,7 @@ puplic static variables on the Exceptions class filled in from | |||
| 375 | 375 | public static IntPtr Exception; | |
| 376 | 376 | public static IntPtr StopIteration; | |
| 377 | 377 | public static IntPtr GeneratorExit; | |
| 378 | - #if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 378 | + #if PYTHON2 | ||
| 379 | 379 | public static IntPtr StandardError; | |
| 380 | 380 | #endif | |
| 381 | 381 | public static IntPtr ArithmeticError; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -154,15 +154,13 @@ public static int Size() | |||
| 154 | 154 | // (start after PyObject_HEAD) | |
| 155 | 155 | public static int dict = 0; | |
| 156 | 156 | public static int args = 0; | |
| 157 | - #if (PYTHON25 || PYTHON26 || PYTHON27) | ||
| 157 | + #if PYTHON2 | ||
| 158 | 158 | public static int message = 0; | |
| 159 | - #elif (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 159 | + #elif PYTHON3 | ||
| 160 | 160 | public static int traceback = 0; | |
| 161 | 161 | public static int context = 0; | |
| 162 | 162 | public static int cause = 0; | |
| 163 | - #if !PYTHON32 | ||
| 164 | 163 | public static int suppress_context = 0; | |
| 165 | - #endif | ||
| 166 | 164 | #endif | |
| 167 | 165 | ||
| 168 | 166 | // extra c# data | |
@@ -171,7 +169,7 @@ public static int Size() | |||
| 171 | 169 | } | |
| 172 | 170 | ||
| 173 | 171 | ||
| 174 | - #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 172 | + #if PYTHON3 | ||
| 175 | 173 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] | |
| 176 | 174 | internal class BytesOffset | |
| 177 | 175 | { | |
@@ -270,7 +268,7 @@ public static void FreeModuleDef(IntPtr ptr) { | |||
| 270 | 268 | /// </summary> | |
| 271 | 269 | internal class TypeFlags | |
| 272 | 270 | { | |
| 273 | - #if (PYTHON23 || PYTHON24 || PYTHON25 || PYTHON26 || PYTHON27) | ||
| 271 | + #if PYTHON2 | ||
| 274 | 272 | // these flags were removed in Python 3 | |
| 275 | 273 | public static int HaveGetCharBuffer = (1 << 0); | |
| 276 | 274 | public static int HaveSequenceIn = (1 << 1); | |
@@ -309,8 +307,8 @@ internal class TypeFlags | |||
| 309 | 307 | public static int BaseExceptionSubclass = (1 << 30); | |
| 310 | 308 | public static int TypeSubclass = (1 << 31); | |
| 311 | 309 | ||
| 312 | - // Default flags for Python 2 | ||
| 313 | - #if (PYTHON23 || PYTHON24 || PYTHON25 || PYTHON26 || PYTHON27) | ||
| 310 | + #if PYTHON2 | ||
| 311 | + // Default flags for Python 2 | ||
| 314 | 312 | public static int Default = ( | |
| 315 | 313 | HaveGetCharBuffer | | |
| 316 | 314 | HaveSequenceIn | | |
@@ -320,14 +318,10 @@ internal class TypeFlags | |||
| 320 | 318 | HaveIter | | |
| 321 | 319 | HaveClass | | |
| 322 | 320 | HaveStacklessExtension | | |
| 323 | - #if (PYTHON25 || PYTHON26 || PYTHON27) | ||
| 324 | 321 | HaveIndex | | |
| 325 | - #endif | ||
| 326 | 322 | 0); | |
| 327 | - #endif | ||
| 328 | - | ||
| 329 | - // Default flags for Python 3 | ||
| 330 | - #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 323 | + #elif PYTHON3 | ||
| 324 | + // Default flags for Python 3 | ||
| 331 | 325 | public static int Default = ( | |
| 332 | 326 | HaveStacklessExtension | | |
| 333 | 327 | HaveVersionTag); | |
@@ -390,7 +384,7 @@ static Interop() | |||
| 390 | 384 | pmap["nb_add"] = p["BinaryFunc"]; | |
| 391 | 385 | pmap["nb_subtract"] = p["BinaryFunc"]; | |
| 392 | 386 | pmap["nb_multiply"] = p["BinaryFunc"]; | |
| 393 | - #if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 387 | + #if PYTHON2 | ||
| 394 | 388 | pmap["nb_divide"] = p["BinaryFunc"]; | |
| 395 | 389 | #endif | |
| 396 | 390 | pmap["nb_remainder"] = p["BinaryFunc"]; | |
@@ -415,7 +409,7 @@ static Interop() | |||
| 415 | 409 | pmap["nb_inplace_add"] = p["BinaryFunc"]; | |
| 416 | 410 | pmap["nb_inplace_subtract"] = p["BinaryFunc"]; | |
| 417 | 411 | pmap["nb_inplace_multiply"] = p["BinaryFunc"]; | |
| 418 | - #if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 412 | + #if PYTHON2 | ||
| 419 | 413 | pmap["nb_inplace_divide"] = p["BinaryFunc"]; | |
| 420 | 414 | #endif | |
| 421 | 415 | pmap["nb_inplace_remainder"] = p["BinaryFunc"]; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -186,9 +186,9 @@ public static void Initialize() | |||
| 186 | 186 | // CPython interpreter process - this bootstraps the managed runtime | |
| 187 | 187 | // when it is imported by the CLR extension module. | |
| 188 | 188 | //==================================================================== | |
| 189 | - #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 189 | + #if PYTHON3 | ||
| 190 | 190 | public static IntPtr InitExt() { | |
| 191 | - #else | ||
| 191 | + #elif PYTHON2 | ||
| 192 | 192 | public static void InitExt() | |
| 193 | 193 | { | |
| 194 | 194 | #endif | |
@@ -234,12 +234,12 @@ public static void InitExt() | |||
| 234 | 234 | catch (PythonException e) | |
| 235 | 235 | { | |
| 236 | 236 | e.Restore(); | |
| 237 | - #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 237 | + #if PYTHON3 | ||
| 238 | 238 | return IntPtr.Zero; | |
| 239 | 239 | #endif | |
| 240 | 240 | } | |
| 241 | 241 | ||
| 242 | - #if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36) | ||
| 242 | + #if PYTHON3 | ||
| 243 | 243 | return Python.Runtime.ImportHook.GetCLRModule(); | |
| 244 | 244 | #endif | |
| 245 | 245 | } | |
@@ -501,4 +501,4 @@ public static PyObject Import(string name) | |||
| 501 | 501 | return PythonEngine.ImportModule(name); | |
| 502 | 502 | } | |
| 503 | 503 | } | |
| 504 | - } | ||
| 504 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments