From 385830424043c81945a21ca14e051e3b4c282829 Mon Sep 17 00:00:00 2001 From: Dwayne Litzenberger Date: Sun, 14 Jul 2013 18:48:59 -0700 Subject: Py3k cleanup: Remove PyModule_GetDict Also rename _fastmath_module -> m for consistency --- src/_fastmath.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/_fastmath.c b/src/_fastmath.c index 565d2aa..063ad70 100644 --- a/src/_fastmath.c +++ b/src/_fastmath.c @@ -1598,36 +1598,34 @@ PyInit__fastmath (void) init_fastmath (void) #endif { - PyObject *_fastmath_module; - PyObject *_fastmath_dict; - + PyObject *m; + #ifdef IS_PY3K if (PyType_Ready(&rsaKeyType) < 0) return NULL; if (PyType_Ready(&dsaKeyType) < 0) return NULL; - _fastmath_module = PyModule_Create(&moduledef); - if (_fastmath_module == NULL) + m = PyModule_Create(&moduledef); + if (m == NULL) return NULL; #else if (PyType_Ready(&rsaKeyType) < 0) return; if (PyType_Ready(&dsaKeyType) < 0) return; - _fastmath_module = Py_InitModule ("_fastmath", _fastmath__methods__); + m = Py_InitModule ("_fastmath", _fastmath__methods__); #endif - _fastmath_dict = PyModule_GetDict (_fastmath_module); fastmathError = PyErr_NewException ("_fastmath.error", NULL, NULL); #ifdef IS_PY3K if (fastmathError == NULL) return NULL; #endif - PyDict_SetItemString (_fastmath_dict, "error", fastmathError); + PyObject_SetAttrString(m, "error", fastmathError); - PyModule_AddIntConstant(_fastmath_module, "HAVE_DECL_MPZ_POWM_SEC", HAVE_DECL_MPZ_POWM_SEC); + PyModule_AddIntConstant(m, "HAVE_DECL_MPZ_POWM_SEC", HAVE_DECL_MPZ_POWM_SEC); #ifdef IS_PY3K - return _fastmath_module; + return m; #endif } -- cgit v1.2.1