diff options
author | Christian Tismer <tismer@stackless.com> | 2017-12-17 19:12:56 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2018-05-30 18:13:41 +0000 |
commit | 18dc31becdd994c53a9f894087cf1ef99fbd0232 (patch) | |
tree | 3021cfa473f20102bfb63a26117776615b91b526 /sources/shiboken2/tests | |
parent | 50dd4ae202d7afb3556335c056db003f5ef50532 (diff) |
PEP 384-squash: Implement PEP 384
This is the condensed checkin of 18 commits which created
the implementation of PEP 384.
Task-number: PYSIDE-560
Change-Id: I834c659af4c2b55b268f8e8dc4cfa53f02502409
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/tests')
7 files changed, 21 insertions, 17 deletions
diff --git a/sources/shiboken2/tests/minimalbinding/CMakeLists.txt b/sources/shiboken2/tests/minimalbinding/CMakeLists.txt index 7edb0290a..b8b6417d1 100644 --- a/sources/shiboken2/tests/minimalbinding/CMakeLists.txt +++ b/sources/shiboken2/tests/minimalbinding/CMakeLists.txt @@ -26,7 +26,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} ${SBK_PYTHON_INCLUDE_DIR} ${libminimal_SOURCE_DIR} - ${libshiboken_SOURCE_DIR}) + ${libshiboken_SOURCE_DIR} + ${libshiboken_BINARY_DIR}) add_library(minimal MODULE ${minimal_SRC}) set_property(TARGET minimal PROPERTY PREFIX "") set_property(TARGET minimal PROPERTY OUTPUT_NAME "minimal${PYTHON_EXTENSION_SUFFIX}") diff --git a/sources/shiboken2/tests/otherbinding/CMakeLists.txt b/sources/shiboken2/tests/otherbinding/CMakeLists.txt index 7d4dd5b55..186766b41 100644 --- a/sources/shiboken2/tests/otherbinding/CMakeLists.txt +++ b/sources/shiboken2/tests/otherbinding/CMakeLists.txt @@ -32,7 +32,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${libsample_SOURCE_DIR}/.. ${sample_BINARY_DIR} ${sample_BINARY_DIR}/sample - ${libshiboken_SOURCE_DIR}) + ${libshiboken_SOURCE_DIR} + ${libshiboken_BINARY_DIR}) add_library(other MODULE ${other_SRC}) set_property(TARGET other PROPERTY PREFIX "") set_property(TARGET other PROPERTY OUTPUT_NAME "other${PYTHON_EXTENSION_SUFFIX}") diff --git a/sources/shiboken2/tests/samplebinding/CMakeLists.txt b/sources/shiboken2/tests/samplebinding/CMakeLists.txt index 78ddfca0a..32117e44a 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 8f01b4a0a..322387088 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 a5065c7a6..5fcdab974 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 3cc80860d..5f0a9206b 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(&%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); diff --git a/sources/shiboken2/tests/smartbinding/CMakeLists.txt b/sources/shiboken2/tests/smartbinding/CMakeLists.txt index aab2121d3..faaa797b6 100644 --- a/sources/shiboken2/tests/smartbinding/CMakeLists.txt +++ b/sources/shiboken2/tests/smartbinding/CMakeLists.txt @@ -27,7 +27,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} ${SBK_PYTHON_INCLUDE_DIR} ${libsmart_SOURCE_DIR} - ${libshiboken_SOURCE_DIR}) + ${libshiboken_SOURCE_DIR} + ${libshiboken_BINARY_DIR}) add_library(smart MODULE ${smart_SRC}) set_property(TARGET smart PROPERTY PREFIX "") set_property(TARGET smart PROPERTY OUTPUT_NAME "smart${PYTHON_EXTENSION_SUFFIX}") |