This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author andrei.avk
Recipients andrei.avk, iritkatriel, jbw, kj, moi90, serhiy.storchaka
Date 2021-10-26.16:10:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1635264647.14.0.757771949216.issue43656@roundup.psfhosted.org>
In-reply-to
Content
Martin: It's true that exceptions raised in other methods called from __init__ would still have this issue, but I feel like ~90% of it would be solved by the proposed fix.

It does introduce an inconsistency but it does so because it reflects the inconsistency of `self` being NOT initialized in __init__ and `self` being initialized in all other methods used after __init__. It makes intuitive sense that you don't get a repr of an object before it exists in a full state.

The doc fix is useful in itself, but I'm not sure it's enough given the issue reported by Joe with new students getting this error. When they get this error, they will not understand why it happens, what's the connection between the error and the argument that needs to be provided to fix it, and whether it's the correct fix or not.

If they *do* understand it, fixing the __repr__ is probably the best solution, and then no fix on our side is required.

My concern with adding a safe repr argument is that code using that argument can be copy pasted unknowingly and then it's not explicit/obvious that it will silence the errors raised due to broken __repr__'s. (including __repr__'s that are broken even outside of __init__ method).

If such an parameter is added, it's much better to make it a new parameter, to avoid backwards incompatible change, which means it can be backported.
History
Date User Action Args
2021-10-26 16:10:47andrei.avksetrecipients: + andrei.avk, serhiy.storchaka, iritkatriel, moi90, kj, jbw
2021-10-26 16:10:47andrei.avksetmessageid: <1635264647.14.0.757771949216.issue43656@roundup.psfhosted.org>
2021-10-26 16:10:47andrei.avklinkissue43656 messages
2021-10-26 16:10:46andrei.avkcreate