Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

len built-in overwritten in ssl.py leading to "'int' object is not callable" error #97558

Open
pn opened this issue Sep 26, 2022 · 3 comments
Open
Labels
type-bug An unexpected behavior, bug, or error

Comments

@pn
Copy link

pn commented Sep 26, 2022

Bug report

I experienced a crash:

  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1235, in sendall
    amount = len(byte_view)
TypeError: 'int' object is not callable

Looks like len built-in function is overwritten by an int in one of read methods in the same file:

def read(self, len=1024, buffer=None):

Following patch fixes the issue for me:

908c908
<     def read(self, len=1024, buffer=None):
---
>     def read(self, _len=1024, buffer=None):
915c915
<             v = self._sslobj.read(len, buffer)
---
>             v = self._sslobj.read(_len, buffer)
917c917
<             v = self._sslobj.read(len)
---
>             v = self._sslobj.read(_len)
1121c1121
<     def read(self, len=1024, buffer=None):
---
>     def read(self, _len=1024, buffer=None):
1130c1130
<                 return self._sslobj.read(len, buffer)
---
>                 return self._sslobj.read(_len, buffer)
1132c1132
<                 return self._sslobj.read(len)
---
>                 return self._sslobj.read(_len)

Your environment

  • CPython versions tested on: 3.10.7
  • Operating system and architecture: MacOS 12.5 (21G72) M1

I searched opened issues and PRs, but did not find this issue reported yet.

@pn pn added the type-bug An unexpected behavior, bug, or error label Sep 26, 2022
@vstinner
Copy link
Member

vstinner commented Sep 26, 2022

I experienced a crash:

Can you please provide the whole traceback? I don't see the relationship between the ssl read() method overridding len() built-in function and the ssl sendall() method.

@pn
Copy link
Author

pn commented Sep 26, 2022

@vstinner, here is more complete stack trace I can share (deleted part related to private project).

    async for doc in cursor:
  File "/Users/pawel/Library/Caches/pypoetry/virtualenvs/project-V3vI678V-py3.10/lib/python3.10/site-packages/motor/core.py", line 1249, in next
    if self.alive and (self._buffer_size() or await self._get_more()):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/pawel/Library/Caches/pypoetry/virtualenvs/project-V3vI678V-py3.10/lib/python3.10/site-packages/pymongo/cursor.py", line 1165, in _refresh
    self.__send_message(q)
  File "/Users/pawel/Library/Caches/pypoetry/virtualenvs/project-V3vI678V-py3.10/lib/python3.10/site-packages/pymongo/cursor.py", line 1052, in __send_message
    response = client._run_operation(
  File "/Users/pawel/Library/Caches/pypoetry/virtualenvs/project-V3vI678V-py3.10/lib/python3.10/site-packages/pymongo/mongo_client.py", line 1267, in _run_operation
    return self._retryable_read(
  File "/Users/pawel/Library/Caches/pypoetry/virtualenvs/project-V3vI678V-py3.10/lib/python3.10/site-packages/pymongo/mongo_client.py", line 1371, in _retryable_read
    return func(session, server, sock_info, read_pref)
  File "/Users/pawel/Library/Caches/pypoetry/virtualenvs/project-V3vI678V-py3.10/lib/python3.10/site-packages/pymongo/mongo_client.py", line 1263, in _cmd
    return server.run_operation(
  File "/Users/pawel/Library/Caches/pypoetry/virtualenvs/project-V3vI678V-py3.10/lib/python3.10/site-packages/pymongo/server.py", line 114, in run_operation
    sock_info.send_message(data, max_doc_size)
  File "/Users/pawel/Library/Caches/pypoetry/virtualenvs/project-V3vI678V-py3.10/lib/python3.10/site-packages/pymongo/pool.py", line 786, in send_message
    self._raise_connection_failure(error)
  File "/Users/pawel/Library/Caches/pypoetry/virtualenvs/project-V3vI678V-py3.10/lib/python3.10/site-packages/pymongo/pool.py", line 784, in send_message
    self.sock.sendall(message)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1235, in sendall
    amount = len(byte_view)
TypeError: 'int' object is not callable

The version of pymongo is 4.1.1

Also I should have mentioned that the crash is happening only during debugging of the project.

@vstinner
Copy link
Member

vstinner commented Sep 26, 2022

Does your change fix the issue for you?

Also I should have mentioned that the crash is happening only during debugging of the project.

That's surprising, you should dig into the issue to try to understand it.

@vstinner, here is more complete stack trace I can share (deleted part related to private project).

Maybe the private parts overridde the built-in len() function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants