[issue41647] MutableMapping ".setdefault()" to return default value via __getitem__

2020-08-27 Thread Matias G
New submission from Matias G : Hi, This is more a question/proposal than a real issue. I apologize in advance if this has already been debated or if it is not relevant. I noticed `setdefault` method of mutable mapping objects is returning the default value as passed in the call, when

[issue45555] Object stays alive for weak reference if an exception happens in constructor

2021-10-21 Thread Matias G
New submission from Matias G : Hi Python developers, I stumbled on a weird behavior, which might be a bug actually. I am surprised by the output of the following piece of code: ``` import weakref refs = [] class A: def __init__(self): refs.append(weakref.ref(self

[issue45555] Object stays alive for weak reference if an exception happens in constructor

2021-10-22 Thread Matias G
Matias G added the comment: About the reference in exception: I thought that Python 3 didn't have the need for `sys.exc_clear()` (which has been removed), specifically for this kind of problem. The code I use is in fact more complex than the small snippet I posted here to reproduce