mirror of
https://github.com/python/cpython.git
synced 2025-11-10 06:24:12 +00:00
use PyModule_Add{Int,String}Constant() where appropriate
(thanks to Neal Norwitz for the code review, BTW)
This commit is contained in:
parent
577c7a763d
commit
7b01a83488
1 changed files with 6 additions and 12 deletions
|
|
@ -12,6 +12,8 @@ module instead.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define MODULE_VERSION "1.0"
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "structmember.h"
|
#include "structmember.h"
|
||||||
|
|
||||||
|
|
@ -1440,9 +1442,6 @@ PyMODINIT_FUNC
|
||||||
init_csv(void)
|
init_csv(void)
|
||||||
{
|
{
|
||||||
PyObject *module;
|
PyObject *module;
|
||||||
PyObject *rev;
|
|
||||||
PyObject *v;
|
|
||||||
int res;
|
|
||||||
StyleDesc *style;
|
StyleDesc *style;
|
||||||
|
|
||||||
if (PyType_Ready(&Dialect_Type) < 0)
|
if (PyType_Ready(&Dialect_Type) < 0)
|
||||||
|
|
@ -1460,10 +1459,8 @@ init_csv(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Add version to the module. */
|
/* Add version to the module. */
|
||||||
rev = PyString_FromString("1.0");
|
if (PyModule_AddStringConstant(module, "__version__",
|
||||||
if (rev == NULL)
|
MODULE_VERSION) == -1)
|
||||||
return;
|
|
||||||
if (PyModule_AddObject(module, "__version__", rev) < 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Add _dialects dictionary */
|
/* Add _dialects dictionary */
|
||||||
|
|
@ -1475,11 +1472,8 @@ init_csv(void)
|
||||||
|
|
||||||
/* Add quote styles into dictionary */
|
/* Add quote styles into dictionary */
|
||||||
for (style = quote_styles; style->name; style++) {
|
for (style = quote_styles; style->name; style++) {
|
||||||
v = PyInt_FromLong(style->style);
|
if (PyModule_AddIntConstant(module, style->name,
|
||||||
if (v == NULL)
|
style->style) == -1)
|
||||||
return;
|
|
||||||
res = PyModule_AddObject(module, style->name, v);
|
|
||||||
if (res < 0)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue