Tighten up allowed types in auto sequence conversions

Instead of allowing generic sequences to be convertible to wxPoint, wxSize, and others, explicitly allow only tuples and lists.  This is needed because these types also have methods that make them look like sequences, which meant that you could pass a wxSize where a wxPoint is expected, and so on.

Even worse is nonsense stuff like:

    wx.Point(10,20) == wx.Size(10,20)

evaluating to True.
This commit is contained in:
Robin Dunn
2017-04-12 13:57:08 -07:00
parent 8ce1232758
commit b01729f4ef
5 changed files with 24 additions and 5 deletions

View File

@@ -626,7 +626,7 @@ def convertTwoIntegersTemplate(CLASS):
if (sipCanConvertToType(sipPy, sipType_{CLASS}, SIP_NO_CONVERTORS))
return 1;
if (PySequence_Check(sipPy) && PySequence_Size(sipPy) == 2) {{
if ((PyTuple_Check(sipPy) || PyList_Check(sipPy)) && PySequence_Size(sipPy) == 2) {{
int rval = 1;
PyObject* o1 = PySequence_ITEM(sipPy, 0);
PyObject* o2 = PySequence_ITEM(sipPy, 1);
@@ -666,7 +666,7 @@ def convertFourIntegersTemplate(CLASS):
if (sipCanConvertToType(sipPy, sipType_{CLASS}, SIP_NO_CONVERTORS))
return 1;
if (PySequence_Check(sipPy) && PySequence_Size(sipPy) == 4) {{
if ((PyTuple_Check(sipPy) || PyList_Check(sipPy)) && PySequence_Size(sipPy) == 4) {{
int rval = 1;
PyObject* o1 = PySequence_ITEM(sipPy, 0);
PyObject* o2 = PySequence_ITEM(sipPy, 1);
@@ -713,7 +713,7 @@ def convertTwoDoublesTemplate(CLASS):
if (sipCanConvertToType(sipPy, sipType_{CLASS}, SIP_NO_CONVERTORS))
return 1;
if (PySequence_Check(sipPy) && PySequence_Size(sipPy) == 2) {{
if ((PyTuple_Check(sipPy) || PyList_Check(sipPy)) && PySequence_Size(sipPy) == 2) {{
int rval = 1;
PyObject* o1 = PySequence_ITEM(sipPy, 0);
PyObject* o2 = PySequence_ITEM(sipPy, 1);
@@ -753,7 +753,7 @@ def convertFourDoublesTemplate(CLASS):
if (sipCanConvertToType(sipPy, sipType_{CLASS}, SIP_NO_CONVERTORS))
return 1;
if (PySequence_Check(sipPy) && PySequence_Size(sipPy) == 4) {{
if ((PyTuple_Check(sipPy) || PyList_Check(sipPy)) && PySequence_Size(sipPy) == 4) {{
int rval = 1;
PyObject* o1 = PySequence_ITEM(sipPy, 0);
PyObject* o2 = PySequence_ITEM(sipPy, 1);