##// END OF EJS Templates
parsers: don't leak references to sys et al in check_python_version...
Augie Fackler -
r23943:5fb44983 stable
parent child Browse files
Show More
@@ -2267,8 +2267,16 b' static void module_init(PyObject *mod)'
2267
2267
2268 static int check_python_version(void)
2268 static int check_python_version(void)
2269 {
2269 {
2270 PyObject *sys = PyImport_ImportModule("sys");
2270 PyObject *sys = PyImport_ImportModule("sys"), *ver;
2271 long hexversion = PyInt_AsLong(PyObject_GetAttrString(sys, "hexversion"));
2271 long hexversion;
2272 if (!sys)
2273 return -1;
2274 ver = PyObject_GetAttrString(sys, "hexversion");
2275 Py_DECREF(sys);
2276 if (!ver)
2277 return -1;
2278 hexversion = PyInt_AsLong(ver);
2279 Py_DECREF(ver);
2272 /* sys.hexversion is a 32-bit number by default, so the -1 case
2280 /* sys.hexversion is a 32-bit number by default, so the -1 case
2273 * should only occur in unusual circumstances (e.g. if sys.hexversion
2281 * should only occur in unusual circumstances (e.g. if sys.hexversion
2274 * is manually set to an invalid value). */
2282 * is manually set to an invalid value). */
General Comments 0
You need to be logged in to leave comments. Login now