diff options
| author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-22 22:24:54 +0200 |
|---|---|---|
| committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-22 22:24:54 +0200 |
| commit | 1c8f059019d79f1891f42a2656a96919a1187967 (patch) | |
| tree | bcec768e9ca0d0e1e9e1ab80e0dfc0fe29ae758d /Modules/grpmodule.c | |
| parent | 2a545099f7ed45de1d45b45200d82c6298b75d2b (diff) | |
| download | cpython-git-1c8f059019d79f1891f42a2656a96919a1187967.tar.gz | |
Issue #18520: Add a new PyStructSequence_InitType2() function, same than
PyStructSequence_InitType() except that it has a return value (0 on success,
-1 on error).
* PyStructSequence_InitType2() now raises MemoryError on memory allocation failure
* Fix also some calls to PyDict_SetItemString(): handle error
Diffstat (limited to 'Modules/grpmodule.c')
| -rw-r--r-- | Modules/grpmodule.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c index f85cdd46fc..73596d3374 100644 --- a/Modules/grpmodule.c +++ b/Modules/grpmodule.c @@ -210,9 +210,14 @@ PyInit_grp(void) if (m == NULL) return NULL; d = PyModule_GetDict(m); - if (!initialized) - PyStructSequence_InitType(&StructGrpType, &struct_group_type_desc); - PyDict_SetItemString(d, "struct_group", (PyObject *) &StructGrpType); + if (!initialized) { + if (PyStructSequence_InitType2(&StructGrpType, + &struct_group_type_desc) < 0) + return NULL; + } + if (PyDict_SetItemString(d, "struct_group", + (PyObject *)&StructGrpType) < 0) + return NULL; initialized = 1; return m; } |
