[pywin32-bugs] [ pywin32-Bugs-723837 ] PyHANDLE destructor triggers a SystemError
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2003-04-18 19:03:14
|
Bugs item #723837, was opened at 2003-04-18 19:03 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=723837&group_id=78018 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Jason Orendorff (jorend) Assigned to: Nobody/Anonymous (nobody) Summary: PyHANDLE destructor triggers a SystemError Initial Comment: This code is in PyHANDLE.cpp: /*static*/ void PyHANDLE::deallocFunc(PyObject *ob) { // Call virtual method Close ((PyHANDLE *)ob)->Close(); PyErr_Clear(); // can not leave pending exceptions in destructors. delete (PyHANDLE *)ob; } If this is called because an unrelated exception occurred, it incorrectly clears the exception. For example, suppose I have Python code that calls a Python function f1(). This function successfully creates a PyHANDLE, stores it in a local varaible, and then raises an unrelated exception. The caller, f2(), catches the exception. At this point, the PyHANDLE still exists because the traceback object has a reference to it (indirectly). Now suppose f2() throws an exception. The previous traceback object is now released (replaced by the new traceback). The PyHANDLE object is decref'd and freed. PyHANDLE::deallocFunc() is called. The exception that f2() threw is now cleared. This results in a SystemError. The attached test case reproduces it. I think it should be if (!((PyHANDLE *)ob)->Close()) PyErr_Clear(); but I'm not sure. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=723837&group_id=78018 |