Xavier de Gaye added the comment:

> out can be b'Done.\r\n'. Use self.assertIn.

Ok, new patch attached.


>> If both patches were to be included, the test case in warn_4.patch would 
>> test the above patch and not the changes made in Python/_warnings.c.
> You can test err for warning message.

In the case where PyExc_RecursionErrorInst would not leak frames, the code path 
followed by the test case would not run any of the changes made in _warnings.c.


> The traceback should be cleared before decrementing the reference count. And 
> only if Py_REFCNT(v) is 2.

I believe that attempting to fix the frames leak by clearing the traceback 
implies the following changes:
    * The previous patch to PyErr_PrintEx()
    * v->context and v->cause should also be tested against equality with 
PyExc_RecursionErrorInst.
    * In PyErr_PrintEx() the variable v2 may also be PyExc_RecursionErrorInst.
    * The sames change should also be done when freeing the exception value at 
least:
        in PyErr_WriteUnraisable() called when an exception occurs during 
finalization
        in PyErr_Restore()
        [1] when sys.last_value is cleared in PyImport_Cleanup()
And that would miss the case [1] where sys.last_value is set to None by some 
python user code.

Note [1]:
Unless it is acceptable to clear the PyExc_RecursionErrorInst traceback even 
when sys.last_value has been set (then Py_REFCNT(v) is 3 instead of 2).

Not sure if this is worth the trouble.

----------
Added file: http://bugs.python.org/file37289/warn_5.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22898>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to