Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4edc5eb

Browse files
committed
Reversed the order of the checks for None or a Dialog where a Window is expected so it doesn't crash under OSX/Mach-o.
1 parent c65218e commit 4edc5eb

2 files changed

Lines changed: 8 additions & 22 deletions

File tree

Mac/Modules/win/Winmodule.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ PyObject *WinObj_New(WindowPtr itself)
7676
}
7777
WinObj_Convert(PyObject *v, WindowPtr *p_itself)
7878
{
79-
#if 1
79+
80+
if (v == Py_None) { *p_itself = NULL; return 1; }
81+
if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
82+
8083
{
8184
DialogRef dlg;
8285
if (DlgObj_Convert(v, &dlg) && dlg) {
@@ -85,16 +88,6 @@ WinObj_Convert(PyObject *v, WindowPtr *p_itself)
8588
}
8689
PyErr_Clear();
8790
}
88-
#else
89-
if (DlgObj_Check(v)) {
90-
*p_itself = DlgObj_ConvertToWindow(v);
91-
return 1;
92-
}
93-
#endif
94-
95-
if (v == Py_None) { *p_itself = NULL; return 1; }
96-
if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
97-
9891
if (!WinObj_Check(v))
9992
{
10093
PyErr_SetString(PyExc_TypeError, "Window required");

Mac/Modules/win/winsupport.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ def outputInitStructMembers(self):
137137
Output("it->ob_freeit = PyMac_AutoDisposeWindow;")
138138
OutRbrace()
139139
def outputCheckConvertArg(self):
140-
Output("#if 1")
140+
Out("""
141+
if (v == Py_None) { *p_itself = NULL; return 1; }
142+
if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
143+
""")
141144
OutLbrace()
142145
Output("DialogRef dlg;")
143146
OutLbrace("if (DlgObj_Convert(v, &dlg) && dlg)")
@@ -146,16 +149,6 @@ def outputCheckConvertArg(self):
146149
OutRbrace()
147150
Output("PyErr_Clear();")
148151
OutRbrace()
149-
Output("#else")
150-
OutLbrace("if (DlgObj_Check(v))")
151-
Output("*p_itself = DlgObj_ConvertToWindow(v);")
152-
Output("return 1;")
153-
OutRbrace()
154-
Output("#endif")
155-
Out("""
156-
if (v == Py_None) { *p_itself = NULL; return 1; }
157-
if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
158-
""")
159152
def outputCleanupStructMembers(self):
160153
Output("if (self->ob_freeit && self->ob_itself)")
161154
OutLbrace()

0 commit comments

Comments
 (0)