Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Support PYTHON36 define
  • Loading branch information
cgohlke committed Jan 5, 2017
commit e8f71bbffee0283d5c8ab9fcb7a8cb8e1772732e
6 changes: 3 additions & 3 deletions src/clrmodule/ClrModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public class clrModule
{
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
[RGiesecke.DllExport.DllExport("PyInit_clr", System.Runtime.InteropServices.CallingConvention.StdCall)]
public static IntPtr PyInit_clr()
#else
Expand Down Expand Up @@ -94,7 +94,7 @@ public static void initclr()
#if DEBUG_PRINT
System.Console.WriteLine("Could not load Python.Runtime, so sad.");
#endif
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
return IntPtr.Zero;
#else
return;
Expand All @@ -106,7 +106,7 @@ public static void initclr()
// So now we get the PythonEngine and execute the InitExt method on it.
var pythonEngineType = pythonRuntime.GetType("Python.Runtime.PythonEngine");

#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
return (IntPtr)pythonEngineType.InvokeMember("InitExt", System.Reflection.BindingFlags.InvokeMethod, null, null, null);
#else
pythonEngineType.InvokeMember("InitExt", System.Reflection.BindingFlags.InvokeMethod, null, null, null);
Expand Down
10 changes: 5 additions & 5 deletions src/runtime/converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ internal static IntPtr GetPythonTypeByAlias(Type op)
{
return Runtime.PyUnicodeType;
}
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
else if ((op == int16Type) ||
(op == int32Type) ||
(op == int64Type)) {
Expand Down Expand Up @@ -450,7 +450,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
return true;

case TypeCode.Int32:
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
// Trickery to support 64-bit platforms.
if (IntPtr.Size == 4)
{
Expand Down Expand Up @@ -511,7 +511,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
return true;

case TypeCode.Byte:
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType))
{
if (Runtime.PyBytes_Size(value) == 1)
Expand Down Expand Up @@ -556,7 +556,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
return true;

case TypeCode.SByte:
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType)) {
if (Runtime.PyBytes_Size(value) == 1) {
op = Runtime.PyBytes_AS_STRING(value);
Expand Down Expand Up @@ -599,7 +599,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
return true;

case TypeCode.Char:
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType)) {
if (Runtime.PyBytes_Size(value) == 1) {
op = Runtime.PyBytes_AS_STRING(value);
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/delegateobject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw)
//====================================================================
// Implements __cmp__ for reflected delegate types.
//====================================================================
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
public static new IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op) {
if (op != Runtime.Py_EQ && op != Runtime.Py_NE)
{
Expand Down
10 changes: 5 additions & 5 deletions src/runtime/exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private Exceptions()

internal static void Initialize()
{
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
exceptions_module = Runtime.PyImport_ImportModule("builtins");
#else
exceptions_module = Runtime.PyImport_ImportModule("exceptions");
Expand Down Expand Up @@ -371,15 +371,15 @@ internal static IntPtr RaiseTypeError(string message)
puplic static variables on the Exceptions class filled in from
the python class using reflection in Initialize() looked up by
name, not posistion. */
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
public static IntPtr BaseException;
#endif
public static IntPtr Exception;
public static IntPtr StopIteration;
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
public static IntPtr GeneratorExit;
#endif
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
public static IntPtr StandardError;
#endif
public static IntPtr ArithmeticError;
Expand Down Expand Up @@ -436,7 +436,7 @@ puplic static variables on the Exceptions class filled in from
public static IntPtr SyntaxWarning;
public static IntPtr RuntimeWarning;
public static IntPtr FutureWarning;
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
public static IntPtr ImportWarning;
public static IntPtr UnicodeWarning;
//PyAPI_DATA(PyObject *) PyExc_BytesWarning;
Expand Down
10 changes: 5 additions & 5 deletions src/runtime/importhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class ImportHook
static CLRModule root;
static MethodWrapper hook;

#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
static IntPtr py_clr_module;
static IntPtr module_def;
#endif
Expand All @@ -30,7 +30,7 @@ internal static void Initialize()
// but it provides the most "Pythonic" way of dealing with CLR
// modules (Python doesn't provide a way to emulate packages).
IntPtr dict = Runtime.PyImport_GetModuleDict();
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
IntPtr mod = Runtime.PyImport_ImportModule("builtins");
py_import = Runtime.PyObject_GetAttrString(mod, "__import__");
#else
Expand All @@ -43,7 +43,7 @@ internal static void Initialize()

root = new CLRModule();

#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
// create a python module with the same methods as the clr module-like object
module_def = ModuleDefOffset.AllocModuleDef("clr");
py_clr_module = Runtime.PyModule_Create2(module_def, 3);
Expand All @@ -70,7 +70,7 @@ internal static void Initialize()

internal static void Shutdown()
{
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
if (0 != Runtime.Py_IsInitialized()) {
Runtime.XDecref(py_clr_module);
Runtime.XDecref(root.pyHandle);
Expand All @@ -95,7 +95,7 @@ internal static void Shutdown()
public static IntPtr GetCLRModule(IntPtr? fromList = null)
{
root.InitializePreload();
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
// update the module dictionary with the contents of the root dictionary
root.LoadNames();
IntPtr py_mod_dict = Runtime.PyModule_GetDict(py_clr_module);
Expand Down
16 changes: 8 additions & 8 deletions src/runtime/interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static int Size()
public static int args = 0;
#if (PYTHON25 || PYTHON26 || PYTHON27)
public static int message = 0;
#elif (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#elif (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
public static int traceback = 0;
public static int context = 0;
public static int cause = 0;
Expand All @@ -171,7 +171,7 @@ public static int Size()
}


#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
internal class BytesOffset
{
Expand Down Expand Up @@ -292,10 +292,10 @@ internal class TypeFlags
/* XXX Reusing reserved constants */
public static int Managed = (1 << 15); // PythonNet specific
public static int Subclass = (1 << 16); // PythonNet specific
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
public static int HaveIndex = (1 << 17);
#endif
#if (PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
/* Objects support nb_index in PyNumberMethods */
public static int HaveVersionTag = (1 << 18);
public static int ValidVersionTag = (1 << 19);
Expand Down Expand Up @@ -331,7 +331,7 @@ internal class TypeFlags
#endif

// Default flags for Python 3
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
public static int Default = (
HaveStacklessExtension |
HaveVersionTag);
Expand Down Expand Up @@ -394,7 +394,7 @@ static Interop()
pmap["nb_add"] = p["BinaryFunc"];
pmap["nb_subtract"] = p["BinaryFunc"];
pmap["nb_multiply"] = p["BinaryFunc"];
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
pmap["nb_divide"] = p["BinaryFunc"];
#endif
pmap["nb_remainder"] = p["BinaryFunc"];
Expand All @@ -419,7 +419,7 @@ static Interop()
pmap["nb_inplace_add"] = p["BinaryFunc"];
pmap["nb_inplace_subtract"] = p["BinaryFunc"];
pmap["nb_inplace_multiply"] = p["BinaryFunc"];
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
pmap["nb_inplace_divide"] = p["BinaryFunc"];
#endif
pmap["nb_inplace_remainder"] = p["BinaryFunc"];
Expand All @@ -433,7 +433,7 @@ static Interop()
pmap["nb_true_divide"] = p["BinaryFunc"];
pmap["nb_inplace_floor_divide"] = p["BinaryFunc"];
pmap["nb_inplace_true_divide"] = p["BinaryFunc"];
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
pmap["nb_index"] = p["UnaryFunc"];
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/interop35.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@



#if (PYTHON35)
#if (PYTHON35 || PYTHON36)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a leftover from trying to reuse the file for Python 3.6. It is no longer needed. I'll remove this change. Thank you.

using System;
using System.Collections;
using System.Collections.Specialized;
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/pythonengine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public static void Initialize()
// CPython interpreter process - this bootstraps the managed runtime
// when it is imported by the CLR extension module.
//====================================================================
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
public static IntPtr InitExt() {
#else
public static void InitExt()
Expand Down Expand Up @@ -234,12 +234,12 @@ public static void InitExt()
catch (PythonException e)
{
e.Restore();
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
return IntPtr.Zero;
#endif
}

#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
return Python.Runtime.ImportHook.GetCLRModule();
#endif
}
Expand Down
Loading