Skip to content

Handling Collections Callable Attribute missing issue in 3.9+#81

Open
udhayprakash wants to merge 1 commit intopyreadline:masterfrom
udhayprakash:patch-1
Open

Handling Collections Callable Attribute missing issue in 3.9+#81
udhayprakash wants to merge 1 commit intopyreadline:masterfrom
udhayprakash:patch-1

Conversation

@udhayprakash
Copy link

In python 3.11, when working on a module, I got below error.
\pyreadline\py3k_compat.py", line 8, in callable return isinstance(x, collections.Callable)
^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'collections' has no attribute 'Callable'

When researched I understood that Collections module was modified. It moved collections.Callable to collections.abc.Callable Handled that change, bearing in mind backward compatibility

In python 3.11, when working on a module, I got below error. 
\pyreadline\py3k_compat.py", line 8, in callable    return isinstance(x, collections.Callable)
                         ^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'collections' has no attribute 'Callable'

When researched I understood that Collections module was modified. It moved collections.Callable to collections.abc.Callable
Handled that change, bearing in mind backward compatibility
@RocaroDev93
Copy link

Hello, can you push this modification on pip please. I use the rshell package that depends on it and I had to modify the pyreadline code to use my project with 3.10+ Python version.

May I suggest this code instead :

    def callable(x):
        if sys.version_info[1] >= 10:
            return isinstance(x, collections.abc.Callable)
        else:
            return isinstance(x, collections.Callable)

@udhayprakash
Copy link
Author

i dont have permissions to merge this PR. I, too, am awaiting for the repo owner to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants