py3: Base: files R-Z ported to python3

issue 0000995
This commit is contained in:
Yorik van Havre
2017-05-18 19:31:32 +02:00
committed by wmayer
parent 769bc97f63
commit d4b7100bb2
5 changed files with 67 additions and 7 deletions

View File

@@ -131,8 +131,14 @@ PyObject* VectorPy::number_multiply_handler(PyObject *self, PyObject *other)
double b = PyFloat_AsDouble(other);
return new VectorPy(a * b);
}
else if (PyInt_Check(other)) {
long b = PyInt_AsLong(other);
#if PY_MAJOR_VERSION < 3
else if (PyInt_Check(other)) {
Base::Vector3d a = static_cast<VectorPy*>(self) ->value();
long b = PyInt_AsLong(other);
#else
else if (PyLong_Check(other)) {
long b = PyLong_AsLong(other);
#endif
return new VectorPy(a * (double)b);
}
else {
@@ -146,8 +152,13 @@ PyObject* VectorPy::number_multiply_handler(PyObject *self, PyObject *other)
double b = PyFloat_AsDouble(self);
return new VectorPy(a * b);
}
#if PY_MAJOR_VERSION >= 3
else if (PyLong_Check(self)) {
long b = PyLong_AsLong(self);
#else
else if (PyInt_Check(self)) {
long b = PyInt_AsLong(self);
#endif
return new VectorPy(a * (double)b);
}
else {
@@ -580,11 +591,13 @@ int VectorPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
return 0;
}
#if PY_MAJOR_VERSION < 3
PyObject * VectorPy::number_divide_handler (PyObject* /*self*/, PyObject* /*other*/)
{
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
return 0;
}
#endif
PyObject * VectorPy::number_remainder_handler (PyObject* /*self*/, PyObject* /*other*/)
{
@@ -663,10 +676,12 @@ PyObject * VectorPy::number_or_handler (PyObject* /*self*/, PyObject* /*other*/)
return 0;
}
#if PY_MAJOR_VERSION < 3
int VectorPy::number_coerce_handler (PyObject ** /*self*/, PyObject ** /*other*/)
{
return 1;
}
#endif
PyObject * VectorPy::number_int_handler (PyObject* /*self*/)
{
@@ -674,11 +689,13 @@ PyObject * VectorPy::number_int_handler (PyObject* /*self*/)
return 0;
}
#if PY_MAJOR_VERSION < 3
PyObject * VectorPy::number_long_handler (PyObject* /*self*/)
{
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
return 0;
}
#endif
PyObject * VectorPy::number_float_handler (PyObject* /*self*/)
{
@@ -686,6 +703,7 @@ PyObject * VectorPy::number_float_handler (PyObject* /*self*/)
return 0;
}
#if PY_MAJOR_VERSION < 3
PyObject * VectorPy::number_oct_handler (PyObject* /*self*/)
{
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
@@ -697,3 +715,4 @@ PyObject * VectorPy::number_hex_handler (PyObject* /*self*/)
PyErr_SetString(PyExc_NotImplementedError, "Not implemented");
return 0;
}
#endif