Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support Python 3.6 #310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ python:
- 3.2
- 3.4
- 3.5
- 3.6
before_install:
- sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ trusty main universe"
- sudo apt-get install software-properties-common
Expand Down
10 changes: 10 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ environment:
CONDA_BLD: "C:\\miniconda-64"
CONDA_BLD_ARCH: "64"

- PYTHON: "C:\\Python36"
CONDA_PY: "36"
CONDA_BLD: "C:\\miniconda-32"
CONDA_BLD_ARCH: "32"

- PYTHON: "C:\\Python36-x64"
CONDA_PY: "36"
CONDA_BLD: "C:\\miniconda-64"
CONDA_BLD_ARCH: "64"

install:
# install conda and deps
- powershell .\ci\install.ps1
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def _get_interop_filename():
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: C#',
'License :: OSI Approved :: Zope Public License',
'Development Status :: 5 - Production/Stable',
Expand Down
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 @@ -143,4 +143,4 @@ public static int magic() {
public static int members = 0;
}
}
#endif
#endif
Loading