Commit b8e37bc1 authored by Stefan Behnel's avatar Stefan Behnel

disable usage of _PyType_Lookup() in Py<=2.6/3.1

--HG--
extra : amend_source : c827dfd2e781c1a7e1b982601b6ee8e826d5b4ed
parent 75175aee
...@@ -11,6 +11,9 @@ Features added ...@@ -11,6 +11,9 @@ Features added
Bugs fixed Bugs fixed
---------- ----------
* Lookups of special methods (specifically for context managers) could fail
in Python <= 2.6/3.1.
* Local variables were erroneously appended to the signature introspection * Local variables were erroneously appended to the signature introspection
of Cython implemented functions with keyword-only arguments under Python 3. of Cython implemented functions with keyword-only arguments under Python 3.
......
...@@ -1029,7 +1029,8 @@ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { ...@@ -1029,7 +1029,8 @@ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
/////////////// PyObjectLookupSpecial.proto /////////////// /////////////// PyObjectLookupSpecial.proto ///////////////
//@requires: PyObjectGetAttrStr //@requires: PyObjectGetAttrStr
#if CYTHON_COMPILING_IN_CPYTHON #if CYTHON_COMPILING_IN_CPYTHON && (PY_VERSION_HEX >= 0x03020000 || PY_MAJOR_VERSION < 3 && PY_VERSION_HEX >= 0x02070000)
// looks like calling _PyType_Lookup() isn't safe in Py<=2.6/3.1
static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) { static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) {
PyObject *res; PyObject *res;
PyTypeObject *tp = Py_TYPE(obj); PyTypeObject *tp = Py_TYPE(obj);
...@@ -1052,7 +1053,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObj ...@@ -1052,7 +1053,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObj
return res; return res;
} }
#else #else
#define __Pyx_PyObject_LookupSpecial(o,n) PyObject_GetAttr(o,n) #define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
#endif #endif
/////////////// PyObjectGetAttrStr.proto /////////////// /////////////// PyObjectGetAttrStr.proto ///////////////
......
...@@ -207,6 +207,11 @@ EXT_EXTRAS = { ...@@ -207,6 +207,11 @@ EXT_EXTRAS = {
'tag:trace': update_linetrace_extension, 'tag:trace': update_linetrace_extension,
} }
def _is_py3_before_32(excluded, version):
return version[0] >= 3 and version < (3,2)
# TODO: use tags # TODO: use tags
VER_DEP_MODULES = { VER_DEP_MODULES = {
# tests are excluded if 'CurrentPythonVersion OP VersionTuple', i.e. # tests are excluded if 'CurrentPythonVersion OP VersionTuple', i.e.
...@@ -252,6 +257,7 @@ VER_DEP_MODULES = { ...@@ -252,6 +257,7 @@ VER_DEP_MODULES = {
(2,7) : (operator.lt, lambda x: x in ['run.withstat_py', # multi context with statement (2,7) : (operator.lt, lambda x: x in ['run.withstat_py', # multi context with statement
'run.yield_inside_lambda', 'run.yield_inside_lambda',
'run.test_dictviews', 'run.test_dictviews',
'run.pyclass_special_methods',
]), ]),
# The next line should start (3,); but this is a dictionary, so # The next line should start (3,); but this is a dictionary, so
# we can only have one (3,) key. Since 2.7 is supposed to be the # we can only have one (3,) key. Since 2.7 is supposed to be the
...@@ -263,7 +269,10 @@ VER_DEP_MODULES = { ...@@ -263,7 +269,10 @@ VER_DEP_MODULES = {
(3,): (operator.ge, lambda x: x in ['run.non_future_division', (3,): (operator.ge, lambda x: x in ['run.non_future_division',
'compile.extsetslice', 'compile.extsetslice',
'compile.extdelslice', 'compile.extdelslice',
'run.special_methods_T561_py2']), 'run.special_methods_T561_py2'
]),
(3,1): (_is_py3_before_32, lambda x: x in ['run.pyclass_special_methods',
]),
(3,3) : (operator.lt, lambda x: x in ['build.package_compilation', (3,3) : (operator.lt, lambda x: x in ['build.package_compilation',
]), ]),
(3,4,0,'beta',3) : (operator.le, lambda x: x in ['run.py34_signature', (3,4,0,'beta',3) : (operator.le, lambda x: x in ['run.py34_signature',
......
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