mirror of
https://github.com/boostorg/python.git
synced 2026-01-19 16:32:16 +00:00
fixes for GCC .so/exception problems
[SVN r13471]
This commit is contained in:
@@ -29,26 +29,53 @@ among others.
|
||||
<h2>Supported Platforms</h2>
|
||||
<p>Boost.Python is known to have been tested in the following configurations:
|
||||
|
||||
|
||||
<ul>
|
||||
<li>Against Python 2.0 using the following compiler/library combinations:
|
||||
<li>Against <a href="http://www.python/org/2.2.1">Python 2.2.1</a> using
|
||||
the following compilers (Note that pickling doesn't work with Python
|
||||
2.2 due to a core language bug;
|
||||
<a href="http://www.python/org/2.2.1">2.2.1</a> fixes that).
|
||||
|
||||
<ul>
|
||||
<li><a
|
||||
href="http://msdn.microsoft.com/vstudio/sp/vs6sp4/dnldoverview.asp">MSVC++6sp4</a>
|
||||
with the native library.
|
||||
href="http://msdn.microsoft.com/vstudio/downloads/updates/sp/vs6/sp5/default.asp">MSVC++6sp5</a>. All
|
||||
tests pass.
|
||||
|
||||
<li>An upcoming release of <a
|
||||
href="http://www.metrowerks.com/products/windows/">Metrowerks
|
||||
CodeWarrior Pro6 for Windows</a> with the native library (the first
|
||||
release has a bug that's fatal to Boost.Python)
|
||||
<li><a href="http://www.metrowerks.com/products/windows/">Metrowerks
|
||||
CodeWarrior Pro7.2 for Windows</a>. All tests pass.
|
||||
|
||||
<li><a
|
||||
<li><a href="http://gcc.gnu.org">GCC 3.0.4</a> under <a
|
||||
href="www.cygwin.com">Cygwin</a>. All tests pass.
|
||||
|
||||
<li><a href="http://gcc.gnu.org">GCC 2.95.2</a> under <a
|
||||
href="www.mingw.org">MinGW</a>. Comprehensive test fails at
|
||||
runtime due to a compiler code-generation bug. Other tests seem to
|
||||
work.
|
||||
|
||||
<li><a
|
||||
href="http://developer.intel.com/software/products/compilers/c50/">Intel
|
||||
C++ 5.0</a>. Compilation succeeds, but tests <font
|
||||
color="#FF0000"><b>FAILED at runtime</b></font> due to a bug in its
|
||||
exception-handling implementation.
|
||||
C++ 6.0</a> beta: Comprehensive test fails to link due to a
|
||||
linker bug. Other tests seem to work.
|
||||
|
||||
<li><a
|
||||
href="http://developer.intel.com/software/products/compilers/c50/">Intel
|
||||
C++ 5.0</a> Comprehensive test fails at runtime due to an
|
||||
exception-handling bug. Other tests seem to work.
|
||||
|
||||
<li><a href="http://msdn.microsoft.com/visualc/">MSVC++7 (Visual
|
||||
Studio .NET)</a>. Some tests fail to compile (comprehensive.cpp,
|
||||
ivect.cpp, dvect.cpp, noncopyable_export.cpp); others seem to work.
|
||||
</ul>
|
||||
|
||||
<li>Against Python 1.5.2 using the following compiler/library:
|
||||
|
||||
<li>Against Python 2.0 using the following compilers:
|
||||
<ul>
|
||||
<li><a
|
||||
href="http://msdn.microsoft.com/vstudio/sp/vs6sp4/dnldoverview.asp">MSVC++6sp4</a>.
|
||||
|
||||
</ul>
|
||||
|
||||
<li>Against Python 1.5.2 using the following compiler/library combinations:
|
||||
|
||||
<ul>
|
||||
<li><a
|
||||
|
||||
@@ -768,7 +768,7 @@ void throw_key_error_if_end(
|
||||
if (p == m.end())
|
||||
{
|
||||
PyErr_SetObject(PyExc_KeyError, boost::python::converters::to_python(key));
|
||||
throw boost::python::error_already_set();
|
||||
boost::python::throw_error_already_set();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE
|
||||
if (tup.size() != 3) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"expecting exactly 3 values in tuple.");
|
||||
throw python::error_already_set();
|
||||
python::throw_error_already_set();
|
||||
}
|
||||
MillerIndex result;
|
||||
for (int i = 0; i < 3; i++)
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace { // Avoid cluttering the global namespace.
|
||||
if (state.size() != 1) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Unexpected argument in call to __setstate__.");
|
||||
throw python::error_already_set();
|
||||
python::throw_error_already_set();
|
||||
}
|
||||
int number = from_python(state[0].get(), python::type<int>());
|
||||
if (number != 42)
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace {
|
||||
{
|
||||
if(args.size() != 1 || keywords.size() != 0) {
|
||||
PyErr_SetString(PyExc_TypeError, "wrong number of arguments");
|
||||
throw boost::python::error_already_set();
|
||||
boost::python::throw_error_already_set();
|
||||
}
|
||||
const world& w = from_python(args[0].get(), type<const world&>());
|
||||
ref mydict = getattr(args[0], "__dict__");
|
||||
@@ -115,7 +115,7 @@ namespace {
|
||||
{
|
||||
if(args.size() != 2 || keywords.size() != 0) {
|
||||
PyErr_SetString(PyExc_TypeError, "wrong number of arguments");
|
||||
throw boost::python::error_already_set();
|
||||
boost::python::throw_error_already_set();
|
||||
}
|
||||
world& w = from_python(args[0].get(), type<world&>());
|
||||
ref mydict = getattr(args[0], "__dict__");
|
||||
@@ -123,7 +123,7 @@ namespace {
|
||||
if (state.size() != 2) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Unexpected argument in call to __setstate__.");
|
||||
throw python::error_already_set();
|
||||
python::throw_error_already_set();
|
||||
}
|
||||
// restore the object's __dict__
|
||||
dictionary odict = from_python(mydict.get(), type<dictionary>());
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace vects {
|
||||
{ \
|
||||
if (lhs.size() != rhs.size()) { \
|
||||
PyErr_SetString(PyExc_ValueError, "vectors have different sizes"); \
|
||||
throw boost::python::error_already_set(); \
|
||||
boost::python::throw_error_already_set(); \
|
||||
} \
|
||||
std::vector<bool> result(lhs.size()); \
|
||||
for (std::size_t i=0; i<lhs.size(); i++) { \
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace vects { \
|
||||
operator##oper (const vect_type1& lhs, const vect_type2& rhs) { \
|
||||
if (lhs.size() != rhs.size()) { \
|
||||
PyErr_SetString(PyExc_ValueError, "vectors have different sizes"); \
|
||||
throw boost::python::error_already_set(); \
|
||||
boost::python::throw_error_already_set(); \
|
||||
} \
|
||||
result_type result(lhs.size()); \
|
||||
for (std::size_t i=0; i<lhs.size(); i++) { \
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace { // Avoid cluttering the global namespace.
|
||||
|
||||
void raise_vector_IndexError() {
|
||||
PyErr_SetString(PyExc_IndexError, "vector index out of range");
|
||||
throw python::error_already_set();
|
||||
python::throw_error_already_set();
|
||||
}
|
||||
|
||||
double getitem(const std::vector<double>& vd, std::size_t key) {
|
||||
@@ -90,8 +90,8 @@ BOOST_PYTHON_MODULE_INIT(simple_vector)
|
||||
python::class_builder<std::vector<double>, vector_double_wrapper>
|
||||
vector_double(this_module, "vector_double");
|
||||
|
||||
vector_double.def(python::constructor<>());
|
||||
vector_double.def(python::constructor<int>());
|
||||
vector_double.def(python::constructor<>());
|
||||
vector_double.def(python::constructor<python::tuple>());
|
||||
vector_double.def(&std::vector<double>::size, "__len__");
|
||||
vector_double.def(getitem, "__getitem__");
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace example {
|
||||
|
||||
void raise_vector_IndexError() {
|
||||
PyErr_SetString(PyExc_IndexError, "vector index out of range");
|
||||
throw boost::python::error_already_set();
|
||||
boost::python::throw_error_already_set();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace {
|
||||
if (getstate_manages_dict.get() == 0)
|
||||
{
|
||||
PyErr_SetString(PyExc_RuntimeError, "Incomplete pickle support (__getstate_manages_dict__ not set)");
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace {
|
||||
if (dict_defines_state.get() == 0)
|
||||
{
|
||||
PyErr_SetString(PyExc_RuntimeError, "Incomplete pickle support (__dict_defines_state__ not set)");
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ namespace detail {
|
||||
{
|
||||
boost::python::string message("Special attribute names other than '__doc__' and '__name__' are read-only, in particular: ");
|
||||
PyErr_SetObject(PyExc_TypeError, (message + name).get());
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
if (PyCallable_Check(value))
|
||||
@@ -485,7 +485,7 @@ int instance::setattr(const char* name, PyObject* value)
|
||||
if (BOOST_CSTD_::strcmp(name, "__class__") == 0)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "__class__ attribute is read-only");
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
if (BOOST_CSTD_::strcmp(name, "__dict__") == 0)
|
||||
@@ -999,9 +999,15 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_PYTHON_DECL void adjust_slice_indices(PyObject* obj, int& start, int& finish)
|
||||
BOOST_PYTHON_DECL bool adjust_slice_indices(PyObject* obj, int& start, int& finish)
|
||||
{
|
||||
int length = callback<int>::call_method(obj, "__len__");
|
||||
ref len(PyEval_CallMethod(obj, "__len__", "()")
|
||||
, ref::null_ok);
|
||||
|
||||
if (len.get() == 0)
|
||||
return false;
|
||||
|
||||
int length = PyInt_AsLong(len.get());
|
||||
|
||||
// This is standard Python class behavior.
|
||||
if (start < 0)
|
||||
@@ -1014,6 +1020,8 @@ BOOST_PYTHON_DECL void adjust_slice_indices(PyObject* obj, int& start, int& fini
|
||||
start = 0;
|
||||
if (finish < 0)
|
||||
finish = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -30,7 +30,7 @@ BOOST_PYTHON_DECL long from_python(PyObject* p, boost::python::type<long>)
|
||||
{
|
||||
result = PyInt_AsLong(p);
|
||||
if (PyErr_Occurred())
|
||||
throw boost::python::argument_error();
|
||||
boost::python::throw_argument_error();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ BOOST_PYTHON_DECL double from_python(PyObject* p, boost::python::type<double>)
|
||||
{
|
||||
result = PyFloat_AsDouble(p);
|
||||
if (PyErr_Occurred())
|
||||
throw boost::python::argument_error();
|
||||
boost::python::throw_argument_error();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -61,11 +61,9 @@ T integer_from_python(PyObject* p, boost::python::type<T>)
|
||||
const char message[] = "%ld out of range for %s";
|
||||
sprintf(buffer, message, long_result, typeid(T).name());
|
||||
PyErr_SetString(PyExc_ValueError, buffer);
|
||||
throw boost::python::argument_error();
|
||||
boost::python::throw_argument_error();
|
||||
}
|
||||
#if defined(__MWERKS__) && __MWERKS__ <= 0x2407
|
||||
return 0; // Not smart enough to know that the catch clause always rethrows
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -81,7 +79,7 @@ PyObject* integer_to_python(T value)
|
||||
{
|
||||
const char message[] = "value out of range for Python int";
|
||||
PyErr_SetString(PyExc_ValueError, message);
|
||||
throw boost::python::error_already_set();
|
||||
boost::python::throw_error_already_set();
|
||||
}
|
||||
|
||||
return to_python(value_as_long);
|
||||
@@ -134,7 +132,7 @@ BOOST_PYTHON_DECL char from_python(PyObject* p, boost::python::type<char>)
|
||||
if (PyString_Check(p)) l = PyString_Size(p);
|
||||
if (l < 0 || l > 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "expected string of length 0 or 1");
|
||||
throw boost::python::argument_error();
|
||||
boost::python::throw_argument_error();
|
||||
}
|
||||
if (l == 0) return '\0';
|
||||
return PyString_AsString(p)[0];
|
||||
@@ -174,7 +172,7 @@ BOOST_PYTHON_DECL void from_python(PyObject* p, boost::python::type<void>)
|
||||
{
|
||||
if (p != Py_None) {
|
||||
PyErr_SetString(PyExc_TypeError, "expected argument of type None");
|
||||
throw boost::python::argument_error();
|
||||
boost::python::throw_argument_error();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +180,7 @@ BOOST_PYTHON_DECL const char* from_python(PyObject* p, boost::python::type<const
|
||||
{
|
||||
const char* s = PyString_AsString(p);
|
||||
if (!s)
|
||||
throw boost::python::argument_error();
|
||||
boost::python::throw_argument_error();
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -195,7 +193,7 @@ BOOST_PYTHON_DECL std::string from_python(PyObject* p, boost::python::type<std::
|
||||
{
|
||||
if (! PyString_Check(p)) {
|
||||
PyErr_SetString(PyExc_TypeError, "expected a string");
|
||||
throw boost::python::argument_error();
|
||||
boost::python::throw_argument_error();
|
||||
}
|
||||
return std::string(PyString_AsString(p), PyString_Size(p));
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace
|
||||
else if (!PyFloat_Check(intermediate))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "__complex__ method did not return a Complex object");
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
return PyFloat_AS_DOUBLE(intermediate);
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace detail
|
||||
PyErr_SetString(
|
||||
PyExc_TypeError
|
||||
, const_cast<char*>("no to_python (by-value) converter found for type"));
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
return source == 0
|
||||
@@ -46,7 +46,7 @@ namespace detail
|
||||
PyErr_SetString(
|
||||
PyExc_TypeError
|
||||
, const_cast<char*>("no from_python rvalue or lvalue converters found for type"));
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace detail
|
||||
PyErr_SetString(
|
||||
PyExc_TypeError
|
||||
, const_cast<char*>("no from_python lvalue converters found for type"));
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace detail
|
||||
PyErr_SetString(
|
||||
PyExc_ReferenceError
|
||||
, const_cast<char*>("Attempt to return dangling internal reference"));
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
void* result = find(source, converters);
|
||||
if (!result)
|
||||
@@ -79,7 +79,7 @@ namespace detail
|
||||
PyErr_SetString(
|
||||
PyExc_TypeError
|
||||
, const_cast<char*>("no registered from_python lvalue converter was able to convert object"));
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ namespace detail
|
||||
PyErr_SetString(
|
||||
PyExc_TypeError
|
||||
, const_cast<char*>("class not registered for to_python type"));
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
BOOST_PYTHON_DECL void* convert_rvalue(PyObject* src, rvalue_stage1_data& data, void* storage)
|
||||
@@ -115,7 +115,7 @@ namespace detail
|
||||
PyErr_SetString(
|
||||
PyExc_TypeError
|
||||
, const_cast<char*>("no registered from_python lvalue or rvalue converter was able to convert object"));
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
if (data.construct != 0)
|
||||
data.construct(src, &data);
|
||||
|
||||
@@ -22,13 +22,23 @@ namespace
|
||||
{
|
||||
python::ref module_obj(PyImport_ImportModule((char*) module_name));
|
||||
PyObject* module_dict = PyModule_GetDict(module_obj.get());
|
||||
if (module_dict == 0) throw python::import_error();
|
||||
if (module_dict == 0) python::throw_import_error();
|
||||
return module_dict;
|
||||
}
|
||||
}
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
void BOOST_PYTHON_DECL throw_import_error()
|
||||
{
|
||||
throw import_error();
|
||||
}
|
||||
|
||||
void BOOST_PYTHON_DECL throw_export_error()
|
||||
{
|
||||
throw export_error();
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
BOOST_PYTHON_DECL const char* converters_attribute_name = "__converters__";
|
||||
@@ -43,20 +53,20 @@ namespace detail
|
||||
if (py_class == 0) {
|
||||
err = std::string("module ") + module_name + " has no attribute " + py_class_name;
|
||||
PyErr_SetString(PyExc_RuntimeError, const_cast<char*>(err.c_str()));
|
||||
throw python::import_error();
|
||||
python::throw_import_error();
|
||||
}
|
||||
python::ref c_obj(PyObject_GetAttrString(py_class, const_cast<char*>(attribute_name.c_str())), ref::null_ok);
|
||||
if (c_obj.get() == 0) {
|
||||
err = std::string("object ") + module_name + "." + py_class_name
|
||||
+ " has no attribute " + attribute_name;
|
||||
PyErr_SetString(PyExc_RuntimeError, const_cast<char*>(err.c_str()));
|
||||
throw python::import_error();
|
||||
python::throw_import_error();
|
||||
}
|
||||
if (! PyCObject_Check(c_obj.get())) {
|
||||
err = std::string("object ") + module_name + "." + py_class_name + "."
|
||||
+ attribute_name + " is not a PyCObject";
|
||||
PyErr_SetString(PyExc_RuntimeError, const_cast<char*>(err.c_str()));
|
||||
throw python::import_error();
|
||||
python::throw_import_error();
|
||||
}
|
||||
return PyCObject_AsVoidPtr(c_obj.get());
|
||||
}
|
||||
@@ -76,7 +86,7 @@ namespace detail
|
||||
imported_major, imported_minor);
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"Fatal: export_converters_api mismatch");
|
||||
throw import_error();
|
||||
throw_import_error();
|
||||
}
|
||||
if (importing_minor != imported_minor) {
|
||||
// Python uses fprintf(stderr, ...) for API warnings.
|
||||
|
||||
@@ -39,10 +39,20 @@ BOOST_PYTHON_DECL bool handle_exception_impl(function0<void> f)
|
||||
return true;
|
||||
}
|
||||
|
||||
void BOOST_PYTHON_DECL throw_argument_error()
|
||||
{
|
||||
throw argument_error();
|
||||
}
|
||||
|
||||
void BOOST_PYTHON_DECL throw_error_already_set()
|
||||
{
|
||||
throw error_already_set();
|
||||
}
|
||||
|
||||
BOOST_PYTHON_DECL PyObject* expect_non_null(PyObject* x)
|
||||
{
|
||||
if (x == 0)
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -53,7 +63,7 @@ namespace detail {
|
||||
if (!PyComplex_Check(p))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "expected a complex number");
|
||||
throw boost::python::argument_error();
|
||||
boost::python::throw_argument_error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ extension_instance* get_extension_instance(PyObject* p)
|
||||
if (p->ob_type->ob_type != extension_meta_class())
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, p->ob_type->tp_name);
|
||||
throw boost::python::argument_error();
|
||||
boost::python::throw_argument_error();
|
||||
}
|
||||
return static_cast<extension_instance*>(p);
|
||||
}
|
||||
@@ -157,7 +157,7 @@ extension_instance::add_implementation(std::auto_ptr<instance_holder_base> holde
|
||||
if (typeid(*holder) == typeid(**p))
|
||||
{
|
||||
PyErr_SetString(PyExc_RuntimeError, "Base class already initialized");
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
}
|
||||
m_wrapped_objects.push_back(holder.release());
|
||||
@@ -242,9 +242,9 @@ void two_string_error(PyObject* exception_object, const char* format, const char
|
||||
|
||||
PyErr_SetString(exception_object, buffer);
|
||||
if (exception_object == PyExc_TypeError)
|
||||
throw argument_error();
|
||||
throw_argument_error();
|
||||
else
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
// This is called when an attempt has been made to convert the given obj to
|
||||
@@ -309,7 +309,7 @@ void report_missing_class_object(const std::type_info& info)
|
||||
const char message[] = "Cannot convert <%.*s> to python; its Python class was never created or has been deleted.";
|
||||
sprintf(buffer, message, sizeof(buffer) - sizeof(message) - 1, info.name());
|
||||
PyErr_SetString(PyExc_RuntimeError, buffer);
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
void report_released_smart_pointer(const std::type_info& info)
|
||||
@@ -318,7 +318,7 @@ void report_released_smart_pointer(const std::type_info& info)
|
||||
const char message[] = "Converting from python, pointer or smart pointer to <%.*s> is NULL.";
|
||||
sprintf(buffer, message, sizeof(buffer) - sizeof(message) - 1, info.name());
|
||||
PyErr_SetString(PyExc_RuntimeError, buffer);
|
||||
throw argument_error();
|
||||
throw_argument_error();
|
||||
}
|
||||
|
||||
read_only_setattr_function::read_only_setattr_function(const char* name)
|
||||
|
||||
@@ -51,7 +51,7 @@ void function::add_to_namespace(reference<function> new_function, const char* na
|
||||
(string("Attempt to overload ") + name
|
||||
+ " failed. The existing attribute has type "
|
||||
+ existing_object->ob_type->tp_name).get());
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ class python_extension_class_converters
|
||||
return static_cast<T*>(target);
|
||||
}
|
||||
boost::python::detail::report_missing_instance_data(self, boost::python::detail::class_registry<T>::class_object(), typeid(T));
|
||||
throw boost::python::argument_error();
|
||||
boost::python::throw_argument_error();
|
||||
#if defined(__MWERKS__) && __MWERKS__ <= 0x2406
|
||||
return 0;
|
||||
#endif
|
||||
@@ -293,7 +293,7 @@ class python_extension_class_converters
|
||||
return held->ptr();
|
||||
}
|
||||
boost::python::detail::report_missing_ptr_data(self, boost::python::detail::class_registry<T>::class_object(), typeid(T));
|
||||
throw boost::python::argument_error();
|
||||
boost::python::throw_argument_error();
|
||||
#if defined(__MWERKS__) && __MWERKS__ <= 0x2406
|
||||
return *(PtrType*)0;
|
||||
#endif
|
||||
|
||||
@@ -189,7 +189,7 @@ struct init%x : init
|
||||
{
|
||||
%(PyObject* a%n;
|
||||
%)if (!PyArg_ParseTuple(args, const_cast<char*>("%(O%)")%(, &a%n%)))
|
||||
throw argument_error();
|
||||
throw_argument_error();
|
||||
return new T(self%(,
|
||||
boost::python::detail::reference_parameter<A%n>(from_python(a%n, type<A%n>()))%)
|
||||
);
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace
|
||||
string report("extension class wrapper for base class ");
|
||||
(report += id.name()) += " has not been created yet";
|
||||
PyErr_SetObject(PyExc_RuntimeError, report.get());
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
return p->value;
|
||||
}
|
||||
@@ -273,14 +273,14 @@ void class_base::add_property(char const* name, ref const& fget)
|
||||
{
|
||||
ref property(PyObject_CallFunction((PyObject*)&PyProperty_Type, "O", fget.get()));
|
||||
if (PyObject_SetAttrString(object().get(), const_cast<char*>(name), property.get()) < 0)
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
void class_base::add_property(char const* name, ref const& fget, ref const& fset)
|
||||
{
|
||||
ref property(PyObject_CallFunction((PyObject*)&PyProperty_Type, "OO", fget.get(), fset.get()));
|
||||
if (PyObject_SetAttrString(object().get(), const_cast<char*>(name), property.get()) < 0)
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
@@ -95,7 +95,7 @@ void function::add_to_namespace(
|
||||
dict = PyObject_GetAttrString(ns, "__dict__");
|
||||
|
||||
if (dict == 0)
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
|
||||
ref existing(PyObject_GetItem(dict, name.get()), ref::null_ok);
|
||||
|
||||
@@ -110,7 +110,7 @@ void function::add_to_namespace(
|
||||
// The PyObject_GetAttrString() call above left an active error
|
||||
PyErr_Clear();
|
||||
if (PyObject_SetAttr(ns, name.get(), attribute.get()) < 0)
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
namespace
|
||||
|
||||
@@ -24,7 +24,7 @@ T object_from_python(PyObject* p, type<T>)
|
||||
if (!T::accepts(x))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, p->ob_type->tp_name);
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
return T(x);
|
||||
}
|
||||
@@ -111,7 +111,7 @@ tuple_base::tuple_base(ref p)
|
||||
if (!accepts(p))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, p->ob_type->tp_name);
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ string::string(ref p)
|
||||
if (!accepts(p))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, p->ob_type->tp_name);
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ dictionary_base::dictionary_base(ref p)
|
||||
if (!accepts(p))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, p->ob_type->tp_name);
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ void dictionary_base::clear()
|
||||
const ref& dictionary_proxy::operator=(const ref& rhs)
|
||||
{
|
||||
if (PyDict_SetItem(m_dict.get(), m_key.get(), rhs.get()) == -1)
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
return rhs;
|
||||
}
|
||||
|
||||
@@ -283,12 +283,12 @@ ref dictionary_base::get_item(const ref& key, const ref& default_) const
|
||||
void dictionary_base::set_item(const ref& key, const ref& value)
|
||||
{
|
||||
if (PyDict_SetItem(get(), key.get(), value.get()) == -1)
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
void dictionary_base::erase(ref key) {
|
||||
if (PyDict_DelItem(get(), key.get()) == -1)
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
list dictionary_base::items() const { return list(ref(PyDict_Items(get()))); }
|
||||
@@ -347,7 +347,7 @@ list_base::list_base(ref p)
|
||||
if (!accepts(p))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, p->ob_type->tp_name);
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,13 +384,13 @@ list_proxy list_base::operator[](std::size_t pos)
|
||||
void list_base::insert(std::size_t index, const ref& item)
|
||||
{
|
||||
if (PyList_Insert(get(), index, item.get()) == -1)
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
void list_base::push_back(const ref& item)
|
||||
{
|
||||
if (PyList_Append(get(), item.get()) == -1)
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
void list_base::append(const ref& item)
|
||||
@@ -411,13 +411,13 @@ list_slice_proxy list_base::slice(int low, int high)
|
||||
void list_base::sort()
|
||||
{
|
||||
if (PyList_Sort(get()) == -1)
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
void list_base::reverse()
|
||||
{
|
||||
if (PyList_Reverse(get()) == -1)
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
tuple list_base::as_tuple() const
|
||||
@@ -445,7 +445,7 @@ void list_base::set_item(std::size_t pos, const ref& rhs)
|
||||
{
|
||||
int result = PyList_SetItem(this->get(), pos, rhs.get());
|
||||
if (result == -1)
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
Py_INCREF(rhs.get());
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ list_proxy::list_proxy(const ref& list, std::size_t index)
|
||||
const list& list_slice_proxy::operator=(const list& rhs)
|
||||
{
|
||||
if (PyList_SetSlice(m_list.get(), m_low, m_high, rhs.get()) == -1)
|
||||
throw error_already_set();
|
||||
throw_error_already_set();
|
||||
return rhs;
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ void set_first(IntPair& p, int value)
|
||||
void del_first(const IntPair&)
|
||||
{
|
||||
PyErr_SetString(PyExc_AttributeError, "first can't be deleted!");
|
||||
throw boost::python::error_already_set();
|
||||
boost::python::throw_error_already_set();
|
||||
}
|
||||
|
||||
IntPairPythonClass::IntPairPythonClass(boost::python::module_builder& m)
|
||||
@@ -146,14 +146,14 @@ void IntPairPythonClass::setattr(IntPair& x, const std::string& name, int value)
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_AttributeError, name.c_str());
|
||||
throw boost::python::error_already_set();
|
||||
boost::python::throw_error_already_set();
|
||||
}
|
||||
}
|
||||
|
||||
void IntPairPythonClass::delattr(IntPair&, const char*)
|
||||
{
|
||||
PyErr_SetString(PyExc_AttributeError, "Attributes can't be deleted!");
|
||||
throw boost::python::error_already_set();
|
||||
boost::python::throw_error_already_set();
|
||||
}
|
||||
|
||||
int IntPairPythonClass::getattr(const IntPair& p, const std::string& s)
|
||||
@@ -165,11 +165,9 @@ int IntPairPythonClass::getattr(const IntPair& p, const std::string& s)
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_AttributeError, s.c_str());
|
||||
throw boost::python::error_already_set();
|
||||
boost::python::throw_error_already_set();
|
||||
}
|
||||
#if defined(__MWERKS__) && __MWERKS__ <= 0x2407
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace { namespace file_local {
|
||||
@@ -177,8 +175,8 @@ void throw_key_error_if_end(const StringMap& m, StringMap::const_iterator p, std
|
||||
{
|
||||
if (p == m.end())
|
||||
{
|
||||
PyErr_SetObject(PyExc_KeyError, BOOST_PYTHON_CONVERSION::to_python(key));
|
||||
throw boost::python::error_already_set();
|
||||
PyErr_SetObject(PyExc_KeyError, BOOST_PYTHON_CONVERSION::to_python(key));
|
||||
boost::python::throw_error_already_set();
|
||||
}
|
||||
}
|
||||
}} // namespace <anonymous>::file_local
|
||||
@@ -871,7 +869,7 @@ namespace bpl_test {
|
||||
if (state.size() != 1) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Unexpected argument in call to __setstate__.");
|
||||
throw boost::python::error_already_set();
|
||||
boost::python::throw_error_already_set();
|
||||
}
|
||||
|
||||
const int number = BOOST_PYTHON_CONVERSION::from_python(state[0].get(), boost::python::type<int>());
|
||||
@@ -1182,7 +1180,7 @@ PyObject* raw(const boost::python::tuple& args, const boost::python::dictionary&
|
||||
if(args.size() != 2 || keywords.size() != 2)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "wrong number of arguments");
|
||||
throw boost::python::argument_error();
|
||||
boost::python::throw_argument_error();
|
||||
}
|
||||
|
||||
RawTest* first = BOOST_PYTHON_CONVERSION::from_python(args[0].get(), boost::python::type<RawTest*>());
|
||||
|
||||
Reference in New Issue
Block a user