Fix Python 3.10 AtributeError#72
Conversation
Fixed this:
```python
C:\Windows\system32>python
Python 3.10.0 (tags/v3.10.0:b494f59, Oct 4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\site.py", line 446, in register_readline
import readline
File "C:\Program Files\Python310\lib\site-packages\readline.py", line 34, in <module>
rl = Readline()
File "C:\Program Files\Python310\lib\site-packages\pyreadline\rlmain.py", line 422, in __init__
BaseReadline.__init__(self)
File "C:\Program Files\Python310\lib\site-packages\pyreadline\rlmain.py", line 62, in __init__
mode.init_editing_mode(None)
File "C:\Program Files\Python310\lib\site-packages\pyreadline\modes\emacs.py", line 633, in init_editing_mode
self._bind_key('space', self.self_insert)
File "C:\Program Files\Python310\lib\site-packages\pyreadline\modes\basemode.py", line 162, in _bind_key
if not callable(func):
File "C:\Program Files\Python310\lib\site-packages\pyreadline\py3k_compat.py", line 8, in callable
return isinstance(x, collections.Callable)
AttributeError: module 'collections' has no attribute 'Callable'
```
|
Fixing the issue that way excludes Python 2.7. Better would be: and then to use |
|
Dear Andy, Python 2.7 first came out on 2010. Its EOL was announced for almost 2 years ago. If we're to carry all these corpses in the trunk, we might as well work for the Corleone family. I'm going to risk saying that this is no longer the same language. Now, I have very little idea what amount of trouble this would involve, but could this not simply be a I could not emphasize this loud enough: if you are a command-line animal like me, this is one of the most useful libraries in the whole Pyverse. As I mentioned, this is working great for me. I just want it to work great for everybody. |
|
Although, if we were about to carry all these corpses, then… if sys.version_info[:2] >= (3, 3):
from collections.abc import Callable
else:
from collections import Callable
def callable(x):
return isinstance(x, Callable) |
|
But to be honest, I pretty much agree with @ricardo-reis-1970. |
You mean my code suggestion or my opinion on |
|
Please send your PR here |
Bumping -- I like this solution. |
This codepath is not executed for Python 2, only Python 3: |
Fixed this: