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

Regression in Django with singledispatchmethod on models #127750

Closed
Labels
3.13bugs and security fixes3.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@vodik

Description

@vodik

Bug report

Bug description:

Also reported upstream to Djangohere.

The following code works on Python 3.12 and I believe#85160 is the cause.

When traversing a relationship and then calling asingledispatchmethod method registered on a model, the reference to self seems to get cached and locked to the first created model.

classTest(models.Model):    ...classTest2(models.Model):relationship=models.ForeignKey("Test",on_delete=models.CASCADE)@singledispatchmethoddefbug(self,x):print(">",id(self))@bug.registerdef_(self,x:int):print(">",id(self))

and then it's pretty easy to trigger:

fortintest.test2_set.all():print("id:",id(t))# always changest.bug(4)# only ever prints a single id

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp