Add support for Python 3.8

This commit is contained in:
rdb 2019-08-13 17:48:32 +02:00
parent fef72ab2a5
commit df8ccdb7ab
6 changed files with 100 additions and 16 deletions

View File

@ -2863,8 +2863,13 @@ write_module_class(ostream &out, Object *obj) {
// destructor tp_dealloc;
out << " &Dtool_FreeInstance_" << ClassName << ",\n";
// printfunc tp_print;
out << "#if PY_VERSION_HEX >= 0x03080000\n";
out << " 0, // tp_vectorcall_offset\n";
out << "#else\n";
write_function_slot(out, 4, slots, "tp_print");
out << "#endif\n";
// getattrfunc tp_getattr;
write_function_slot(out, 4, slots, "tp_getattr");
// setattrfunc tp_setattr;
@ -3055,6 +3060,10 @@ write_module_class(ostream &out, Object *obj) {
out << "#if PY_VERSION_HEX >= 0x03040000\n";
out << " nullptr, // tp_finalize\n";
out << "#endif\n";
// vectorcallfunc tp_vectorcall
out << "#if PY_VERSION_HEX >= 0x03080000\n";
out << " nullptr, // tp_vectorcall\n";
out << "#endif\n";
out << " },\n";
// It's tempting to initialize the type handle here, but this causes static

View File

@ -80,7 +80,7 @@ Dtool_PyTypedObject *Dtool_GetSuperBase() {
sizeof(Dtool_PyInstDef),
0, // tp_itemsize
&Dtool_FreeInstance_DTOOL_SUPER_BASE,
nullptr, // tp_print
0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
#if PY_MAJOR_VERSION >= 3
@ -129,6 +129,13 @@ Dtool_PyTypedObject *Dtool_GetSuperBase() {
nullptr, // tp_subclasses
nullptr, // tp_weaklist
nullptr, // tp_del
0, // tp_version_tag,
#if PY_VERSION_HEX >= 0x03040000
nullptr, // tp_finalize
#endif
#if PY_VERSION_HEX >= 0x03080000
nullptr, // tp_vectorcall
#endif
},
TypeHandle::none(),
Dtool_PyModuleClassInit_DTOOL_SUPER_BASE,

View File

@ -139,7 +139,7 @@ typedef long Py_hash_t;
/* Python 3.6 */
#ifndef _PyObject_CallNoArg
#if PY_VERSION_HEX < 0x03080000 && !defined(_PyObject_CallNoArg)
INLINE PyObject *_PyObject_CallNoArg(PyObject *func) {
static PyTupleObject empty_tuple = {PyVarObject_HEAD_INIT(nullptr, 0)};
#ifdef Py_TRACE_REFS

View File

@ -541,7 +541,7 @@ static PyObject *Dtool_MappingWrapper_keys(PyObject *self, PyObject *) {
sizeof(Dtool_SequenceWrapper),
0, // tp_itemsize
Dtool_WrapperBase_dealloc,
nullptr, // tp_print
0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
@ -582,6 +582,13 @@ static PyObject *Dtool_MappingWrapper_keys(PyObject *self, PyObject *) {
nullptr, // tp_subclasses
nullptr, // tp_weaklist
nullptr, // tp_del
0, // tp_version_tag,
#if PY_VERSION_HEX >= 0x03040000
nullptr, // tp_finalize
#endif
#if PY_VERSION_HEX >= 0x03080000
nullptr, // tp_vectorcall
#endif
};
static bool registered = false;
@ -675,7 +682,7 @@ static PyObject *Dtool_MappingWrapper_values(PyObject *self, PyObject *) {
sizeof(Dtool_MappingWrapper),
0, // tp_itemsize
Dtool_WrapperBase_dealloc,
nullptr, // tp_print
0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
@ -716,6 +723,13 @@ static PyObject *Dtool_MappingWrapper_values(PyObject *self, PyObject *) {
nullptr, // tp_subclasses
nullptr, // tp_weaklist
nullptr, // tp_del
0, // tp_version_tag,
#if PY_VERSION_HEX >= 0x03040000
nullptr, // tp_finalize
#endif
#if PY_VERSION_HEX >= 0x03080000
nullptr, // tp_vectorcall
#endif
};
static bool registered = false;
@ -817,7 +831,7 @@ static PyObject *Dtool_MappingWrapper_items(PyObject *self, PyObject *) {
sizeof(Dtool_MappingWrapper),
0, // tp_itemsize
Dtool_WrapperBase_dealloc,
nullptr, // tp_print
0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
@ -858,6 +872,13 @@ static PyObject *Dtool_MappingWrapper_items(PyObject *self, PyObject *) {
nullptr, // tp_subclasses
nullptr, // tp_weaklist
nullptr, // tp_del
0, // tp_version_tag,
#if PY_VERSION_HEX >= 0x03040000
nullptr, // tp_finalize
#endif
#if PY_VERSION_HEX >= 0x03080000
nullptr, // tp_vectorcall
#endif
};
static bool registered = false;
@ -1192,7 +1213,7 @@ Dtool_SequenceWrapper *Dtool_NewSequenceWrapper(PyObject *self, const char *name
sizeof(Dtool_SequenceWrapper),
0, // tp_itemsize
Dtool_WrapperBase_dealloc,
nullptr, // tp_print
0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
@ -1233,6 +1254,13 @@ Dtool_SequenceWrapper *Dtool_NewSequenceWrapper(PyObject *self, const char *name
nullptr, // tp_subclasses
nullptr, // tp_weaklist
nullptr, // tp_del
0, // tp_version_tag,
#if PY_VERSION_HEX >= 0x03040000
nullptr, // tp_finalize
#endif
#if PY_VERSION_HEX >= 0x03080000
nullptr, // tp_vectorcall
#endif
};
static bool registered = false;
@ -1296,7 +1324,7 @@ Dtool_MutableSequenceWrapper *Dtool_NewMutableSequenceWrapper(PyObject *self, co
sizeof(Dtool_MutableSequenceWrapper),
0, // tp_itemsize
Dtool_WrapperBase_dealloc,
nullptr, // tp_print
0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
@ -1337,6 +1365,13 @@ Dtool_MutableSequenceWrapper *Dtool_NewMutableSequenceWrapper(PyObject *self, co
nullptr, // tp_subclasses
nullptr, // tp_weaklist
nullptr, // tp_del
0, // tp_version_tag,
#if PY_VERSION_HEX >= 0x03040000
nullptr, // tp_finalize
#endif
#if PY_VERSION_HEX >= 0x03080000
nullptr, // tp_vectorcall
#endif
};
static bool registered = false;
@ -1404,7 +1439,7 @@ Dtool_MappingWrapper *Dtool_NewMappingWrapper(PyObject *self, const char *name)
sizeof(Dtool_MappingWrapper),
0, // tp_itemsize
Dtool_WrapperBase_dealloc,
nullptr, // tp_print
0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
@ -1445,6 +1480,13 @@ Dtool_MappingWrapper *Dtool_NewMappingWrapper(PyObject *self, const char *name)
nullptr, // tp_subclasses
nullptr, // tp_weaklist
nullptr, // tp_del
0, // tp_version_tag,
#if PY_VERSION_HEX >= 0x03040000
nullptr, // tp_finalize
#endif
#if PY_VERSION_HEX >= 0x03080000
nullptr, // tp_vectorcall
#endif
};
static bool registered = false;
@ -1517,7 +1559,7 @@ Dtool_MappingWrapper *Dtool_NewMutableMappingWrapper(PyObject *self, const char
sizeof(Dtool_MappingWrapper),
0, // tp_itemsize
Dtool_WrapperBase_dealloc,
nullptr, // tp_print
0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
@ -1558,6 +1600,13 @@ Dtool_MappingWrapper *Dtool_NewMutableMappingWrapper(PyObject *self, const char
nullptr, // tp_subclasses
nullptr, // tp_weaklist
nullptr, // tp_del
0, // tp_version_tag,
#if PY_VERSION_HEX >= 0x03040000
nullptr, // tp_finalize
#endif
#if PY_VERSION_HEX >= 0x03080000
nullptr, // tp_vectorcall
#endif
};
static bool registered = false;
@ -1594,7 +1643,7 @@ Dtool_NewGenerator(PyObject *self, iternextfunc gen_next) {
sizeof(Dtool_GeneratorWrapper),
0, // tp_itemsize
Dtool_WrapperBase_dealloc,
nullptr, // tp_print
0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
@ -1635,6 +1684,13 @@ Dtool_NewGenerator(PyObject *self, iternextfunc gen_next) {
nullptr, // tp_subclasses
nullptr, // tp_weaklist
nullptr, // tp_del
0, // tp_version_tag,
#if PY_VERSION_HEX >= 0x03040000
nullptr, // tp_finalize
#endif
#if PY_VERSION_HEX >= 0x03080000
nullptr, // tp_vectorcall
#endif
};
if (PyType_Ready(&wrapper_type) < 0) {
@ -1663,7 +1719,7 @@ Dtool_NewStaticProperty(PyTypeObject *type, const PyGetSetDef *getset) {
sizeof(PyGetSetDescrObject),
0, // tp_itemsize
(destructor)Dtool_StaticProperty_dealloc,
nullptr, // tp_print
0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_reserved
@ -1696,7 +1752,7 @@ Dtool_NewStaticProperty(PyTypeObject *type, const PyGetSetDef *getset) {
nullptr, // tp_init
nullptr, // tp_alloc
nullptr, // tp_new
nullptr, // tp_del
nullptr, // tp_free
nullptr, // tp_is_gc
nullptr, // tp_bases
nullptr, // tp_mro
@ -1704,6 +1760,13 @@ Dtool_NewStaticProperty(PyTypeObject *type, const PyGetSetDef *getset) {
nullptr, // tp_subclasses
nullptr, // tp_weaklist
nullptr, // tp_del
0, // tp_version_tag,
#if PY_VERSION_HEX >= 0x03040000
nullptr, // tp_finalize
#endif
#if PY_VERSION_HEX >= 0x03080000
nullptr, // tp_vectorcall
#endif
};
if (PyType_Ready(&wrapper_type) < 0) {

View File

@ -2918,7 +2918,9 @@ if '__file__' in locals():
bindir = os.path.join(os.path.dirname(__file__), '..', 'bin')
if os.path.isdir(bindir):
if not os.environ.get('PATH'):
if hasattr(os, 'add_dll_directory'):
os.add_dll_directory(bindir)
elif not os.environ.get('PATH'):
os.environ['PATH'] = bindir
else:
os.environ['PATH'] = bindir + os.pathsep + os.environ['PATH']

View File

@ -168,15 +168,18 @@ questions.
PANDA3D_TOOLS_INIT = """import os, sys
import panda3d
dir = os.path.dirname(panda3d.__file__)
del panda3d
if sys.platform in ('win32', 'cygwin'):
path_var = 'PATH'
if hasattr(os, 'add_dll_directory'):
os.add_dll_directory(dir)
elif sys.platform == 'darwin':
path_var = 'DYLD_LIBRARY_PATH'
else:
path_var = 'LD_LIBRARY_PATH'
dir = os.path.dirname(panda3d.__file__)
del panda3d
if not os.environ.get(path_var):
os.environ[path_var] = dir
else: