aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/tests/samplebinding
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/tests/samplebinding')
-rw-r--r--sources/shiboken2/tests/samplebinding/CMakeLists.txt3
-rw-r--r--sources/shiboken2/tests/samplebinding/bytearray_bufferprotocol.cpp2
-rw-r--r--sources/shiboken2/tests/samplebinding/namespace_test.py20
-rw-r--r--sources/shiboken2/tests/samplebinding/typesystem_sample.xml4
4 files changed, 15 insertions, 14 deletions
diff --git a/sources/shiboken2/tests/samplebinding/CMakeLists.txt b/sources/shiboken2/tests/samplebinding/CMakeLists.txt
index 78ddfca0..32117e44 100644
--- a/sources/shiboken2/tests/samplebinding/CMakeLists.txt
+++ b/sources/shiboken2/tests/samplebinding/CMakeLists.txt
@@ -136,7 +136,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}
${SBK_PYTHON_INCLUDE_DIR}
${libsample_SOURCE_DIR}
- ${libshiboken_SOURCE_DIR})
+ ${libshiboken_SOURCE_DIR}
+ ${libshiboken_BINARY_DIR})
add_library(sample MODULE ${sample_SRC})
set_property(TARGET sample PROPERTY PREFIX "")
set_property(TARGET sample PROPERTY OUTPUT_NAME "sample${PYTHON_EXTENSION_SUFFIX}")
diff --git a/sources/shiboken2/tests/samplebinding/bytearray_bufferprotocol.cpp b/sources/shiboken2/tests/samplebinding/bytearray_bufferprotocol.cpp
index 8f01b4a0..32238708 100644
--- a/sources/shiboken2/tests/samplebinding/bytearray_bufferprotocol.cpp
+++ b/sources/shiboken2/tests/samplebinding/bytearray_bufferprotocol.cpp
@@ -33,7 +33,7 @@ extern "C" {
static Py_ssize_t SbkByteArray_segcountproc(PyObject* self, Py_ssize_t* lenp)
{
if (lenp)
- *lenp = self->ob_type->tp_as_sequence->sq_length(self);
+ *lenp = Py_TYPE(self)->tp_as_sequence->sq_length(self);
return 1;
}
static Py_ssize_t SbkByteArray_readbufferproc(PyObject* self, Py_ssize_t segment, void** ptrptr)
diff --git a/sources/shiboken2/tests/samplebinding/namespace_test.py b/sources/shiboken2/tests/samplebinding/namespace_test.py
index a5065c7a..5fcdab97 100644
--- a/sources/shiboken2/tests/samplebinding/namespace_test.py
+++ b/sources/shiboken2/tests/samplebinding/namespace_test.py
@@ -33,12 +33,7 @@
import unittest
from sample import *
-from py3kcompat import IS_PY3K
-if IS_PY3K:
- TYPE_STR = "class"
-else:
- TYPE_STR = "type"
class TestEnumUnderNamespace(unittest.TestCase):
def testInvisibleNamespace(self):
@@ -59,11 +54,16 @@ class TestClassesUnderNamespace(unittest.TestCase):
self.assertEqual(res, 4)
def testTpNames(self):
- self.assertEqual(str(SampleNamespace.SomeClass), "<%s 'sample.SampleNamespace.SomeClass'>"%TYPE_STR)
- self.assertEqual(str(SampleNamespace.SomeClass.ProtectedEnum), "<%s 'sample.SampleNamespace.SomeClass.ProtectedEnum'>"%TYPE_STR)
- self.assertEqual(str(SampleNamespace.SomeClass.SomeInnerClass.ProtectedEnum), "<%s 'sample.SampleNamespace.SomeClass.SomeInnerClass.ProtectedEnum'>"%TYPE_STR)
- self.assertEqual(str(SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough), "<%s 'sample.SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough'>"%TYPE_STR)
- self.assertEqual(str(SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough.NiceEnum), "<%s 'sample.SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough.NiceEnum'>"%TYPE_STR)
+ self.assertEqual(str(SampleNamespace.SomeClass),
+ "<class 'sample.SampleNamespace.SomeClass'>")
+ self.assertEqual(str(SampleNamespace.SomeClass.ProtectedEnum),
+ "<class 'sample.SampleNamespace.SomeClass.ProtectedEnum'>")
+ self.assertEqual(str(SampleNamespace.SomeClass.SomeInnerClass.ProtectedEnum),
+ "<class 'sample.SampleNamespace.SomeClass.SomeInnerClass.ProtectedEnum'>")
+ self.assertEqual(str(SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough),
+ "<class 'sample.SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough'>")
+ self.assertEqual(str(SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough.NiceEnum),
+ "<class 'sample.SampleNamespace.SomeClass.SomeInnerClass.OkThisIsRecursiveEnough.NiceEnum'>")
if __name__ == '__main__':
unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
index 3cc80860..5f0a9206 100644
--- a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
+++ b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
@@ -1666,7 +1666,7 @@
Tested in InjectCodeTest.testTypeNativeBeginning_TypeTargetBeginning:
-->
<inject-code class="target" position="beginning">
- %PYTHONTYPEOBJECT.tp_str = InjectCode_tpstr;
+ PepType(&amp;%PYTHONTYPEOBJECT)->tp_str = InjectCode_tpstr;
</inject-code>
<!-- Tested in InjectCodeTest.testFunctionTargetBeginning_FunctionTargetEnd -->
@@ -2178,7 +2178,7 @@
</add-function>
<add-function signature="__repr__" return-type="PyObject*">
<inject-code class="target" position="beginning">
- ByteArray b(((PyObject*)%PYSELF)->ob_type->tp_name);
+ ByteArray b(PepType(Py_TYPE(%PYSELF))->tp_name);
PyObject* aux = Shiboken::String::fromStringAndSize(%CPPSELF.data(), %CPPSELF.size());
if (PyUnicode_CheckExact(aux)) {
PyObject* tmp = PyUnicode_AsASCIIString(aux);