We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
From [email protected] on October 17, 2012 09:02:27
--- pacparser_py.c 2012-10-17 17:56:25.038235264 +0200 +++ pacparser_py.c.new 2012-10-17 17:51:57.648909350 +0200 @``@ -31,6 +31,22 @``@ #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None #endif
@``@
+#if PY_MAJOR_VERSION >= 3 + #define MOD_ERROR_VAL NULL + #define MOD_SUCCESS_VAL(val) val + #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void) + #define MOD_DEF(ob, name, doc, methods) + static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; + ob = PyModule_Create(&moduledef); +#else + #define MOD_ERROR_VAL + #define MOD_SUCCESS_VAL(val) + #define MOD_INIT(name) void init##name(void) + #define MOD_DEF(ob, name, doc, methods) + ob = Py_InitModule3(name, methods, doc); +#endif + static PyObject *PacparserError; // Initialize PAC parser. // @``@ -137,12 +153,14 @``@ {NULL, NULL, 0, NULL} };
-PyMODINIT_FUNC -init_pacparser(void) +MOD_INIT(_pacparser) { PyObject *m; - m = Py_InitModule("_pacparser", PpMethods); + MOD_DEF(m, "_pacparser", NULL, PpMethods) + if(m == NULL) + return MOD_ERROR_VAL; PacparserError = PyErr_NewException("pacparser.error", NULL, NULL); Py_INCREF(PacparserError); PyModule_AddObject(m, "error", PacparserError); + return MOD_SUCCESS_VAL(m); }
Original issue: http://code.google.com/p/pacparser/issues/detail?id=21
The text was updated successfully, but these errors were encountered:
From manugarg on April 14, 2013 23:00:02
Thanks a lot Paweł for the patch. I have committed it: https://code.google.com/p/pacparser/source/detail?r=2777fc745a8223886ddd9c017a6e5f6e681369ce
Status: Fixed
Sorry, something went wrong.
No branches or pull requests
From [email protected] on October 17, 2012 09:02:27
--- pacparser_py.c 2012-10-17 17:56:25.038235264 +0200
+++ pacparser_py.c.new 2012-10-17 17:51:57.648909350 +0200
@``@
-31,6 +31,22@``@
#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
#endif
+#if PY_MAJOR_VERSION >= 3
+ #define MOD_ERROR_VAL NULL
+ #define MOD_SUCCESS_VAL(val) val
+ #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void)
+ #define MOD_DEF(ob, name, doc, methods)
+ static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT, name, doc, -1, methods, };
+ ob = PyModule_Create(&moduledef);
+#else
+ #define MOD_ERROR_VAL
+ #define MOD_SUCCESS_VAL(val)
+ #define MOD_INIT(name) void init##name(void)
+ #define MOD_DEF(ob, name, doc, methods)
+ ob = Py_InitModule3(name, methods, doc);
+#endif
+
static PyObject *PacparserError;
// Initialize PAC parser.
//
@``@
-137,12 +153,14@``@
{NULL, NULL, 0, NULL}
};
-PyMODINIT_FUNC
-init_pacparser(void)
+MOD_INIT(_pacparser)
{
PyObject *m;
- m = Py_InitModule("_pacparser", PpMethods);
+ MOD_DEF(m, "_pacparser", NULL, PpMethods)
+ if(m == NULL)
+ return MOD_ERROR_VAL;
PacparserError = PyErr_NewException("pacparser.error", NULL, NULL);
Py_INCREF(PacparserError);
PyModule_AddObject(m, "error", PacparserError);
+ return MOD_SUCCESS_VAL(m);
}
Original issue: http://code.google.com/p/pacparser/issues/detail?id=21
The text was updated successfully, but these errors were encountered: