Skip to content

Commit 589c35b

Browse files
committed
Python 2.0 is not supposed to use string exceptions in the standard library
& extensions, so create exceptions in extension modules using the PyErr_NewException() API.
1 parent 2806782 commit 589c35b

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

Modules/_cursesmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,7 @@ init_curses()
23292329
ModDict = d; /* For PyCurses_InitScr */
23302330

23312331
/* For exception curses.error */
2332-
PyCursesError = PyString_FromString("_curses.error");
2332+
PyCursesError = PyErr_NewException("_curses.error", NULL, NULL);
23332333
PyDict_SetItemString(d, "error", PyCursesError);
23342334

23352335
/* Make the version available */

Modules/almodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2195,7 +2195,7 @@ inital()
21952195

21962196
/* Add some symbolic constants to the module */
21972197
d = PyModule_GetDict(m);
2198-
ErrorObject = PyString_FromString("al.error");
2198+
ErrorObject = PyErr_NewException("al.error", NULL, NULL);
21992199
PyDict_SetItemString(d, "error", ErrorObject);
22002200

22012201
/* XXXX Add constants here */

Modules/pcremodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ initpcre()
654654

655655
/* Add some symbolic constants to the module */
656656
d = PyModule_GetDict(m);
657-
ErrorObject = PyString_FromString("pcre.error");
657+
ErrorObject = PyErr_NewException("pcre.error", NULL, NULL);
658658
PyDict_SetItemString(d, "error", ErrorObject);
659659

660660
/* Insert the flags */

0 commit comments

Comments
 (0)