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

Skip to content

Commit 573f903

Browse files
cgohlkefilmor
authored andcommitted
Support Python 3.6 (#310)
* Support PYTHON36 define * Add interop36.cs generated by clang * Add Python 3.6 to Appveyor build * Add Python 3.6 to Travis build [skip appveyor] * Add Python 3.6 to Trove classifiers
1 parent 9c060a3 commit 573f903

14 files changed

+223
-57
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ python:
55
- 3.2
66
- 3.4
77
- 3.5
8+
- 3.6
89
before_install:
910
- sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ trusty main universe"
1011
- sudo apt-get install software-properties-common

appveyor.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ environment:
5757
CONDA_BLD: "C:\\miniconda-64"
5858
CONDA_BLD_ARCH: "64"
5959

60+
- PYTHON: "C:\\Python36"
61+
CONDA_PY: "36"
62+
CONDA_BLD: "C:\\miniconda-32"
63+
CONDA_BLD_ARCH: "32"
64+
65+
- PYTHON: "C:\\Python36-x64"
66+
CONDA_PY: "36"
67+
CONDA_BLD: "C:\\miniconda-64"
68+
CONDA_BLD_ARCH: "64"
69+
6070
install:
6171
# install conda and deps
6272
- powershell .\ci\install.ps1

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ def _get_interop_filename():
343343
'Programming Language :: Python :: 3.3',
344344
'Programming Language :: Python :: 3.4',
345345
'Programming Language :: Python :: 3.5',
346+
'Programming Language :: Python :: 3.6',
346347
'Programming Language :: C#',
347348
'License :: OSI Approved :: Zope Public License',
348349
'Development Status :: 5 - Production/Stable',

src/clrmodule/ClrModule.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
public class clrModule
2828
{
29-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
29+
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
3030
[RGiesecke.DllExport.DllExport("PyInit_clr", System.Runtime.InteropServices.CallingConvention.StdCall)]
3131
public static IntPtr PyInit_clr()
3232
#else
@@ -94,7 +94,7 @@ public static void initclr()
9494
#if DEBUG_PRINT
9595
System.Console.WriteLine("Could not load Python.Runtime, so sad.");
9696
#endif
97-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
97+
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
9898
return IntPtr.Zero;
9999
#else
100100
return;
@@ -106,7 +106,7 @@ public static void initclr()
106106
// So now we get the PythonEngine and execute the InitExt method on it.
107107
var pythonEngineType = pythonRuntime.GetType("Python.Runtime.PythonEngine");
108108

109-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
109+
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
110110
return (IntPtr)pythonEngineType.InvokeMember("InitExt", System.Reflection.BindingFlags.InvokeMethod, null, null, null);
111111
#else
112112
pythonEngineType.InvokeMember("InitExt", System.Reflection.BindingFlags.InvokeMethod, null, null, null);

src/runtime/converter.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ internal static IntPtr GetPythonTypeByAlias(Type op)
8484
{
8585
return Runtime.PyUnicodeType;
8686
}
87-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
87+
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
8888
else if ((op == int16Type) ||
8989
(op == int32Type) ||
9090
(op == int64Type)) {
@@ -450,7 +450,7 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
450450
return true;
451451

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

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

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

601601
case TypeCode.Char:
602-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
602+
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
603603
if (Runtime.PyObject_TypeCheck(value, Runtime.PyBytesType)) {
604604
if (Runtime.PyBytes_Size(value) == 1) {
605605
op = Runtime.PyBytes_AS_STRING(value);

src/runtime/delegateobject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw)
102102
//====================================================================
103103
// Implements __cmp__ for reflected delegate types.
104104
//====================================================================
105-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
105+
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
106106
public static new IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op) {
107107
if (op != Runtime.Py_EQ && op != Runtime.Py_NE)
108108
{

src/runtime/exceptions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private Exceptions()
8484

8585
internal static void Initialize()
8686
{
87-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
87+
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
8888
exceptions_module = Runtime.PyImport_ImportModule("builtins");
8989
#else
9090
exceptions_module = Runtime.PyImport_ImportModule("exceptions");
@@ -371,15 +371,15 @@ internal static IntPtr RaiseTypeError(string message)
371371
puplic static variables on the Exceptions class filled in from
372372
the python class using reflection in Initialize() looked up by
373373
name, not posistion. */
374-
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
374+
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
375375
public static IntPtr BaseException;
376376
#endif
377377
public static IntPtr Exception;
378378
public static IntPtr StopIteration;
379-
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
379+
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
380380
public static IntPtr GeneratorExit;
381381
#endif
382-
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
382+
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
383383
public static IntPtr StandardError;
384384
#endif
385385
public static IntPtr ArithmeticError;
@@ -436,7 +436,7 @@ puplic static variables on the Exceptions class filled in from
436436
public static IntPtr SyntaxWarning;
437437
public static IntPtr RuntimeWarning;
438438
public static IntPtr FutureWarning;
439-
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
439+
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
440440
public static IntPtr ImportWarning;
441441
public static IntPtr UnicodeWarning;
442442
//PyAPI_DATA(PyObject *) PyExc_BytesWarning;

src/runtime/importhook.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal class ImportHook
1414
static CLRModule root;
1515
static MethodWrapper hook;
1616

17-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
17+
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
1818
static IntPtr py_clr_module;
1919
static IntPtr module_def;
2020
#endif
@@ -30,7 +30,7 @@ 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)
33+
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
3434
IntPtr mod = Runtime.PyImport_ImportModule("builtins");
3535
py_import = Runtime.PyObject_GetAttrString(mod, "__import__");
3636
#else
@@ -43,7 +43,7 @@ internal static void Initialize()
4343

4444
root = new CLRModule();
4545

46-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
46+
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
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);
@@ -70,7 +70,7 @@ internal static void Initialize()
7070

7171
internal static void Shutdown()
7272
{
73-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
73+
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
7474
if (0 != Runtime.Py_IsInitialized()) {
7575
Runtime.XDecref(py_clr_module);
7676
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)
98+
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
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);

src/runtime/interop.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public static int Size()
156156
public static int args = 0;
157157
#if (PYTHON25 || PYTHON26 || PYTHON27)
158158
public static int message = 0;
159-
#elif (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
159+
#elif (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
160160
public static int traceback = 0;
161161
public static int context = 0;
162162
public static int cause = 0;
@@ -171,7 +171,7 @@ public static int Size()
171171
}
172172

173173

174-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
174+
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
175175
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
176176
internal class BytesOffset
177177
{
@@ -292,10 +292,10 @@ internal class TypeFlags
292292
/* XXX Reusing reserved constants */
293293
public static int Managed = (1 << 15); // PythonNet specific
294294
public static int Subclass = (1 << 16); // PythonNet specific
295-
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
295+
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
296296
public static int HaveIndex = (1 << 17);
297297
#endif
298-
#if (PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
298+
#if (PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
299299
/* Objects support nb_index in PyNumberMethods */
300300
public static int HaveVersionTag = (1 << 18);
301301
public static int ValidVersionTag = (1 << 19);
@@ -331,7 +331,7 @@ internal class TypeFlags
331331
#endif
332332

333333
// Default flags for Python 3
334-
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
334+
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
335335
public static int Default = (
336336
HaveStacklessExtension |
337337
HaveVersionTag);
@@ -394,7 +394,7 @@ static Interop()
394394
pmap["nb_add"] = p["BinaryFunc"];
395395
pmap["nb_subtract"] = p["BinaryFunc"];
396396
pmap["nb_multiply"] = p["BinaryFunc"];
397-
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
397+
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
398398
pmap["nb_divide"] = p["BinaryFunc"];
399399
#endif
400400
pmap["nb_remainder"] = p["BinaryFunc"];
@@ -419,7 +419,7 @@ static Interop()
419419
pmap["nb_inplace_add"] = p["BinaryFunc"];
420420
pmap["nb_inplace_subtract"] = p["BinaryFunc"];
421421
pmap["nb_inplace_multiply"] = p["BinaryFunc"];
422-
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
422+
#if !(PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
423423
pmap["nb_inplace_divide"] = p["BinaryFunc"];
424424
#endif
425425
pmap["nb_inplace_remainder"] = p["BinaryFunc"];
@@ -433,7 +433,7 @@ static Interop()
433433
pmap["nb_true_divide"] = p["BinaryFunc"];
434434
pmap["nb_inplace_floor_divide"] = p["BinaryFunc"];
435435
pmap["nb_inplace_true_divide"] = p["BinaryFunc"];
436-
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
436+
#if (PYTHON25 || PYTHON26 || PYTHON27 || PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35 || PYTHON36)
437437
pmap["nb_index"] = p["UnaryFunc"];
438438
#endif
439439

src/runtime/interop35.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,4 @@ public static int magic() {
143143
public static int members = 0;
144144
}
145145
}
146-
#endif
146+
#endif

0 commit comments

Comments
 (0)