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

Skip to content

Commit 9502692

Browse files
committed
Return MacOS.Error in stead of RuntimeError in case of failure so the user
gets a reasonable explanation in stead of a large negative number.
1 parent c6a164b commit 9502692

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

Mac/Modules/gestaltmodule.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2525
/* Macintosh Gestalt interface */
2626

2727
#include "Python.h"
28+
#include "macglue.h"
2829

2930
#include <Types.h>
3031
#include <Gestalt.h>
@@ -47,12 +48,8 @@ gestalt_gestalt(self, args)
4748
}
4849
selector = *(OSType*)str;
4950
iErr = Gestalt ( selector, &response );
50-
if (iErr != 0) {
51-
char buf[100];
52-
sprintf(buf, "Gestalt error code %d", iErr);
53-
PyErr_SetString(PyExc_RuntimeError, buf);
54-
return NULL;
55-
}
51+
if (iErr != 0)
52+
return PyMac_Error(iErr);
5653
return PyInt_FromLong(response);
5754
}
5855

0 commit comments

Comments
 (0)