Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2422870

Browse files
Exceptions doc: add Py_INCREF after creating new exception types
See best practice example in Python source: https://github.com/python/cpython/blob/master/Modules/_testcapimodule.c#L6733
1 parent 55095f9 commit 2422870

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

‎doc/sphinx/source/exceptions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ Often you need to create an Exception class that is specialised to a particular
184184
if (! ExceptionBase) {
185185
return NULL;
186186
} else {
187+
Py_INCREF(ExceptionBase);
187188
PyModule_AddObject(m, "ExceptionBase", ExceptionBase);
188189
}
189190
/* Now a sub-class exception that inherits from the base exception above.
@@ -199,6 +200,7 @@ Often you need to create an Exception class that is specialised to a particular
199200
if (! SpecialisedError) {
200201
return NULL;
201202
} else {
203+
Py_INCREF(SpecialisedError);
202204
PyModule_AddObject(m, "SpecialisedError", SpecialisedError);
203205
}
204206
/* END: Initialise exceptions here. */

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /