mirror of
https://github.com/boostorg/python.git
synced 2026-01-25 06:22:15 +00:00
scott snyder's fixes to maintain 1.5.2 compatibility
[SVN r12065]
This commit is contained in:
@@ -566,18 +566,12 @@ bool add_capability_richcompare(type_object_base::capability capability, PyTypeO
|
||||
return false;
|
||||
}
|
||||
|
||||
#if PYTHON_API_VERSION >= 1010
|
||||
# define ENABLE_INPLACE_CAPABILITY1 \
|
||||
dest->tp_flags |= Py_TPFLAGS_HAVE_INPLACEOPS;
|
||||
#else
|
||||
# define ENABLE_INPLACE_CAPABILITY1
|
||||
#endif
|
||||
#define ENABLE_INPLACE_CAPABILITY(field) \
|
||||
case type_object_base::number_##field: \
|
||||
create_method_table_if_null(dest->tp_as_number); \
|
||||
dest->tp_as_number->nb_##field = &do_instance_nb_##field; \
|
||||
detail::shared_pod_manager::replace_if_equal(dest->tp_as_number); \
|
||||
ENABLE_INPLACE_CAPABILITY1 \
|
||||
dest->tp_flags |= Py_TPFLAGS_HAVE_INPLACEOPS; \
|
||||
return true
|
||||
|
||||
bool add_capability_inplace(type_object_base::capability capability, PyTypeObject* dest)
|
||||
@@ -585,6 +579,7 @@ bool add_capability_inplace(type_object_base::capability capability, PyTypeObjec
|
||||
assert(dest != 0);
|
||||
switch (capability)
|
||||
{
|
||||
#if PYTHON_API_VERSION >= 1010
|
||||
ENABLE_INPLACE_CAPABILITY (inplace_add);
|
||||
ENABLE_INPLACE_CAPABILITY (inplace_subtract);
|
||||
ENABLE_INPLACE_CAPABILITY (inplace_multiply);
|
||||
@@ -596,6 +591,7 @@ bool add_capability_inplace(type_object_base::capability capability, PyTypeObjec
|
||||
ENABLE_INPLACE_CAPABILITY (inplace_and);
|
||||
ENABLE_INPLACE_CAPABILITY (inplace_or);
|
||||
ENABLE_INPLACE_CAPABILITY (inplace_xor);
|
||||
#endif
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -334,7 +334,8 @@ Special member attributes. Tests courtesy of Barry Scott <barry@scottb.demon.co.
|
||||
'Docs for DerivedFromBase.fred'
|
||||
|
||||
>>> import sys
|
||||
>>> if sys.version_info[0] < 2 or ( sys.version_info[0] == 2 and
|
||||
>>> if not sys.__dict__.has_key('version_info') or \
|
||||
... sys.version_info[0] < 2 or ( sys.version_info[0] == 2 and
|
||||
... sys.version_info[1] < 2 ):
|
||||
... assert dir(df) == []
|
||||
... assert dir(db) == []
|
||||
@@ -1069,43 +1070,6 @@ test inheritB2
|
||||
Traceback (innermost last):
|
||||
TypeError: bad operand type(s) for pow()
|
||||
|
||||
>>> ii = Int(1)
|
||||
>>> ii += Int(2)
|
||||
>>> ii.i()
|
||||
3
|
||||
>>> ii -= Int(1)
|
||||
>>> ii.i()
|
||||
2
|
||||
>>> ii *= Int(3)
|
||||
>>> ii.i()
|
||||
6
|
||||
>>> ii /= Int(2)
|
||||
>>> ii.i()
|
||||
3
|
||||
>>> ii <<= Int(2)
|
||||
>>> ii.i()
|
||||
12
|
||||
>>> ii >>= Int(1)
|
||||
>>> ii.i()
|
||||
6
|
||||
>>> ii &= Int(5)
|
||||
>>> ii.i()
|
||||
4
|
||||
>>> ii |= Int(9)
|
||||
>>> ii.i()
|
||||
13
|
||||
>>> ii ^= Int(7)
|
||||
>>> ii.i()
|
||||
10
|
||||
>>> ii %= Int(4)
|
||||
>>> ii.i()
|
||||
2
|
||||
>>> ii **= Int(3)
|
||||
>>> ii.i()
|
||||
8
|
||||
>>> ii.j()
|
||||
11
|
||||
|
||||
Test operator export to a subclass
|
||||
|
||||
# force method table sharing
|
||||
@@ -1226,6 +1190,50 @@ test methodologies for wrapping functions that return a pointer
|
||||
'''
|
||||
#'
|
||||
|
||||
__test__ = {}
|
||||
import sys
|
||||
|
||||
# Inplace ops only exist in python 2.1 or later.
|
||||
if sys.hexversion >= 0x02010000:
|
||||
__test__['inplacetests'] = r'''
|
||||
>>> ii = Int(1)
|
||||
>>> ii += Int(2)
|
||||
>>> ii.i()
|
||||
3
|
||||
>>> ii -= Int(1)
|
||||
>>> ii.i()
|
||||
2
|
||||
>>> ii *= Int(3)
|
||||
>>> ii.i()
|
||||
6
|
||||
>>> ii /= Int(2)
|
||||
>>> ii.i()
|
||||
3
|
||||
>>> ii <<= Int(2)
|
||||
>>> ii.i()
|
||||
12
|
||||
>>> ii >>= Int(1)
|
||||
>>> ii.i()
|
||||
6
|
||||
>>> ii &= Int(5)
|
||||
>>> ii.i()
|
||||
4
|
||||
>>> ii |= Int(9)
|
||||
>>> ii.i()
|
||||
13
|
||||
>>> ii ^= Int(7)
|
||||
>>> ii.i()
|
||||
10
|
||||
>>> ii %= Int(4)
|
||||
>>> ii.i()
|
||||
2
|
||||
>>> ii **= Int(3)
|
||||
>>> ii.i()
|
||||
8
|
||||
>>> ii.j()
|
||||
11
|
||||
'''
|
||||
|
||||
from boost_python_test import *
|
||||
|
||||
# pickle requires these derived classes to be
|
||||
|
||||
Reference in New Issue
Block a user