diff options
author | Skip Montanaro <skip@pobox.com> | 2003-04-12 19:23:46 (GMT) |
---|---|---|
committer | Skip Montanaro <skip@pobox.com> | 2003-04-12 19:23:46 (GMT) |
commit | 7b01a83488ebe1969b416d579e7df58576bb3c44 (patch) | |
tree | bff7b8974122848905c4b124b271f937d89c3ef2 | |
parent | 577c7a763d6ce04bb23467a9b56d3b4276b480b3 (diff) | |
download | cpython-7b01a83488ebe1969b416d579e7df58576bb3c44.zip cpython-7b01a83488ebe1969b416d579e7df58576bb3c44.tar.gz cpython-7b01a83488ebe1969b416d579e7df58576bb3c44.tar.bz2 |
use PyModule_Add{Int,String}Constant() where appropriate
(thanks to Neal Norwitz for the code review, BTW)
-rw-r--r-- | Modules/_csv.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c index 8bee6df..07d368c 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -12,6 +12,8 @@ module instead. */ +#define MODULE_VERSION "1.0" + #include "Python.h" #include "structmember.h" @@ -1440,9 +1442,6 @@ PyMODINIT_FUNC init_csv(void) { PyObject *module; - PyObject *rev; - PyObject *v; - int res; StyleDesc *style; if (PyType_Ready(&Dialect_Type) < 0) @@ -1460,10 +1459,8 @@ init_csv(void) return; /* Add version to the module. */ - rev = PyString_FromString("1.0"); - if (rev == NULL) - return; - if (PyModule_AddObject(module, "__version__", rev) < 0) + if (PyModule_AddStringConstant(module, "__version__", + MODULE_VERSION) == -1) return; /* Add _dialects dictionary */ @@ -1475,11 +1472,8 @@ init_csv(void) /* Add quote styles into dictionary */ for (style = quote_styles; style->name; style++) { - v = PyInt_FromLong(style->style); - if (v == NULL) - return; - res = PyModule_AddObject(module, style->name, v); - if (res < 0) + if (PyModule_AddIntConstant(module, style->name, + style->style) == -1) return; } |