summaryrefslogtreecommitdiff
path: root/libs/python
diff options
context:
space:
mode:
Diffstat (limited to 'libs/python')
-rw-r--r--libs/python/src/dict.cpp4
-rw-r--r--libs/python/src/list.cpp4
-rw-r--r--libs/python/src/long.cpp15
-rw-r--r--libs/python/src/object/class.cpp8
-rw-r--r--libs/python/src/str.cpp10
-rw-r--r--libs/python/src/tuple.cpp5
6 files changed, 18 insertions, 28 deletions
diff --git a/libs/python/src/dict.cpp b/libs/python/src/dict.cpp
index 5e196ff..77d840d 100644
--- a/libs/python/src/dict.cpp
+++ b/libs/python/src/dict.cpp
@@ -28,9 +28,9 @@ namespace
detail::new_reference dict_base::call(object const& arg_)
{
- union { PyTypeObject *ptop; PyObject *pop; }pun = { &PyDict_Type };
return (detail::new_reference)PyObject_CallFunction(
- pun.pop, const_cast<char*>("(O)"), arg_.ptr());
+ (PyObject*)&PyDict_Type, const_cast<char*>("(O)"),
+ arg_.ptr());
}
dict_base::dict_base()
diff --git a/libs/python/src/list.cpp b/libs/python/src/list.cpp
index 69f6da4..77e6168 100644
--- a/libs/python/src/list.cpp
+++ b/libs/python/src/list.cpp
@@ -10,11 +10,11 @@ namespace boost { namespace python { namespace detail {
detail::new_non_null_reference list_base::call(object const& arg_)
{
- union{ PyTypeObject *ptop; PyObject *pop; }pun = { &PyList_Type };
return (detail::new_non_null_reference)
(expect_non_null)(
PyObject_CallFunction(
- pun.pop, const_cast<char*>("(O)"), arg_.ptr()));
+ (PyObject*)&PyList_Type, const_cast<char*>("(O)"),
+ arg_.ptr()));
}
list_base::list_base()
diff --git a/libs/python/src/long.cpp b/libs/python/src/long.cpp
index fcba9d4..1ec8ebc 100644
--- a/libs/python/src/long.cpp
+++ b/libs/python/src/long.cpp
@@ -8,16 +8,16 @@ namespace boost { namespace python { namespace detail {
new_non_null_reference long_base::call(object const& arg_)
{
- union { PyTypeObject *ptop; PyObject *pop; }pun = { &PyLong_Type };
return (detail::new_non_null_reference)PyObject_CallFunction(
- pun.pop, const_cast<char*>("(O)"), arg_.ptr());
+ (PyObject*)&PyLong_Type, const_cast<char*>("(O)"),
+ arg_.ptr());
}
new_non_null_reference long_base::call(object const& arg_, object const& base)
{
- union { PyTypeObject *ptop; PyObject *pop; }pun = { &PyLong_Type };
return (detail::new_non_null_reference)PyObject_CallFunction(
- pun.pop, const_cast<char*>("(OO)"), arg_.ptr(), base.ptr());
+ (PyObject*)&PyLong_Type, const_cast<char*>("(OO)"),
+ arg_.ptr(), base.ptr());
}
long_base::long_base()
@@ -25,12 +25,7 @@ long_base::long_base()
detail::new_reference(
PyObject_CallFunction((PyObject*)&PyLong_Type, const_cast<char*>("()")))
)
-{
- union { PyTypeObject *ptop; PyObject *pop; }pun = { &PyLong_Type };
- object(detail::new_reference(
- PyObject_CallFunction(pun.pop, const_cast<char*>("()"))));
-}
-
+{}
long_base::long_base(object_cref arg)
: object(long_base::call(arg))
diff --git a/libs/python/src/object/class.cpp b/libs/python/src/object/class.cpp
index 179ec98..aeef688 100644
--- a/libs/python/src/object/class.cpp
+++ b/libs/python/src/object/class.cpp
@@ -616,11 +616,9 @@ namespace objects
void class_base::add_property(
char const* name, object const& fget, char const* docstr)
{
- union { PyTypeObject *ptop; PyObject *pop; }pun = { &PyProperty_Type };
-
object property(
(python::detail::new_reference)
- PyObject_CallFunction(pun.pop, const_cast<char*>("Osss"), fget.ptr(), 0, 0, docstr));
+ PyObject_CallFunction((PyObject*)&PyProperty_Type, const_cast<char*>("Osss"), fget.ptr(), 0, 0, docstr));
this->setattr(name, property);
}
@@ -628,11 +626,9 @@ namespace objects
void class_base::add_property(
char const* name, object const& fget, object const& fset, char const* docstr)
{
- union { PyTypeObject *ptop; PyObject *pop; }pun = { &PyProperty_Type };
-
object property(
(python::detail::new_reference)
- PyObject_CallFunction(pun.pop, const_cast<char*>("OOss"), fget.ptr(), fset.ptr(), 0, docstr));
+ PyObject_CallFunction((PyObject*)&PyProperty_Type, const_cast<char*>("OOss"), fget.ptr(), fset.ptr(), 0, docstr));
this->setattr(name, property);
}
diff --git a/libs/python/src/str.cpp b/libs/python/src/str.cpp
index 1b7e59c..0bc225a 100644
--- a/libs/python/src/str.cpp
+++ b/libs/python/src/str.cpp
@@ -9,14 +9,14 @@ namespace boost { namespace python { namespace detail {
detail::new_reference str_base::call(object const& arg_)
{
+ return (detail::new_reference)PyObject_CallFunction(
#if PY_VERSION_HEX >= 0x03000000
- union { PyTypeObject *ptop; PyObject *pop; }pun = { &PyUnicode_Type };
+ (PyObject*)&PyUnicode_Type,
#else
- union { PyTypeObject *ptop; PyObject *pop; }pun = { &PyString_Type };
+ (PyObject*)&PyString_Type,
#endif
-
- return (detail::new_reference)PyObject_CallFunction(
- pun.pop, const_cast<char*>("(O)"), arg_.ptr());
+ const_cast<char*>("(O)"),
+ arg_.ptr());
}
str_base::str_base()
diff --git a/libs/python/src/tuple.cpp b/libs/python/src/tuple.cpp
index 1c38d90..6719713 100644
--- a/libs/python/src/tuple.cpp
+++ b/libs/python/src/tuple.cpp
@@ -8,10 +8,9 @@ namespace boost { namespace python { namespace detail {
detail::new_reference tuple_base::call(object const& arg_)
{
- union { PyTypeObject *ptop; PyObject *pop; }pun = { &PyTuple_Type };
-
return (detail::new_reference)PyObject_CallFunction(
- pun.pop, const_cast<char*>("(O)"), arg_.ptr());
+ (PyObject*)&PyTuple_Type, const_cast<char*>("(O)"),
+ arg_.ptr());
}
tuple_base::tuple_base()