#28358: LazyObject defines attribute that don't exist on wrapped object -------------------------------------+------------------------------------- Reporter: Andrey Fedoseev | Owner: Theofilos | Alexiou Type: Bug | Status: closed Component: Utilities | Version: 1.11 Severity: Normal | Resolution: fixed Keywords: | Triage Stage: Ready for | checkin Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by cfbolz): hi everyone! PyPy dev here. So after some investigation (you can find the gory details on this CPython issue: https://github.com/python/cpython/issues/98148 ) it turns out that this bug also exists in CPython, if you run coverage in pure python mode. The bug occurs only if you: 1) use `super` 2) define `__class__` in the class body yourself 3) use a pure python trace hook, or call locals() in the class body. At this point there has been no reaction from CPython yet, but the way I see things from the PyPy side it'll be on the tricky to fix this so it might take a while (I'm waiting for CPy feedback because the two implementations use exactly the same approaches here, to the point of ending up with exactly the same bug). I was wondering whether Django might be open to a PR that works around the bug for the time being? A pragmatic approach would be to stop using super in `LazyObject.__getattribute__`, which was introduced in 97d7990abde3fe4b525ae83958fd0b52d6a1d13f, and just call `object.__getattribute__` instead. If that sounds like a reasonable solution, I am happy to work on the PR. (there would be some trickiness to how to unit test this, but I can probably think of something). Please let me know! -- Ticket URL: <https://code.djangoproject.com/ticket/28358#comment:21> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/010701852108a0d6-2ab224aa-e28c-460b-97ad-631de0c1aeea-000000%40eu-central-1.amazonses.com.