mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
parent
b840ad7f5c
commit
8cbb23cf09
@ -56,7 +56,7 @@ based on the following rules:
|
||||
if ( sipCanConvertToType( a0, sipType_QgsPointXY, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
|
||||
{
|
||||
int state;
|
||||
int sipIsErr = 0;
|
||||
sipIsErr = 0;
|
||||
|
||||
QgsPointXY *p = reinterpret_cast<QgsPointXY *>( sipConvertToType( a0, sipType_QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
|
||||
if ( sipIsErr )
|
||||
@ -71,7 +71,7 @@ based on the following rules:
|
||||
else if ( sipCanConvertToType( a0, sipType_QPointF, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
|
||||
{
|
||||
int state;
|
||||
int sipIsErr = 0;
|
||||
sipIsErr = 0;
|
||||
|
||||
QPointF *p = reinterpret_cast<QPointF *>( sipConvertToType( a0, sipType_QPointF, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
|
||||
if ( sipIsErr )
|
||||
@ -97,6 +97,11 @@ based on the following rules:
|
||||
QgsWkbTypes::Type wkbType = a4 == Py_None ? QgsWkbTypes::Unknown : static_cast<QgsWkbTypes::Type>( sipConvertToEnum( a4, sipType_QgsWkbTypes_Type ) );
|
||||
sipCpp = new sipQgsPoint( QgsPoint( x, y, z, m, wkbType ) );
|
||||
}
|
||||
else // Invalid ctor arguments
|
||||
{
|
||||
PyErr_SetString( PyExc_TypeError, QStringLiteral( "Invalid type in constructor arguments." ).toUtf8().constData() );
|
||||
sipIsErr = 1;
|
||||
}
|
||||
%End
|
||||
|
||||
|
||||
|
@ -78,7 +78,7 @@ class CORE_EXPORT QgsPoint: public QgsAbstractGeometry
|
||||
if ( sipCanConvertToType( a0, sipType_QgsPointXY, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
|
||||
{
|
||||
int state;
|
||||
int sipIsErr = 0;
|
||||
sipIsErr = 0;
|
||||
|
||||
QgsPointXY *p = reinterpret_cast<QgsPointXY *>( sipConvertToType( a0, sipType_QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
|
||||
if ( sipIsErr )
|
||||
@ -93,7 +93,7 @@ class CORE_EXPORT QgsPoint: public QgsAbstractGeometry
|
||||
else if ( sipCanConvertToType( a0, sipType_QPointF, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
|
||||
{
|
||||
int state;
|
||||
int sipIsErr = 0;
|
||||
sipIsErr = 0;
|
||||
|
||||
QPointF *p = reinterpret_cast<QPointF *>( sipConvertToType( a0, sipType_QPointF, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
|
||||
if ( sipIsErr )
|
||||
@ -119,6 +119,11 @@ class CORE_EXPORT QgsPoint: public QgsAbstractGeometry
|
||||
QgsWkbTypes::Type wkbType = a4 == Py_None ? QgsWkbTypes::Unknown : static_cast<QgsWkbTypes::Type>( sipConvertToEnum( a4, sipType_QgsWkbTypes_Type ) );
|
||||
sipCpp = new sipQgsPoint( QgsPoint( x, y, z, m, wkbType ) );
|
||||
}
|
||||
else // Invalid ctor arguments
|
||||
{
|
||||
PyErr_SetString( PyExc_TypeError, QStringLiteral( "Invalid type in constructor arguments." ).toUtf8().constData() );
|
||||
sipIsErr = 1;
|
||||
}
|
||||
% End
|
||||
#endif
|
||||
|
||||
|
@ -87,5 +87,18 @@ class TestQgsPointXY(unittest.TestCase):
|
||||
assert p.wkbType() == QgsWkbTypes.PointZM and p.x() == 1 and p.y() == 2 and p.z() == 3 and p.m() == 4
|
||||
|
||||
|
||||
class TestQgsPoint(unittest.TestCase):
|
||||
|
||||
def testInvalidConstructorArguments(self):
|
||||
"""Test GH #34557"""
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
point_0 = QgsPoint('a string')
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
point_a = QgsPoint(10, 20)
|
||||
point_b = QgsPoint(point_a)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user