diff --git a/.travis.yml b/.travis.yml index f73c694a4d..8e5e07142e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,32 @@ language: cpp -compiler: - - gcc - - clang -before_script: - - sudo apt-get install python-dev libpng-dev zlib1g-dev libssl-dev libx11-dev libgl1-mesa-dev libxrandr-dev libxxf86dga-dev libxcursor-dev bison flex libfreetype6-dev libvorbis-dev libjpeg-dev libopenal-dev libode-dev nvidia-cg-toolkit -script: python makepanda/makepanda.py --everything --verbose --git-commit $TRAVIS_COMMIT --installer --threads 4 +sudo: false +matrix: + include: + - compiler: gcc + env: PYTHONV=python2.7 + - compiler: clang + env: PYTHONV=python3 +addons: + apt: + packages: + - bison + - flex + - libfreetype6-dev + - libgl1-mesa-dev + - libjpeg-dev + - libode-dev + - libopenal-dev + - libpng-dev + - libssl-dev + - libvorbis-dev + - libx11-dev + - libxcursor-dev + - libxrandr-dev + - nvidia-cg-toolkit + - python-dev + - python3-dev + - zlib1g-dev +script: $PYTHONV makepanda/makepanda.py --everything --git-commit $TRAVIS_COMMIT --installer --threads 4 notifications: irc: channels: diff --git a/direct/src/dcparser/dcClass.cxx b/direct/src/dcparser/dcClass.cxx index cd9a3856b3..c3e37f6421 100644 --- a/direct/src/dcparser/dcClass.cxx +++ b/direct/src/dcparser/dcClass.cxx @@ -22,6 +22,10 @@ #include "dcClassParameter.h" #include +#ifdef HAVE_PYTHON +#include "py_panda.h" +#endif + #ifdef WITHIN_PANDA #include "pStatTimer.h" @@ -80,7 +84,7 @@ DCClass(DCFile *dc_file, const string &name, bool is_struct, bool bogus_class) : { _number = -1; _constructor = NULL; - + #ifdef HAVE_PYTHON _class_def = NULL; _owner_class_def = NULL; @@ -1003,7 +1007,7 @@ client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id, string field_name = PyString_AsString(py_field_name); #endif Py_XDECREF(py_field_name); - + DCField *field = get_field_by_name(field_name); if (field == (DCField *)NULL) { ostringstream strm; diff --git a/direct/src/dcparser/dcField.cxx b/direct/src/dcparser/dcField.cxx index 7946b62aa1..59701a6df2 100644 --- a/direct/src/dcparser/dcField.cxx +++ b/direct/src/dcparser/dcField.cxx @@ -19,6 +19,10 @@ #include "hashGenerator.h" #include "dcmsgtypes.h" +#ifdef HAVE_PYTHON +#include "py_panda.h" +#endif + #ifdef WITHIN_PANDA #include "pStatTimer.h" #endif diff --git a/direct/src/directtools/DirectLights.py b/direct/src/directtools/DirectLights.py index 1c4ffef230..b1a40b24e3 100644 --- a/direct/src/directtools/DirectLights.py +++ b/direct/src/directtools/DirectLights.py @@ -1,6 +1,5 @@ from panda3d.core import * -from string import lower class DirectLight(NodePath): def __init__(self, light, parent): diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index 9a5551d7b9..1abd3cd4e5 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -1315,7 +1315,7 @@ class Enum: i = start for item in items: # remove leading/trailing whitespace - item = string.strip(item) + item = item.strip() # is there anything left? if len(item) == 0: continue diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 47ef0f4628..ef7e8dc877 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -4733,13 +4733,17 @@ write_function_instance(ostream &out, FunctionRemap *remap, expected_params += "str"; } else if (TypeManager::is_wchar_pointer(orig_type)) { + indent(out, indent_level) << "#if PY_VERSION_HEX >= 0x03020000\n"; + indent(out, indent_level) << "PyObject *" << param_name << ";\n"; + indent(out, indent_level) << "#else\n"; indent(out, indent_level) << "PyUnicodeObject *" << param_name << ";\n"; + indent(out, indent_level) << "#endif\n"; format_specifiers += "U"; parameter_list += ", &" + param_name; extra_convert << "#if PY_VERSION_HEX >= 0x03030000\n" - << "wchar_t *" << param_name << "_str = PyUnicode_AsWideCharString((PyObject *)" << param_name << ", NULL);\n" + << "wchar_t *" << param_name << "_str = PyUnicode_AsWideCharString(" << param_name << ", NULL);\n" << "#else" << "Py_ssize_t " << param_name << "_len = PyUnicode_GET_SIZE(" << param_name << ");\n" << "wchar_t *" << param_name << "_str = (wchar_t *)alloca(sizeof(wchar_t) * (" + param_name + "_len + 1));\n" @@ -4757,14 +4761,18 @@ write_function_instance(ostream &out, FunctionRemap *remap, expected_params += "unicode"; } else if (TypeManager::is_wstring(orig_type)) { + indent(out, indent_level) << "#if PY_VERSION_HEX >= 0x03020000\n"; + indent(out, indent_level) << "PyObject *" << param_name << ";\n"; + indent(out, indent_level) << "#else\n"; indent(out, indent_level) << "PyUnicodeObject *" << param_name << ";\n"; + indent(out, indent_level) << "#endif\n"; format_specifiers += "U"; parameter_list += ", &" + param_name; extra_convert << "#if PY_VERSION_HEX >= 0x03030000\n" << "Py_ssize_t " << param_name << "_len;\n" - << "wchar_t *" << param_name << "_str = PyUnicode_AsWideCharString((PyObject *)" + << "wchar_t *" << param_name << "_str = PyUnicode_AsWideCharString(" << param_name << ", &" << param_name << "_len);\n" << "#else\n" << "Py_ssize_t " << param_name << "_len = PyUnicode_GET_SIZE(" << param_name << ");\n" @@ -4782,14 +4790,18 @@ write_function_instance(ostream &out, FunctionRemap *remap, expected_params += "unicode"; } else if (TypeManager::is_const_ptr_to_basic_string_wchar(orig_type)) { + indent(out, indent_level) << "#if PY_VERSION_HEX >= 0x03020000\n"; + indent(out, indent_level) << "PyObject *" << param_name << ";\n"; + indent(out, indent_level) << "#else\n"; indent(out, indent_level) << "PyUnicodeObject *" << param_name << ";\n"; + indent(out, indent_level) << "#endif\n"; format_specifiers += "U"; parameter_list += ", &" + param_name; extra_convert << "#if PY_VERSION_HEX >= 0x03030000\n" << "Py_ssize_t " << param_name << "_len;\n" - << "wchar_t *" << param_name << "_str = PyUnicode_AsWideCharString((PyObject *)" + << "wchar_t *" << param_name << "_str = PyUnicode_AsWideCharString(" << param_name << ", &" << param_name << "_len);\n" << "#else\n" << "Py_ssize_t " << param_name << "_len = PyUnicode_GET_SIZE(" << param_name << ");\n" diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index 59b66ca05a..ca2a894123 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -135,6 +135,18 @@ inline PyObject* doPy_RETURN_FALSE() typedef long Py_hash_t; #endif +#if PY_MAJOR_VERSION >= 3 +// Python 3 versions before 3.3.3 defined this incorrectly. +#undef _PyErr_OCCURRED +#define _PyErr_OCCURRED() (PyThreadState_GET()->curexc_type) + +// Python versions before 3.3 did not define this. +#if PY_VERSION_HEX < 0x03030000 +#define PyUnicode_AsUTF8 _PyUnicode_AsString +#define PyUnicode_AsUTF8AndSize _PyUnicode_AsStringAndSize +#endif +#endif + using namespace std; /////////////////////////////////////////////////////////////////////////////////// diff --git a/dtool/src/pystub/pystub.cxx b/dtool/src/pystub/pystub.cxx index 2c0dd9303b..399af3ef3a 100644 --- a/dtool/src/pystub/pystub.cxx +++ b/dtool/src/pystub/pystub.cxx @@ -144,10 +144,14 @@ extern "C" { EXPCL_PYSTUB int PyType_GenericAlloc(...); EXPCL_PYSTUB int PyType_IsSubtype(...); EXPCL_PYSTUB int PyType_Ready(...); + EXPCL_PYSTUB int PyUnicodeUCS2_FromFormat(...); + EXPCL_PYSTUB int PyUnicodeUCS2_FromString(...); EXPCL_PYSTUB int PyUnicodeUCS2_FromStringAndSize(...); EXPCL_PYSTUB int PyUnicodeUCS2_FromWideChar(...); EXPCL_PYSTUB int PyUnicodeUCS2_AsWideChar(...); EXPCL_PYSTUB int PyUnicodeUCS2_GetSize(...); + EXPCL_PYSTUB int PyUnicodeUCS4_FromFormat(...); + EXPCL_PYSTUB int PyUnicodeUCS4_FromString(...); EXPCL_PYSTUB int PyUnicodeUCS4_FromStringAndSize(...); EXPCL_PYSTUB int PyUnicodeUCS4_FromWideChar(...); EXPCL_PYSTUB int PyUnicodeUCS4_AsWideChar(...); @@ -175,6 +179,8 @@ extern "C" { EXPCL_PYSTUB int _PyObject_CallMethod_SizeT(...); EXPCL_PYSTUB int _PyObject_DebugFree(...); EXPCL_PYSTUB int _PyObject_Del(...); + EXPCL_PYSTUB int _PyUnicode_AsString(...); + EXPCL_PYSTUB int _PyUnicode_AsStringAndSize(...); EXPCL_PYSTUB int _Py_BuildValue_SizeT(...); EXPCL_PYSTUB int _Py_Dealloc(...); EXPCL_PYSTUB int _Py_NegativeRefcount(...); @@ -190,6 +196,7 @@ extern "C" { EXPCL_PYSTUB extern void *PyExc_Exception; EXPCL_PYSTUB extern void *PyExc_FutureWarning; EXPCL_PYSTUB extern void *PyExc_IndexError; + EXPCL_PYSTUB extern void *PyExc_OSError; EXPCL_PYSTUB extern void *PyExc_RuntimeError; EXPCL_PYSTUB extern void *PyExc_StandardError; EXPCL_PYSTUB extern void *PyExc_StopIteration; @@ -334,10 +341,14 @@ int PyTuple_Type(...) { return 0; }; int PyType_GenericAlloc(...) { return 0; }; int PyType_IsSubtype(...) { return 0; } int PyType_Ready(...) { return 0; }; +int PyUnicodeUCS2_FromFormat(...) { return 0; } +int PyUnicodeUCS2_FromString(...) { return 0; } int PyUnicodeUCS2_FromStringAndSize(...) { return 0; } int PyUnicodeUCS2_FromWideChar(...) { return 0; } int PyUnicodeUCS2_AsWideChar(...) { return 0; } int PyUnicodeUCS2_GetSize(...) { return 0; } +int PyUnicodeUCS4_FromFormat(...) { return 0; } +int PyUnicodeUCS4_FromString(...) { return 0; } int PyUnicodeUCS4_FromStringAndSize(...) { return 0; } int PyUnicodeUCS4_FromWideChar(...) { return 0; } int PyUnicodeUCS4_AsWideChar(...) { return 0; } @@ -365,6 +376,8 @@ int _PyObject_CallFunction_SizeT(...) { return 0; }; int _PyObject_CallMethod_SizeT(...) { return 0; }; int _PyObject_DebugFree(...) { return 0; }; int _PyObject_Del(...) { return 0; }; +int _PyUnicode_AsString(...) { return 0; }; +int _PyUnicode_AsStringAndSize(...) { return 0; }; int _Py_BuildValue_SizeT(...) { return 0; }; int _Py_Dealloc(...) { return 0; }; int _Py_NegativeRefcount(...) { return 0; }; @@ -385,6 +398,7 @@ void *PyExc_ConnectionError = (void *)NULL; void *PyExc_Exception = (void *)NULL; void *PyExc_FutureWarning = (void *)NULL; void *PyExc_IndexError = (void *)NULL; +void *PyExc_OSError = (void *)NULL; void *PyExc_RuntimeError = (void *)NULL; void *PyExc_StandardError = (void *)NULL; void *PyExc_StopIteration = (void *)NULL; diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index a4a749f695..8fe92440bc 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1519,7 +1519,7 @@ def CompileLink(dll, obj, opts): else: cmd += ",5.01" - if dll.endswith(".dll"): + if dll.endswith(".dll") or dll.endswith(".pyd"): cmd += ' /IMPLIB:' + GetOutputDir() + '/lib/' + os.path.splitext(os.path.basename(dll))[0] + ".lib" for (opt, dir) in LIBDIRECTORIES: @@ -1527,10 +1527,8 @@ def CompileLink(dll, obj, opts): cmd += ' /LIBPATH:' + BracketNameWithQuotes(dir) for x in obj: - if x.endswith(".dll"): + if x.endswith(".dll") or x.endswith(".pyd"): cmd += ' ' + GetOutputDir() + '/lib/' + os.path.splitext(os.path.basename(x))[0] + ".lib" - elif x.endswith(".pyd"): - cmd += ' ' + os.path.splitext(x)[0] + ".lib" elif x.endswith(".lib"): dname = os.path.splitext(os.path.basename(x))[0] + ".dll" if (GetOrigExt(x) != ".ilb" and os.path.exists(GetOutputDir()+"/bin/" + dname)): @@ -1587,10 +1585,8 @@ def CompileLink(dll, obj, opts): cmd += ' /LIBPATH:' + BracketNameWithQuotes(dir) for x in obj: - if x.endswith(".dll"): + if x.endswith(".dll") or x.endswith(".pyd"): cmd += ' ' + GetOutputDir() + '/lib/' + os.path.splitext(os.path.basename(x))[0] + ".lib" - elif x.endswith(".pyd"): - cmd += ' ' + os.path.splitext(x)[0] + ".lib" elif x.endswith(".lib"): dname = os.path.splitext(dll)[0]+".dll" if (GetOrigExt(x) != ".ilb" and os.path.exists(GetOutputDir()+"/bin/" + os.path.splitext(os.path.basename(x))[0] + ".dll")): diff --git a/panda/src/nativenet/buffered_datagramconnection.cxx b/panda/src/nativenet/buffered_datagramconnection.cxx index e81e518d4a..e19c4a1bb9 100644 --- a/panda/src/nativenet/buffered_datagramconnection.cxx +++ b/panda/src/nativenet/buffered_datagramconnection.cxx @@ -42,10 +42,10 @@ SendMessage(const Datagram &msg) { #ifdef HAVE_PYTHON ostringstream s; -#if PY_MAJOR_VERSION >= 3 +#if PY_VERSION_HEX >= 0x03030000 PyObject *exc_type = PyExc_ConnectionError; #else - PyObject *exc_type = PyExc_StandardError; + PyObject *exc_type = PyExc_OSError; #endif s << endl << "Error sending message: " << endl;