In my specific case I was passing a large bytes object to glBufferStorage, but used a incorrect number of arguments. It appears that the bytes objects attempts to be displayed in the error message, which freezes Python.
Only seems to cause a freeze if running in an IDLE shell. It doesn't freeze when running in a terminal, but the error message is unusable because the buffer fills up.
In my specific case I was passing a large bytes object to glBufferStorage, but used a incorrect number of arguments. It appears that the bytes objects attempts to be displayed in the error message, which freezes Python.