Different exception raised in PyPy and cPython on Windows when importing readline
Trying to import readling on Windows raises a different exception when using PyPy compared with cPython.
First, doing it with cPython
>>> try:
... import readline
... except ModuleNotFoundError:
... print("caught")
...
caught
Next, with PyPy.
>>>> try:
.... import readline
.... except ModuleNotFoundError:
.... print("caught")
....
Traceback (most recent call last):
File "C:\Users\Andre\bin\pypy3.8-v7.3.7-win64\Lib\readline.py", line 10, in <module>
from pyrepl.readline import *
File "C:\Users\Andre\bin\pypy3.8-v7.3.7-win64\Lib\pyrepl\readline.py", line 33, in <module>
from pyrepl.unix_console import UnixConsole, _error
File "C:\Users\Andre\bin\pypy3.8-v7.3.7-win64\Lib\pyrepl\unix_console.py", line 22, in <module>
import termios, select, os, struct, errno
ModuleNotFoundError: No module named 'termios'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "C:\Users\Andre\bin\pypy3.8-v7.3.7-win64\Lib\readline.py", line 14, in <module>
raise ImportError("the 'readline' module is not available on Windows"
ImportError: the 'readline' module is not available on Windows (on either PyPy or CPython)
>>>>
Of course, the ImportError
exception could be caught ... but, since it is raised explicitly in the PyPy readline module, it might make sense to raise a ModuleNotFoundError
instead.