Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[BUG] Using @functools.singledispatchmethod over @classmethod fails #7172

Open
@roastduck

Description

@roastduck

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp