Commit e6beab19 authored by Kirill Smelkov's avatar Kirill Smelkov

Fix build for Python 3.5

@kazuhiko reports that wendelin.core build is currently broken on Python 3.5.
Indeed it was:

    In file included from bigfile/_bigfile.c:37:0:
    ./include/wendelin/compat_py2.h: In function ‘_PyThreadState_UncheckedGetx’:
    ./include/wendelin/compat_py2.h:66:28: warning: implicit declaration of function ‘_Py_atomic_load_relaxed’ [-Wimplicit-function-declaration]
         return (PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current);
                                ^
    ./include/wendelin/compat_py2.h:66:53: error: ‘_PyThreadState_Current’ undeclared (first use in this function)
         return (PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current);
                                                         ^
    ./include/wendelin/compat_py2.h:66:53: note: each undeclared identifier is reported only once for each function it appears in
    ./include/wendelin/compat_py2.h:67:1: warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^

The story here is that in 3.5 they decided to remove direct access to
_PyThreadState_Current and atomic implementations - because that might
semantically conflict with other headers implementing atomics - and
provide only access by function.

Starting from Python 3.5.2rc1 the function to get current thread state
without asserting it is !NULL - _PyThreadState_UncheckedGet() - was added:

    https://github.com/python/cpython/commit/df858591

so for those python versions we can directly use it.

After the fix wendelin.core tox tests pass under all python2.7, python3.4 and python3.5.

More context here:

    https://bugs.python.org/issue26154
    https://bugs.python.org/issue25150

Fixes: nexedi/wendelin.core#1
parent 20115391
......@@ -58,11 +58,22 @@ static inline PyThreadState * _PyThreadState_UncheckedGet(void)
{
return _PyThreadState_Current;
}
#else
/* _PyThreadState_UncheckedGet() was added in CPython 3.5.2rc1
* https://github.com/python/cpython/commit/df858591
*
* During CPython 3.5.0 - 3.5.rc1 there is a window when
* - public access to pyatomics was removed, and
* - _PyThreadState_UncheckedGet() was not added yet
*
* https://bugs.python.org/issue25150
* https://bugs.python.org/issue26154 */
#elif PY_VERSION_HEX < 0x03050000
static inline PyThreadState * _PyThreadState_UncheckedGet(void)
{
return (PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current);
}
#elif PY_VERSION_HEX < 0x03050200
# error "You are using CPython 3.5.X series. Upgrade your CPython to >= 3.5.2 to get _PyThreadState_UncheckedGet() support."
#endif
#endif
......@@ -262,6 +262,7 @@ setup(
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Programming Language :: Python :: Implementation :: CPython
Topic :: Software Development :: Libraries :: Python Modules
Framework :: ZODB\
......
# wendelin.core | tox setup
[tox]
envlist = py27-ZODB3-{zblk0,zblk1}-{fs,zeo,neo}-{numpy110,numpy111}, {py27,py34}-ZODB4-{zblk0,zblk1}-{fs,zeo}-{numpy110,numpy111}
envlist = py27-ZODB3-{zblk0,zblk1}-{fs,zeo,neo}-{numpy110,numpy111}, {py27,py34,py35}-ZODB4-{zblk0,zblk1}-{fs,zeo}-{numpy110,numpy111}
# (NOTE ZODB3 does not work on python3)
# (NOTE NEO does not work on ZODB4)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment