Fixed the equality and inequality operators for some of the basic
data types (wx.Point, wx.Size, wx.Colour, etc.) to no longer raise a TypeError if the compared object is not compatible, but to just return a boolean as expected. For example:: wx.Colour(64,0,64) == 123 ==> False git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38493 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -106,14 +106,32 @@ COLORREF is returned. On X, an allocated pixel value is returned. -1
|
||||
is returned if the pixel is invalid (on X, unallocated).", "");
|
||||
|
||||
|
||||
DocDeclStr(
|
||||
bool , operator==(const wxColour& colour) const,
|
||||
"Compare colours for equality", "");
|
||||
|
||||
DocDeclStr(
|
||||
bool , operator!=(const wxColour& colour) const,
|
||||
"Compare colours for inequality", "");
|
||||
|
||||
%extend {
|
||||
KeepGIL(__eq__);
|
||||
DocStr(__eq__, "Compare colours for equality.", "");
|
||||
bool __eq__(PyObject* other) {
|
||||
wxColour temp, *obj = &temp;
|
||||
if ( other == Py_None ) return false;
|
||||
if ( ! wxColour_helper(other, &obj) ) {
|
||||
PyErr_Clear();
|
||||
return false;
|
||||
}
|
||||
return self->operator==(*obj);
|
||||
}
|
||||
|
||||
|
||||
KeepGIL(__ne__);
|
||||
DocStr(__ne__, "Compare colours for inequality.", "");
|
||||
bool __ne__(PyObject* other) {
|
||||
wxColour temp, *obj = &temp;
|
||||
if ( other == Py_None ) return true;
|
||||
if ( ! wxColour_helper(other, &obj)) {
|
||||
PyErr_Clear();
|
||||
return true;
|
||||
}
|
||||
return self->operator!=(*obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%extend {
|
||||
|
Reference in New Issue
Block a user