Closed picnixz closed 2 months ago
I can reproduce on a3711afefa7a, Debian/WSL/Windows Terminal.
Good for me that I'm not alone in this then. I tried a bit more and it doesn't seem to be because of the metaclass handling. Actually, I also hit the same issue with this code:
class A:
def foo(self):
pass
class B(A):
pass
This one is perfectly valid, although I still hit an IndexError while going up.
Can you try to see if reverting https://github.com/python/cpython/commit/32a0faba439b239d7b0c242c1e3cd2025c52b8cf helps?
I confirm that reverting that commit helps. I also tried on main and the issue is still there, so reverting that specific commit fixed it!
CC @godlygeek
Can you check if https://github.com/python/cpython/issues/121531 fixes it?
I can confirm that your PR fixes this specific issue (at least, I'm not able to reproduce what I described)
Bug report
IMPORTANT
For anyone trying to reproduce this issue, please remove your Python history file before trying anything (remember to back it up) or use
./python -I
instead so that you do not have surprises.Bug description:
I don't really have a better title but here's what I wrote in the interpreter while trying to break metaclasses for this:
The inputs must be given line by line:
class A(type):
; press ENTERdef __prepare__(a, b): pass
; press ENTERclass B(metaclass=A):
; press ENTERpass
; press ENTERThe output is
For now, this is fine. However, by hitting UP multiple times (5 times) until you cannot go up, you get:
Note that I've cleaned up my local history file before this and that I failed to get the IndexError (but still get a dirty history and bad up/down handling) with other inputs such as
I suspect some newlines are badly handled but only if the error occurs at some point (I'm not sure if its tied to the fact that
__prepare__
is bad, and whether I'm possibly leaving a module in a very bad state for some reason). I'm opening an issue because I'd like to know if someone is able to reproduce it or not. It might be my terminal emulator as well so I'd like confirmation.The main commit is 2078eb45ca (I did not bisect the issue though, because it would take me a very long time since I don't know how to do it for interactive inputs like that).
Here's the hexdump of the python history:
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux