Skip to content

Commit df8ccdb

Browse files
committed
Add support for Python 3.8
1 parent fef72ab commit df8ccdb

File tree

6 files changed

+100
-16
lines changed

6 files changed

+100
-16
lines changed

dtool/src/interrogate/interfaceMakerPythonNative.cxx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2863,8 +2863,13 @@ write_module_class(ostream &out, Object *obj) {
28632863

28642864
// destructor tp_dealloc;
28652865
out << " &Dtool_FreeInstance_" << ClassName << ",\n";
2866-
// printfunc tp_print;
2866+
2867+
out << "#if PY_VERSION_HEX >= 0x03080000\n";
2868+
out << " 0, // tp_vectorcall_offset\n";
2869+
out << "#else\n";
28672870
write_function_slot(out, 4, slots, "tp_print");
2871+
out << "#endif\n";
2872+
28682873
// getattrfunc tp_getattr;
28692874
write_function_slot(out, 4, slots, "tp_getattr");
28702875
// setattrfunc tp_setattr;
@@ -3055,6 +3060,10 @@ write_module_class(ostream &out, Object *obj) {
30553060
out << "#if PY_VERSION_HEX >= 0x03040000\n";
30563061
out << " nullptr, // tp_finalize\n";
30573062
out << "#endif\n";
3063+
// vectorcallfunc tp_vectorcall
3064+
out << "#if PY_VERSION_HEX >= 0x03080000\n";
3065+
out << " nullptr, // tp_vectorcall\n";
3066+
out << "#endif\n";
30583067
out << " },\n";
30593068

30603069
// It's tempting to initialize the type handle here, but this causes static

dtool/src/interrogatedb/dtool_super_base.cxx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Dtool_PyTypedObject *Dtool_GetSuperBase() {
8080
sizeof(Dtool_PyInstDef),
8181
0, // tp_itemsize
8282
&Dtool_FreeInstance_DTOOL_SUPER_BASE,
83-
nullptr, // tp_print
83+
0, // tp_vectorcall_offset
8484
nullptr, // tp_getattr
8585
nullptr, // tp_setattr
8686
#if PY_MAJOR_VERSION >= 3
@@ -129,6 +129,13 @@ Dtool_PyTypedObject *Dtool_GetSuperBase() {
129129
nullptr, // tp_subclasses
130130
nullptr, // tp_weaklist
131131
nullptr, // tp_del
132+
0, // tp_version_tag,
133+
#if PY_VERSION_HEX >= 0x03040000
134+
nullptr, // tp_finalize
135+
#endif
136+
#if PY_VERSION_HEX >= 0x03080000
137+
nullptr, // tp_vectorcall
138+
#endif
132139
},
133140
TypeHandle::none(),
134141
Dtool_PyModuleClassInit_DTOOL_SUPER_BASE,

dtool/src/interrogatedb/py_compat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ typedef long Py_hash_t;
139139

140140
/* Python 3.6 */
141141

142-
#ifndef _PyObject_CallNoArg
142+
#if PY_VERSION_HEX < 0x03080000 && !defined(_PyObject_CallNoArg)
143143
INLINE PyObject *_PyObject_CallNoArg(PyObject *func) {
144144
static PyTupleObject empty_tuple = {PyVarObject_HEAD_INIT(nullptr, 0)};
145145
#ifdef Py_TRACE_REFS

dtool/src/interrogatedb/py_wrappers.cxx

Lines changed: 73 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ static PyObject *Dtool_MappingWrapper_keys(PyObject *self, PyObject *) {
541541
sizeof(Dtool_SequenceWrapper),
542542
0, // tp_itemsize
543543
Dtool_WrapperBase_dealloc,
544-
nullptr, // tp_print
544+
0, // tp_vectorcall_offset
545545
nullptr, // tp_getattr
546546
nullptr, // tp_setattr
547547
nullptr, // tp_compare
@@ -582,6 +582,13 @@ static PyObject *Dtool_MappingWrapper_keys(PyObject *self, PyObject *) {
582582
nullptr, // tp_subclasses
583583
nullptr, // tp_weaklist
584584
nullptr, // tp_del
585+
0, // tp_version_tag,
586+
#if PY_VERSION_HEX >= 0x03040000
587+
nullptr, // tp_finalize
588+
#endif
589+
#if PY_VERSION_HEX >= 0x03080000
590+
nullptr, // tp_vectorcall
591+
#endif
585592
};
586593

587594
static bool registered = false;
@@ -675,7 +682,7 @@ static PyObject *Dtool_MappingWrapper_values(PyObject *self, PyObject *) {
675682
sizeof(Dtool_MappingWrapper),
676683
0, // tp_itemsize
677684
Dtool_WrapperBase_dealloc,
678-
nullptr, // tp_print
685+
0, // tp_vectorcall_offset
679686
nullptr, // tp_getattr
680687
nullptr, // tp_setattr
681688
nullptr, // tp_compare
@@ -716,6 +723,13 @@ static PyObject *Dtool_MappingWrapper_values(PyObject *self, PyObject *) {
716723
nullptr, // tp_subclasses
717724
nullptr, // tp_weaklist
718725
nullptr, // tp_del
726+
0, // tp_version_tag,
727+
#if PY_VERSION_HEX >= 0x03040000
728+
nullptr, // tp_finalize
729+
#endif
730+
#if PY_VERSION_HEX >= 0x03080000
731+
nullptr, // tp_vectorcall
732+
#endif
719733
};
720734

721735
static bool registered = false;
@@ -817,7 +831,7 @@ static PyObject *Dtool_MappingWrapper_items(PyObject *self, PyObject *) {
817831
sizeof(Dtool_MappingWrapper),
818832
0, // tp_itemsize
819833
Dtool_WrapperBase_dealloc,
820-
nullptr, // tp_print
834+
0, // tp_vectorcall_offset
821835
nullptr, // tp_getattr
822836
nullptr, // tp_setattr
823837
nullptr, // tp_compare
@@ -858,6 +872,13 @@ static PyObject *Dtool_MappingWrapper_items(PyObject *self, PyObject *) {
858872
nullptr, // tp_subclasses
859873
nullptr, // tp_weaklist
860874
nullptr, // tp_del
875+
0, // tp_version_tag,
876+
#if PY_VERSION_HEX >= 0x03040000
877+
nullptr, // tp_finalize
878+
#endif
879+
#if PY_VERSION_HEX >= 0x03080000
880+
nullptr, // tp_vectorcall
881+
#endif
861882
};
862883

863884
static bool registered = false;
@@ -1192,7 +1213,7 @@ Dtool_SequenceWrapper *Dtool_NewSequenceWrapper(PyObject *self, const char *name
11921213
sizeof(Dtool_SequenceWrapper),
11931214
0, // tp_itemsize
11941215
Dtool_WrapperBase_dealloc,
1195-
nullptr, // tp_print
1216+
0, // tp_vectorcall_offset
11961217
nullptr, // tp_getattr
11971218
nullptr, // tp_setattr
11981219
nullptr, // tp_compare
@@ -1233,6 +1254,13 @@ Dtool_SequenceWrapper *Dtool_NewSequenceWrapper(PyObject *self, const char *name
12331254
nullptr, // tp_subclasses
12341255
nullptr, // tp_weaklist
12351256
nullptr, // tp_del
1257+
0, // tp_version_tag,
1258+
#if PY_VERSION_HEX >= 0x03040000
1259+
nullptr, // tp_finalize
1260+
#endif
1261+
#if PY_VERSION_HEX >= 0x03080000
1262+
nullptr, // tp_vectorcall
1263+
#endif
12361264
};
12371265

12381266
static bool registered = false;
@@ -1296,7 +1324,7 @@ Dtool_MutableSequenceWrapper *Dtool_NewMutableSequenceWrapper(PyObject *self, co
12961324
sizeof(Dtool_MutableSequenceWrapper),
12971325
0, // tp_itemsize
12981326
Dtool_WrapperBase_dealloc,
1299-
nullptr, // tp_print
1327+
0, // tp_vectorcall_offset
13001328
nullptr, // tp_getattr
13011329
nullptr, // tp_setattr
13021330
nullptr, // tp_compare
@@ -1337,6 +1365,13 @@ Dtool_MutableSequenceWrapper *Dtool_NewMutableSequenceWrapper(PyObject *self, co
13371365
nullptr, // tp_subclasses
13381366
nullptr, // tp_weaklist
13391367
nullptr, // tp_del
1368+
0, // tp_version_tag,
1369+
#if PY_VERSION_HEX >= 0x03040000
1370+
nullptr, // tp_finalize
1371+
#endif
1372+
#if PY_VERSION_HEX >= 0x03080000
1373+
nullptr, // tp_vectorcall
1374+
#endif
13401375
};
13411376

13421377
static bool registered = false;
@@ -1404,7 +1439,7 @@ Dtool_MappingWrapper *Dtool_NewMappingWrapper(PyObject *self, const char *name)
14041439
sizeof(Dtool_MappingWrapper),
14051440
0, // tp_itemsize
14061441
Dtool_WrapperBase_dealloc,
1407-
nullptr, // tp_print
1442+
0, // tp_vectorcall_offset
14081443
nullptr, // tp_getattr
14091444
nullptr, // tp_setattr
14101445
nullptr, // tp_compare
@@ -1445,6 +1480,13 @@ Dtool_MappingWrapper *Dtool_NewMappingWrapper(PyObject *self, const char *name)
14451480
nullptr, // tp_subclasses
14461481
nullptr, // tp_weaklist
14471482
nullptr, // tp_del
1483+
0, // tp_version_tag,
1484+
#if PY_VERSION_HEX >= 0x03040000
1485+
nullptr, // tp_finalize
1486+
#endif
1487+
#if PY_VERSION_HEX >= 0x03080000
1488+
nullptr, // tp_vectorcall
1489+
#endif
14481490
};
14491491

14501492
static bool registered = false;
@@ -1517,7 +1559,7 @@ Dtool_MappingWrapper *Dtool_NewMutableMappingWrapper(PyObject *self, const char
15171559
sizeof(Dtool_MappingWrapper),
15181560
0, // tp_itemsize
15191561
Dtool_WrapperBase_dealloc,
1520-
nullptr, // tp_print
1562+
0, // tp_vectorcall_offset
15211563
nullptr, // tp_getattr
15221564
nullptr, // tp_setattr
15231565
nullptr, // tp_compare
@@ -1558,6 +1600,13 @@ Dtool_MappingWrapper *Dtool_NewMutableMappingWrapper(PyObject *self, const char
15581600
nullptr, // tp_subclasses
15591601
nullptr, // tp_weaklist
15601602
nullptr, // tp_del
1603+
0, // tp_version_tag,
1604+
#if PY_VERSION_HEX >= 0x03040000
1605+
nullptr, // tp_finalize
1606+
#endif
1607+
#if PY_VERSION_HEX >= 0x03080000
1608+
nullptr, // tp_vectorcall
1609+
#endif
15611610
};
15621611

15631612
static bool registered = false;
@@ -1594,7 +1643,7 @@ Dtool_NewGenerator(PyObject *self, iternextfunc gen_next) {
15941643
sizeof(Dtool_GeneratorWrapper),
15951644
0, // tp_itemsize
15961645
Dtool_WrapperBase_dealloc,
1597-
nullptr, // tp_print
1646+
0, // tp_vectorcall_offset
15981647
nullptr, // tp_getattr
15991648
nullptr, // tp_setattr
16001649
nullptr, // tp_compare
@@ -1635,6 +1684,13 @@ Dtool_NewGenerator(PyObject *self, iternextfunc gen_next) {
16351684
nullptr, // tp_subclasses
16361685
nullptr, // tp_weaklist
16371686
nullptr, // tp_del
1687+
0, // tp_version_tag,
1688+
#if PY_VERSION_HEX >= 0x03040000
1689+
nullptr, // tp_finalize
1690+
#endif
1691+
#if PY_VERSION_HEX >= 0x03080000
1692+
nullptr, // tp_vectorcall
1693+
#endif
16381694
};
16391695

16401696
if (PyType_Ready(&wrapper_type) < 0) {
@@ -1663,7 +1719,7 @@ Dtool_NewStaticProperty(PyTypeObject *type, const PyGetSetDef *getset) {
16631719
sizeof(PyGetSetDescrObject),
16641720
0, // tp_itemsize
16651721
(destructor)Dtool_StaticProperty_dealloc,
1666-
nullptr, // tp_print
1722+
0, // tp_vectorcall_offset
16671723
nullptr, // tp_getattr
16681724
nullptr, // tp_setattr
16691725
nullptr, // tp_reserved
@@ -1696,14 +1752,21 @@ Dtool_NewStaticProperty(PyTypeObject *type, const PyGetSetDef *getset) {
16961752
nullptr, // tp_init
16971753
nullptr, // tp_alloc
16981754
nullptr, // tp_new
1699-
nullptr, // tp_del
1755+
nullptr, // tp_free
17001756
nullptr, // tp_is_gc
17011757
nullptr, // tp_bases
17021758
nullptr, // tp_mro
17031759
nullptr, // tp_cache
17041760
nullptr, // tp_subclasses
17051761
nullptr, // tp_weaklist
17061762
nullptr, // tp_del
1763+
0, // tp_version_tag,
1764+
#if PY_VERSION_HEX >= 0x03040000
1765+
nullptr, // tp_finalize
1766+
#endif
1767+
#if PY_VERSION_HEX >= 0x03080000
1768+
nullptr, // tp_vectorcall
1769+
#endif
17071770
};
17081771

17091772
if (PyType_Ready(&wrapper_type) < 0) {

makepanda/makepanda.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2918,7 +2918,9 @@ def CreatePandaVersionFiles():
29182918
29192919
bindir = os.path.join(os.path.dirname(__file__), '..', 'bin')
29202920
if os.path.isdir(bindir):
2921-
if not os.environ.get('PATH'):
2921+
if hasattr(os, 'add_dll_directory'):
2922+
os.add_dll_directory(bindir)
2923+
elif not os.environ.get('PATH'):
29222924
os.environ['PATH'] = bindir
29232925
else:
29242926
os.environ['PATH'] = bindir + os.pathsep + os.environ['PATH']

makepanda/makewheel.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,18 @@ def get_python_ext_module_dir():
168168
PANDA3D_TOOLS_INIT = """import os, sys
169169
import panda3d
170170
171+
dir = os.path.dirname(panda3d.__file__)
172+
del panda3d
173+
171174
if sys.platform in ('win32', 'cygwin'):
172175
path_var = 'PATH'
176+
if hasattr(os, 'add_dll_directory'):
177+
os.add_dll_directory(dir)
173178
elif sys.platform == 'darwin':
174179
path_var = 'DYLD_LIBRARY_PATH'
175180
else:
176181
path_var = 'LD_LIBRARY_PATH'
177182
178-
dir = os.path.dirname(panda3d.__file__)
179-
del panda3d
180183
if not os.environ.get(path_var):
181184
os.environ[path_var] = dir
182185
else:

0 commit comments

Comments
 (0)