Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.6k
Open
Description
Describe the bug
Hi there,
According tohttps://docs.python.org/3/library/functools.html#functools.singledispatchmethod,@functools.singledispatchmethod
can be used on top of@classmethod
.
The following code runs in CPython interpreter (requiring Python >= 3.9.8):
importfunctoolsclassA:@functools.singledispatchmethod@classmethoddeff(cls,x):print("Fallback")@f.register@classmethoddef_(cls,x:int):print("int")a=A()a.f(1)a.f("1")
However, it results in the following error in Cython:
TypeError: Invalid first argument to `register()`: <classmethod(<cyfunction A._ at 0x7f497b091a80>)>. Use either `@register(some_class)` or plain `@register` on an annotated function.
Is it a feature or a bug?
Code to reproduce the behaviour:
importfunctoolsclassA:@functools.singledispatchmethod@classmethoddeff(cls,x):print("Fallback")@f.register@classmethoddef_(cls,x:int):print("int")a=A()a.f(1)a.f("1")
Expected behaviour
It should print:
intFallback
OS
Ubuntu 22.04.5 LTS
Python version
3.10.12
Cython version
3.1.4
Additional context
No response
Metadata
Metadata
Assignees
Labels
No labels