GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `dataclasses.astuple` breaks on `DefaultDict` · Issue #98169 · python/cpython

dataclasses.astuple breaks on DefaultDict #98169

New issue
Copy link
New issue
Copy link
Closed
Closed
dataclasses.astuple breaks on DefaultDict#98169
Copy link
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@kwsp
kwsp
opened on Oct 11, 2022
Issue body actions

Bug report

This is very similar to #79721

from dataclasses import dataclass, astuple
from typing import DefaultDict, List
from collections import defaultdict

@dataclass
class C:
    mp: DefaultDict[str, List]

dd = defaultdict(list)
dd["x"].append(12)
c = C(mp=dd)
d = astuple(c)  # throws "TypeError: first argument must be callable or None"


assert d == ({"x": [12]},)
assert d[0] is not c.mp  # make sure defaultdict is copied

Basically applying the same fix for asdict from #32056 to astuple.

Your environment

  • CPython versions tested on: 3.10.7
  • Operating system and architecture: macOS, arm64

Linked PRs

  • gh-98169 dataclasses.astuple support DefaultDict #98170

Activity

  1. kwsp
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Oct 11, 2022
  2. kwsp
    added a commit that references this issue on Oct 11, 2022

    pythongh-98169 dataclasses.astuple support DefaultDict

    81d9170
  3. carljm
    added a commit that references this issue on Mar 13, 2023

    gh-98169 dataclasses.astuple support DefaultDict (#98170)

    71e37d9
  4. carljm
    closed this as completedon Mar 13, 2023
  5. carljm
    added a commit that references this issue on Mar 14, 2023

    Merge branch 'main' into inlinecomp2

    6c5f269
  6. Fidget-Spinner
    added a commit that references this issue on Mar 27, 2023

    pythongh-98169 dataclasses.astuple support DefaultDict (python#98170)

    c54eeaf
  7. warsaw
    added a commit that references this issue on Apr 11, 2023

    pythongh-98169 dataclasses.astuple support DefaultDict (python#98170)

    3f86f25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.