Skip to content

Fix TypeError('cancel() takes exactly one argument (2 given)') with Python 3.9 #368

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: generic
env:
global:
- PYMODULE=uvloop
- RELEASE_PYTHON_VERSIONS="3.5 3.6 3.7 3.8"
- RELEASE_PYTHON_VERSIONS="3.5 3.6 3.7 3.8 3.9"

- S3_UPLOAD_USERNAME=oss-ci-bot
- S3_UPLOAD_BUCKET=magicstack-oss-releases
Expand Down Expand Up @@ -50,6 +50,11 @@ matrix:
env: BUILD=tests,wheels PYTHON_VERSION=3.8.0
branches: {only: [releases]}

- os: osx
osx_image: xcode7.3
env: BUILD=tests,wheels PYTHON_VERSION=3.9.0
branches: {only: [releases]}

- os: linux
dist: trusty
language: python
Expand All @@ -74,6 +79,12 @@ matrix:
python: "3.8"
env: BUILD=tests

- os: linux
dist: bionic
language: python
python: "3.9"
env: BUILD=tests

- os: linux
dist: trusty
branches: {only: [releases]}
Expand Down
4 changes: 2 additions & 2 deletions uvloop/cbhandles.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ cdef class Handle:

return '<' + ' '.join(info) + '>'

def cancel(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Handle.cancel() which doesn't have the msg parameter.

def cancel(self, msg=None):
self._cancel()

def cancelled(self):
Expand Down Expand Up @@ -321,7 +321,7 @@ cdef class TimerHandle:
def cancelled(self):
return self._cancelled

def cancel(self):
def cancel(self, msg=None):
self._cancel()


Expand Down
4 changes: 2 additions & 2 deletions uvloop/loop.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3190,7 +3190,7 @@ class _SyncSocketReaderFuture(aio_Future):
self.__sock = sock
self.__loop = loop

def cancel(self):
def cancel(self, msg=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should pass on this parameter to the super call below.

if self.__sock is not None and self.__sock.fileno() != -1:
self.__loop.remove_reader(self.__sock)
self.__sock = None
Expand All @@ -3205,7 +3205,7 @@ class _SyncSocketWriterFuture(aio_Future):
self.__sock = sock
self.__loop = loop

def cancel(self):
def cancel(self, msg=None):
if self.__sock is not None and self.__sock.fileno() != -1:
self.__loop.remove_writer(self.__sock)
self.__sock = None
Expand Down
2 changes: 1 addition & 1 deletion uvloop/request.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ cdef class UVRequest:
Loop loop

cdef on_done(self)
cdef cancel(self)
cdef cancel(self, msg=*)
2 changes: 1 addition & 1 deletion uvloop/request.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cdef class UVRequest:
self.done = 1
Py_DECREF(self)

cdef cancel(self):
cdef cancel(self, msg=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this is an internal API that shouldn't be changed.

# Most requests are implemented using a threadpool. It's only
# possible to cancel a request when it's still in a threadpool's
# queue. Once it's started to execute, we have to wait until
Expand Down