Skip to content

Commit 4cf7ab3

Browse files
committed
fixes for GCC .so/exception problems
[SVN r13469]
1 parent b7f93bd commit 4cf7ab3

6 files changed

Lines changed: 33 additions & 29 deletions

File tree

include/boost/python/classes.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,19 +349,21 @@ int class_t<T>::instance_mapping_ass_subscript(PyObject* obj, PyObject* key, PyO
349349
return 0;
350350
}
351351

352-
void BOOST_PYTHON_DECL adjust_slice_indices(PyObject* obj, int& start, int& finish);
352+
bool BOOST_PYTHON_DECL adjust_slice_indices(PyObject* obj, int& start, int& finish);
353353

354354
template <class T>
355355
PyObject* class_t<T>::instance_sequence_slice(PyObject* obj, int start, int finish) const
356356
{
357-
adjust_slice_indices(obj, start, finish);
357+
if (!adjust_slice_indices(obj, start, finish))
358+
return 0;
358359
return downcast<T>(obj)->get_slice(start, finish);
359360
}
360361

361362
template <class T>
362363
int class_t<T>::instance_sequence_ass_slice(PyObject* obj, int start, int finish, PyObject* value) const
363364
{
364-
adjust_slice_indices(obj, start, finish);
365+
if (!adjust_slice_indices(obj, start, finish))
366+
return -1;
365367
downcast<T>(obj)->set_slice(start, finish, value);
366368
return 0;
367369
}

include/boost/python/cross_module.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
# include <boost/python/class_builder.hpp>
1919

2020
namespace boost { namespace python {
21-
struct BOOST_PYTHON_DECL import_error: error_already_set {};
22-
struct BOOST_PYTHON_DECL export_error : error_already_set {};
21+
22+
struct BOOST_PYTHON_DECL import_error: error_already_set {};
23+
struct BOOST_PYTHON_DECL export_error : error_already_set {};
24+
25+
void BOOST_PYTHON_DECL throw_import_error();
26+
void BOOST_PYTHON_DECL throw_export_error();
2327

2428
namespace detail
2529
{
@@ -170,10 +174,8 @@ struct export_converter_object_noncopyable : export_converter_object_base<T>
170174
virtual PyObject* to_python(const T& x) {
171175
PyErr_SetString(PyExc_RuntimeError,
172176
"to_python(const T&) converter not exported");
173-
throw import_error();
174-
#if defined(__MWERKS__) && __MWERKS__ <= 0x2406
177+
throw_import_error();
175178
return 0;
176-
#endif
177179
}
178180

179181
virtual T* from_python_Ts(PyObject* p, boost::python::type<T*> t) {

include/boost/python/detail/extension_class.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,8 @@ class python_extension_class_converters
255255
return static_cast<T*>(target);
256256
}
257257
boost::python::detail::report_missing_instance_data(self, boost::python::detail::class_registry<T>::class_object(), typeid(T));
258-
throw boost::python::argument_error();
259-
#if defined(__MWERKS__) && __MWERKS__ <= 0x2406
258+
boost::python::throw_argument_error();
260259
return 0;
261-
#endif
262260
}
263261

264262
// Convert to T*
@@ -286,10 +284,9 @@ class python_extension_class_converters
286284
return held->ptr();
287285
}
288286
boost::python::detail::report_missing_ptr_data(self, boost::python::detail::class_registry<T>::class_object(), typeid(T));
289-
throw boost::python::argument_error();
290-
#if defined(__MWERKS__) && __MWERKS__ <= 0x2406
287+
boost::python::throw_argument_error();
288+
291289
return *(PtrType*)0;
292-
#endif
293290
}
294291

295292
// Extract from obj a reference to the PtrType object which is holding a

include/boost/python/detail/init_function.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ struct init0 : init
299299
virtual instance_holder_base* create_holder(extension_instance* self, PyObject* args, PyObject* /*keywords*/) const
300300
{
301301
if (!PyArg_ParseTuple(args, const_cast<char*>("")))
302-
throw argument_error();
302+
throw_argument_error();
303303
return new T(self
304304
);
305305
}
@@ -314,7 +314,7 @@ struct init1 : init
314314
{
315315
PyObject* a1;
316316
if (!PyArg_ParseTuple(args, const_cast<char*>("O"), &a1))
317-
throw argument_error();
317+
throw_argument_error();
318318
return new T(self,
319319
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>()))
320320
);
@@ -331,7 +331,7 @@ struct init2 : init
331331
PyObject* a1;
332332
PyObject* a2;
333333
if (!PyArg_ParseTuple(args, const_cast<char*>("OO"), &a1, &a2))
334-
throw argument_error();
334+
throw_argument_error();
335335
return new T(self,
336336
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
337337
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>()))
@@ -350,7 +350,7 @@ struct init3 : init
350350
PyObject* a2;
351351
PyObject* a3;
352352
if (!PyArg_ParseTuple(args, const_cast<char*>("OOO"), &a1, &a2, &a3))
353-
throw argument_error();
353+
throw_argument_error();
354354
return new T(self,
355355
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
356356
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),
@@ -371,7 +371,7 @@ struct init4 : init
371371
PyObject* a3;
372372
PyObject* a4;
373373
if (!PyArg_ParseTuple(args, const_cast<char*>("OOOO"), &a1, &a2, &a3, &a4))
374-
throw argument_error();
374+
throw_argument_error();
375375
return new T(self,
376376
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
377377
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),
@@ -394,7 +394,7 @@ struct init5 : init
394394
PyObject* a4;
395395
PyObject* a5;
396396
if (!PyArg_ParseTuple(args, const_cast<char*>("OOOOO"), &a1, &a2, &a3, &a4, &a5))
397-
throw argument_error();
397+
throw_argument_error();
398398
return new T(self,
399399
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
400400
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),
@@ -419,7 +419,7 @@ struct init6 : init
419419
PyObject* a5;
420420
PyObject* a6;
421421
if (!PyArg_ParseTuple(args, const_cast<char*>("OOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6))
422-
throw argument_error();
422+
throw_argument_error();
423423
return new T(self,
424424
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
425425
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),
@@ -446,7 +446,7 @@ struct init7 : init
446446
PyObject* a6;
447447
PyObject* a7;
448448
if (!PyArg_ParseTuple(args, const_cast<char*>("OOOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6, &a7))
449-
throw argument_error();
449+
throw_argument_error();
450450
return new T(self,
451451
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
452452
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),
@@ -475,7 +475,7 @@ struct init8 : init
475475
PyObject* a7;
476476
PyObject* a8;
477477
if (!PyArg_ParseTuple(args, const_cast<char*>("OOOOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8))
478-
throw argument_error();
478+
throw_argument_error();
479479
return new T(self,
480480
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
481481
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),
@@ -506,7 +506,7 @@ struct init9 : init
506506
PyObject* a8;
507507
PyObject* a9;
508508
if (!PyArg_ParseTuple(args, const_cast<char*>("OOOOOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9))
509-
throw argument_error();
509+
throw_argument_error();
510510
return new T(self,
511511
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
512512
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),
@@ -539,7 +539,7 @@ struct init10 : init
539539
PyObject* a9;
540540
PyObject* a10;
541541
if (!PyArg_ParseTuple(args, const_cast<char*>("OOOOOOOOOO"), &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9, &a10))
542-
throw argument_error();
542+
throw_argument_error();
543543
return new T(self,
544544
boost::python::detail::reference_parameter<A1>(from_python(a1, type<A1>())),
545545
boost::python::detail::reference_parameter<A2>(from_python(a2, type<A2>())),

include/boost/python/errors.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
namespace boost { namespace python {
1717

18-
struct error_already_set {};
19-
struct argument_error : error_already_set {};
18+
struct BOOST_PYTHON_DECL error_already_set {};
19+
struct BOOST_PYTHON_DECL argument_error : error_already_set {};
2020

2121
// Handles exceptions caught just before returning to Python code.
2222
// Returns true iff an exception was caught.
@@ -43,6 +43,9 @@ T* expect_non_null(T* x)
4343
return (T*)expect_non_null((PyObject*)x);
4444
}
4545

46+
BOOST_PYTHON_DECL void throw_argument_error();
47+
BOOST_PYTHON_DECL void throw_error_already_set();
48+
4649
}} // namespace boost::python
4750

4851
#endif // ERRORS_DWA052500_H_

include/boost/python/operators.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ namespace detail
344344
if (args.size() == 3 && args[2]->ob_type != Py_None->ob_type)
345345
{
346346
PyErr_SetString(PyExc_TypeError, "expected 2 arguments, got 3");
347-
throw argument_error();
347+
throw_argument_error();
348348
}
349349

350350
return BOOST_PYTHON_CONVERSION::to_python(
@@ -367,7 +367,7 @@ namespace detail
367367
if (args.size() == 3 && args[2]->ob_type != Py_None->ob_type)
368368
{
369369
PyErr_SetString(PyExc_TypeError, "bad operand type(s) for pow()");
370-
throw argument_error();
370+
throw_argument_error();
371371
}
372372

373373
return BOOST_PYTHON_CONVERSION::to_python(

0 commit comments

Comments
 (0)