Skip to content

Commit 9a14064

Browse files
committed
fixes for GCC .so/exception problems
[SVN r13471]
1 parent 5fbba7b commit 9a14064

23 files changed

+144
-93
lines changed

doc/index.html

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,53 @@ <h2>Synopsis</h2>
2929
<h2>Supported Platforms</h2>
3030
<p>Boost.Python is known to have been tested in the following configurations:
3131

32+
3233
<ul>
33-
<li>Against Python 2.0 using the following compiler/library combinations:
34+
<li>Against <a href="http://www.python/org/2.2.1">Python 2.2.1</a> using
35+
the following compilers (Note that pickling doesn't work with Python
36+
2.2 due to a core language bug;
37+
<a href="http://www.python/org/2.2.1">2.2.1</a> fixes that).
38+
3439
<ul>
3540
<li><a
36-
href="http://msdn.microsoft.com/vstudio/sp/vs6sp4/dnldoverview.asp">MSVC++6sp4</a>
37-
with the native library.
41+
href="http://msdn.microsoft.com/vstudio/downloads/updates/sp/vs6/sp5/default.asp">MSVC++6sp5</a>. All
42+
tests pass.
43+
44+
<li><a href="http://www.metrowerks.com/products/windows/">Metrowerks
45+
CodeWarrior Pro7.2 for Windows</a>. All tests pass.
46+
47+
<li><a href="http://gcc.gnu.org">GCC 3.0.4</a> under <a
48+
href="www.cygwin.com">Cygwin</a>. All tests pass.
3849

39-
<li>An upcoming release of <a
40-
href="http://www.metrowerks.com/products/windows/">Metrowerks
41-
CodeWarrior Pro6 for Windows</a> with the native library (the first
42-
release has a bug that's fatal to Boost.Python)
50+
<li><a href="http://gcc.gnu.org">GCC 2.95.2</a> under <a
51+
href="www.mingw.org">MinGW</a>. Comprehensive test fails at
52+
runtime due to a compiler code-generation bug. Other tests seem to
53+
work.
4354

44-
<li><a
55+
<li><a
56+
href="http://developer.intel.com/software/products/compilers/c50/">Intel
57+
C++ 6.0</a> beta: Comprehensive test fails to link due to a
58+
linker bug. Other tests seem to work.
59+
60+
<li><a
4561
href="http://developer.intel.com/software/products/compilers/c50/">Intel
46-
C++ 5.0</a>. Compilation succeeds, but tests <font
47-
color="#FF0000"><b>FAILED at runtime</b></font> due to a bug in its
48-
exception-handling implementation.
62+
C++ 5.0</a> Comprehensive test fails at runtime due to an
63+
exception-handling bug. Other tests seem to work.
64+
65+
<li><a href="http://msdn.microsoft.com/visualc/">MSVC++7 (Visual
66+
Studio .NET)</a>. Some tests fail to compile (comprehensive.cpp,
67+
ivect.cpp, dvect.cpp, noncopyable_export.cpp); others seem to work.
68+
</ul>
69+
70+
71+
<li>Against Python 2.0 using the following compilers:
72+
<ul>
73+
<li><a
74+
href="http://msdn.microsoft.com/vstudio/sp/vs6sp4/dnldoverview.asp">MSVC++6sp4</a>.
75+
4976
</ul>
5077

51-
<li>Against Python 1.5.2 using the following compiler/library:
78+
<li>Against Python 1.5.2 using the following compiler/library combinations:
5279

5380
<ul>
5481
<li><a

doc/special.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ <h2><a name="sequence_and_mapping">Sequence and Mapping Operators</a></h2>
768768
if (p == m.end())
769769
{
770770
PyErr_SetObject(PyExc_KeyError, boost::python::converters::to_python(key));
771-
throw boost::python::error_already_set();
771+
boost::python::throw_error_already_set();
772772
}
773773
}
774774

example/do_it_yourself_convts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE
7777
if (tup.size() != 3) {
7878
PyErr_SetString(PyExc_ValueError,
7979
"expecting exactly 3 values in tuple.");
80-
throw python::error_already_set();
80+
python::throw_error_already_set();
8181
}
8282
MillerIndex result;
8383
for (int i = 0; i < 3; i++)

example/pickle2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ namespace { // Avoid cluttering the global namespace.
6363
if (state.size() != 1) {
6464
PyErr_SetString(PyExc_ValueError,
6565
"Unexpected argument in call to __setstate__.");
66-
throw python::error_already_set();
66+
python::throw_error_already_set();
6767
}
6868
int number = from_python(state[0].get(), python::type<int>());
6969
if (number != 42)

example/pickle3.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ namespace {
9999
{
100100
if(args.size() != 1 || keywords.size() != 0) {
101101
PyErr_SetString(PyExc_TypeError, "wrong number of arguments");
102-
throw boost::python::error_already_set();
102+
boost::python::throw_error_already_set();
103103
}
104104
const world& w = from_python(args[0].get(), type<const world&>());
105105
ref mydict = getattr(args[0], "__dict__");
@@ -115,15 +115,15 @@ namespace {
115115
{
116116
if(args.size() != 2 || keywords.size() != 0) {
117117
PyErr_SetString(PyExc_TypeError, "wrong number of arguments");
118-
throw boost::python::error_already_set();
118+
boost::python::throw_error_already_set();
119119
}
120120
world& w = from_python(args[0].get(), type<world&>());
121121
ref mydict = getattr(args[0], "__dict__");
122122
tuple state = from_python(args[1].get(), type<tuple>());
123123
if (state.size() != 2) {
124124
PyErr_SetString(PyExc_ValueError,
125125
"Unexpected argument in call to __setstate__.");
126-
throw python::error_already_set();
126+
python::throw_error_already_set();
127127
}
128128
// restore the object's __dict__
129129
dictionary odict = from_python(mydict.get(), type<dictionary>());

example/richcmp1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace vects {
3535
{ \
3636
if (lhs.size() != rhs.size()) { \
3737
PyErr_SetString(PyExc_ValueError, "vectors have different sizes"); \
38-
throw boost::python::error_already_set(); \
38+
boost::python::throw_error_already_set(); \
3939
} \
4040
std::vector<bool> result(lhs.size()); \
4141
for (std::size_t i=0; i<lhs.size(); i++) { \

example/richcmp3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace vects { \
1212
operator##oper (const vect_type1& lhs, const vect_type2& rhs) { \
1313
if (lhs.size() != rhs.size()) { \
1414
PyErr_SetString(PyExc_ValueError, "vectors have different sizes"); \
15-
throw boost::python::error_already_set(); \
15+
boost::python::throw_error_already_set(); \
1616
} \
1717
result_type result(lhs.size()); \
1818
for (std::size_t i=0; i<lhs.size(); i++) { \

example/simple_vector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace { // Avoid cluttering the global namespace.
3232

3333
void raise_vector_IndexError() {
3434
PyErr_SetString(PyExc_IndexError, "vector index out of range");
35-
throw python::error_already_set();
35+
python::throw_error_already_set();
3636
}
3737

3838
double getitem(const std::vector<double>& vd, std::size_t key) {
@@ -90,8 +90,8 @@ BOOST_PYTHON_MODULE_INIT(simple_vector)
9090
python::class_builder<std::vector<double>, vector_double_wrapper>
9191
vector_double(this_module, "vector_double");
9292

93-
vector_double.def(python::constructor<>());
9493
vector_double.def(python::constructor<int>());
94+
vector_double.def(python::constructor<>());
9595
vector_double.def(python::constructor<python::tuple>());
9696
vector_double.def(&std::vector<double>::size, "__len__");
9797
vector_double.def(getitem, "__getitem__");

example/vector_wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace example {
3939

4040
void raise_vector_IndexError() {
4141
PyErr_SetString(PyExc_IndexError, "vector index out of range");
42-
throw boost::python::error_already_set();
42+
boost::python::throw_error_already_set();
4343
}
4444

4545
template <typename T>

src/classes.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ namespace {
112112
if (getstate_manages_dict.get() == 0)
113113
{
114114
PyErr_SetString(PyExc_RuntimeError, "Incomplete pickle support (__getstate_manages_dict__ not set)");
115-
throw error_already_set();
115+
throw_error_already_set();
116116
}
117117
}
118118

@@ -127,7 +127,7 @@ namespace {
127127
if (dict_defines_state.get() == 0)
128128
{
129129
PyErr_SetString(PyExc_RuntimeError, "Incomplete pickle support (__dict_defines_state__ not set)");
130-
throw error_already_set();
130+
throw_error_already_set();
131131
}
132132
}
133133

@@ -274,7 +274,7 @@ namespace detail {
274274
{
275275
boost::python::string message("Special attribute names other than '__doc__' and '__name__' are read-only, in particular: ");
276276
PyErr_SetObject(PyExc_TypeError, (message + name).get());
277-
throw error_already_set();
277+
throw_error_already_set();
278278
}
279279

280280
if (PyCallable_Check(value))
@@ -485,7 +485,7 @@ int instance::setattr(const char* name, PyObject* value)
485485
if (BOOST_CSTD_::strcmp(name, "__class__") == 0)
486486
{
487487
PyErr_SetString(PyExc_TypeError, "__class__ attribute is read-only");
488-
throw error_already_set();
488+
throw_error_already_set();
489489
}
490490

491491
if (BOOST_CSTD_::strcmp(name, "__dict__") == 0)
@@ -999,9 +999,15 @@ namespace {
999999
}
10001000
}
10011001

1002-
BOOST_PYTHON_DECL void adjust_slice_indices(PyObject* obj, int& start, int& finish)
1002+
BOOST_PYTHON_DECL bool adjust_slice_indices(PyObject* obj, int& start, int& finish)
10031003
{
1004-
int length = callback<int>::call_method(obj, "__len__");
1004+
ref len(PyEval_CallMethod(obj, "__len__", "()")
1005+
, ref::null_ok);
1006+
1007+
if (len.get() == 0)
1008+
return false;
1009+
1010+
int length = PyInt_AsLong(len.get());
10051011

10061012
// This is standard Python class behavior.
10071013
if (start < 0)
@@ -1014,6 +1020,8 @@ BOOST_PYTHON_DECL void adjust_slice_indices(PyObject* obj, int& start, int& fini
10141020
start = 0;
10151021
if (finish < 0)
10161022
finish = 0;
1023+
1024+
return true;
10171025
}
10181026

10191027
namespace detail {

0 commit comments

Comments
 (0)