[issue23890] assertRaises increases reference counter

2017-06-15 Thread STINNER Victor

Changes by STINNER Victor :


--
resolution:  -> fixed
stage: commit review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2017-06-15 Thread STINNER Victor

STINNER Victor added the comment:

Thank you Vjacheslav Fyodorov for your bug report! The bug should now be fixed 
in 3.5, 3.6 and master (future 3.7) branches.

Python 2.7 is not affected by the bug.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2017-06-15 Thread STINNER Victor

STINNER Victor added the comment:


New changeset 3dc573c8d19dc42ed786ca3237afdad183c41ca0 by Victor Stinner in 
branch '3.5':
Fix ref cycles in TestCase.assertRaises() (#193) (#2228)
https://github.com/python/cpython/commit/3dc573c8d19dc42ed786ca3237afdad183c41ca0


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2017-06-15 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +2273

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2017-06-15 Thread STINNER Victor

STINNER Victor added the comment:


New changeset 50dbf577e10f806056d60ac956db0748d2cc8257 by Victor Stinner in 
branch '3.6':
bpo-23890: Fix ref cycle in TestCase.assertRaises (#858)
https://github.com/python/cpython/commit/50dbf577e10f806056d60ac956db0748d2cc8257


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2017-03-27 Thread STINNER Victor

STINNER Victor added the comment:

It seems like Python 2.7 is not affected.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2017-03-27 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +761

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2017-03-27 Thread STINNER Victor

STINNER Victor added the comment:


New changeset bbd3cf8f1ef1e91a8d6dac6411e18b4b9084abf5 by Victor Stinner in 
branch 'master':
Fix ref cycles in TestCase.assertRaises() (#193)
https://github.com/python/cpython/commit/bbd3cf8f1ef1e91a8d6dac6411e18b4b9084abf5


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2017-02-23 Thread Nick Coghlan

Nick Coghlan added the comment:

Victor's PR takes a more pragmatic approach to address this problem: rather 
than adding the ability to clear the frames for an arbitrary exception tree, it 
just uses a try/finally in a couple of key unittest function definitions to 
clear the offending circular references by setting them to None.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2017-02-23 Thread Nick Coghlan

Changes by Nick Coghlan :


--
stage: needs patch -> commit review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2017-02-20 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +160

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2017-02-18 Thread Nick Coghlan

Nick Coghlan added the comment:

I've been looking into this further, and a reproducer that's independent of 
assertRaises() is to just bind the function to a local variable name in an 
outer function:

def outer():
callable_obj = f
try:
callable_obj()
except Exception as exc:
return exc

That should make it easier to test a basic recursive "clear_all_frames" 
operation like:

def clear_all_frames(exc):
cause = exc.__cause__
if cause is not None:
clear_all_frames(cause)
context = exc.__context__
if context is not None:
clear_all_frames(context)
traceback.clear_frames(exc.__traceback__)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2017-02-18 Thread Nick Coghlan

Nick Coghlan added the comment:

As Robert noted, this is a straight up error, where the clear_frames() call and 
deleting the exception traceback from the saved object aren't enough to drop 
all references to `callable_obj`.

The trick is that the cleanup code isn't accounting for __cause__ and 
__context__: it's only clearing and dropping the traceback for the topmost 
exception in the chain.

In Vjacheslav's example, there are *two* tracebacks to worry about: both the 
top level one (which is getting cleaned up) and the inner one from 
exc.__context__ which isn't being touched.

We could likely use a "traceback.clear_all_frames()" helper that walks an 
exception tree clearing *all* the traceback frames, both on the original 
exception, and on all the __cause__ and __context__ attributes.

(We can't just clear __cause__ and __context__, since those can be accessed and 
tested when using the context manager form and the `exception` attribute)

--
assignee: docs@python -> 
components:  -Documentation
nosy: +ncoghlan
type: enhancement -> behavior
versions: +Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2017-02-18 Thread Subhendu Ghosh

Changes by Subhendu Ghosh :


--
nosy: +subho

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2016-03-18 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +haypo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2016-03-13 Thread Robert Collins

Robert Collins added the comment:

I don't think we make any guarantees for or against references, but - we 
attempt to free references already (see how we call clear_frames), so this is a 
bug, pure and simple.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2016-01-02 Thread Ezio Melotti

Changes by Ezio Melotti :


--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python
stage:  -> needs patch
versions: +Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2015-04-09 Thread Vjacheslav Fyodorov

Vjacheslav Fyodorov added the comment:

It seems, as a minimum it must be noticed in docs.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23890
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2015-04-09 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti, michael.foord, rbcollins

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23890
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2015-04-08 Thread Vjacheslav Fyodorov

New submission from Vjacheslav Fyodorov:

Sometimes unittest's assertRaises increases reference counter of callable. This 
can break tests in tricky cases. Not seen in 2.X version. Demo file attached.

--
components: Library (Lib)
files: test_assertRaises.py
messages: 240280
nosy: Vjacheslav.Fyodorov
priority: normal
severity: normal
status: open
title: assertRaises increases reference counter
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file38866/test_assertRaises.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23890
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23890] assertRaises increases reference counter

2015-04-08 Thread R. David Murray

R. David Murray added the comment:

This is presumably a result of the exception object being saved on the context 
manager object and there being a circular reference chain that doesn't 
immediately get GCed.  This is just how python works.

I don't know if it would be sensible/useful to use the new lightweight 
traceback stuff in assertRaises.  If so it would probably have to be optional 
for backward compatibility reasons.

--
nosy: +r.david.murray
type: behavior - enhancement
versions: +Python 3.5 -Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23890
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com