summaryrefslogtreecommitdiff
path: root/python_compatibility.h
Commit message (Collapse)AuthorAgeFilesLines
* SPDXify the licerse references.Eric S. Raymond2018-03-081-1/+1
|
* Fixes Python C extensions for Python 3 compatibility.Fred Wright2016-04-091-0/+44
These are necessary, but not sufficient, changes to make the C extensions work "polyglot". These are believed to be complete as far as the C code is concerned, and don't break Python 2 compatibility. This puts all the stuff that needs to differ between Python 2 and Python 3 into conditionally-defined macros in a new header file python_compatibility.h. The definitions assume Python 2.6 or later. In addition to the things requiring conditionals, the Lexer object was using the deprecated tp_getattr entry, with a function based on Py_FindMethod, which is gone in Python 3. However, the newer tp_getattro entry can be pointed directly to PyObject_GenericGetAttr, which works in Python 2 and 3. Packet data returned by the Lexer is now 'bytes' in Python 3, which is appropriate given that it may contain binary data. However, it means that packet data can't be passed directly to anything expecting a 'str'. In Python 2, the data is just a 'str' as usual. TESTED: Ran "scons build-all check" and xgps (using Python 2.7). Also ran the daemon and maidenhead-locator tests with Python 2.6.