From e79349d8868b0ad93b7317437f0eb8f95825aa6e Mon Sep 17 00:00:00 2001 From: Alec Cooper Date: Tue, 27 Oct 2015 20:12:03 -0400 Subject: [PATCH 1/7] Adding tp_finalize field to PyTypeObject for Python version 3.4 and up --- Lib/python/builtin.swg | 3 +++ Lib/python/pyinit.swg | 3 +++ Lib/python/pyrun.swg | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 1d892375c..340037580 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -435,6 +435,9 @@ SwigPyStaticVar_Type(void) { #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index e71c72b27..26c1d7ed3 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -185,6 +185,9 @@ swig_varlink_type(void) { #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 5eedca483..47ac80492 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -806,6 +806,9 @@ SwigPyObject_TypeOnce(void) { #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif @@ -985,6 +988,9 @@ SwigPyPacked_TypeOnce(void) { #if PY_VERSION_HEX >= 0x02060000 0, /* tp_version */ #endif +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif #ifdef COUNT_ALLOCS 0,0,0,0 /* tp_alloc -> tp_next */ #endif From b7a351680185c8a594c8ff0e720f62f229a81a6c Mon Sep 17 00:00:00 2001 From: Alec Cooper Date: Wed, 28 Oct 2015 16:42:53 -0400 Subject: [PATCH 2/7] Adding nb_matrix_multiply and nb_inplace_matrix_multiply fields to PyNumberMethods for Python version 3.5 and up --- Lib/python/pyrun.swg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 47ac80492..be3af3280 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -724,7 +724,9 @@ SwigPyObject_TypeOnce(void) { (unaryfunc)SwigPyObject_oct, /*nb_oct*/ (unaryfunc)SwigPyObject_hex, /*nb_hex*/ #endif -#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ +#if PY_VERSION_HEX >= 0x03050000 /* 3.5 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ +#elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ #elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ From 5724195b8b42f89a7c615f025165dea4736890e2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 12 Dec 2015 21:41:33 +0000 Subject: [PATCH 3/7] Adding tp_finalize field to PyTypeObject for Python 3.4 and -builtin --- Source/Modules/python.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 3395ebe68..98302d2d8 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4050,6 +4050,9 @@ public: Printv(f, "#if PY_VERSION_HEX >= 0x02060000\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_version_tag"), "tp_version_tag", "int"); Printv(f, "#endif\n", NIL); + Printv(f, "#if PY_VERSION_HEX >= 0x03040000\n", NIL); + printSlot(f, getSlot(n, "feature:python:tp_finalize"), "tp_finalize", "destructor"); + Printv(f, "#endif\n", NIL); Printf(f, " },\n"); // PyAsyncMethods as_async From f7b9466dff0bc7904e4ab7ac6f9ea46908f5e5cd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 13 Dec 2015 14:13:32 +0000 Subject: [PATCH 4/7] Python 3.3 builtin missing field initializers added Add in ht_qualname and ht_cached_keys for Python 3.3 and later --- Source/Modules/python.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 98302d2d8..75d8ffafa 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4164,9 +4164,15 @@ public: Printv(f, "#endif\n", NIL); Printf(f, " },\n"); - // PyObject *ht_name, *ht_slots + // PyObject *ht_name, *ht_slots, *ht_qualname; printSlot(f, getSlot(n, "feature:python:ht_name"), "ht_name", "PyObject*"); printSlot(f, getSlot(n, "feature:python:ht_slots"), "ht_slots", "PyObject*"); + Printv(f, "#if PY_VERSION_HEX >= 0x03030000\n", NIL); + printSlot(f, getSlot(n, "feature:python:ht_qualname"), "ht_qualname", "PyObject*"); + + // struct _dictkeysobject *ht_cached_keys; + printSlot(f, getSlot(n, "feature:python:ht_cached_keys"), "ht_cached_keys", "struct _dictkeysobject*"); + Printv(f, "#endif\n", NIL); Printf(f, "};\n\n"); String *clientdata = NewString(""); From fcb2ed1d1065429c692a28bb2ee873821444cd56 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 13 Dec 2015 14:18:03 +0000 Subject: [PATCH 5/7] Add -Wmissing-field-initializers to python Travis testing --- Tools/testflags.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/testflags.py b/Tools/testflags.py index 76389f046..63a3b4645 100755 --- a/Tools/testflags.py +++ b/Tools/testflags.py @@ -15,7 +15,7 @@ def get_cflags(language, std, compiler): "octave":"-Werror " + c_common, "perl5":"-Werror " + c_common, "php":"-Werror " + c_common, - "python":"-Werror " + c_common, + "python":"-Werror " + c_common + " -Wmissing-field-initializers", "r":"-Werror " + c_common, "ruby":"-Werror " + c_common, "scilab":"-Werror " + c_common, @@ -44,7 +44,7 @@ def get_cxxflags(language, std, compiler): "octave":"-Werror " + cxx_common, "perl5":"-Werror " + cxx_common, "php":"-Werror " + cxx_common, - "python":"-Werror " + cxx_common, + "python":"-Werror " + cxx_common + " -Wmissing-field-initializers", "r":"-Werror " + cxx_common, "ruby":"-Werror " + cxx_common, "scilab": cxx_common, From 24b4a0fb945885c009923ca029fc5542570132ac Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 Dec 2015 01:29:43 +0000 Subject: [PATCH 6/7] Cosmetic correction for Python tp_version -> tp_version_tag --- Lib/python/builtin.swg | 2 +- Lib/python/pyinit.swg | 2 +- Lib/python/pyrun.swg | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 340037580..4604e4397 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -433,7 +433,7 @@ SwigPyStaticVar_Type(void) { 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version */ + 0, /* tp_version_tag */ #endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 26c1d7ed3..9398443e3 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -183,7 +183,7 @@ swig_varlink_type(void) { 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version */ + 0, /* tp_version_tag */ #endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index be3af3280..f13154794 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -806,7 +806,7 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version */ + 0, /* tp_version_tag */ #endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ @@ -988,7 +988,7 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version */ + 0, /* tp_version_tag */ #endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ From 5f93c94e879f636867733aaff1a209c6535e4583 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 Dec 2015 01:56:11 +0000 Subject: [PATCH 7/7] Python tp_allocs -> tp_next corrections Updates for Python 2.5 and later and for -builtin. --- Lib/python/builtin.swg | 8 +++++++- Lib/python/pyinit.swg | 8 +++++++- Lib/python/pyrun.swg | 16 ++++++++++++++-- Source/Modules/python.cxx | 9 +++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 4604e4397..0107c52d5 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -439,7 +439,13 @@ SwigPyStaticVar_Type(void) { 0, /* tp_finalize */ #endif #ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 + 0, /* tp_prev */ +#endif + 0 /* tp_next */ #endif }; staticvar_type = tmp; diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 9398443e3..2e21b8265 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -189,7 +189,13 @@ swig_varlink_type(void) { 0, /* tp_finalize */ #endif #ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 + 0, /* tp_prev */ +#endif + 0 /* tp_next */ #endif }; varlink_type = tmp; diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index f13154794..1326ed775 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -812,7 +812,13 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_finalize */ #endif #ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 + 0, /* tp_prev */ +#endif + 0 /* tp_next */ #endif }; swigpyobject_type = tmp; @@ -994,7 +1000,13 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_finalize */ #endif #ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 + 0, /* tp_prev */ +#endif + 0 /* tp_next */ #endif }; swigpypacked_type = tmp; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 75d8ffafa..eff263be6 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4053,6 +4053,15 @@ public: Printv(f, "#if PY_VERSION_HEX >= 0x03040000\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_finalize"), "tp_finalize", "destructor"); Printv(f, "#endif\n", NIL); + Printv(f, "#ifdef COUNT_ALLOCS\n", NIL); + printSlot(f, getSlot(), "tp_allocs", "Py_ssize_t"); + printSlot(f, getSlot(), "tp_frees", "Py_ssize_t"); + printSlot(f, getSlot(), "tp_maxalloc", "Py_ssize_t"); + Printv(f, "#if PY_VERSION_HEX >= 0x02050000\n", NIL); + printSlot(f, getSlot(), "tp_prev", "struct _typeobject*"); + Printv(f, "#endif\n", NIL); + printSlot(f, getSlot(), "tp_next", "struct _typeobject*"); + Printv(f, "#endif\n", NIL); Printf(f, " },\n"); // PyAsyncMethods as_async