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

copy fails on collections.OrderedDict dataclass with required args #105736

Open
Assignees
ericsnowcurrentlyrhettinger
Labels
3.11only security fixes3.12only security fixes3.13bugs and security fixesstdlibPython modules in the Lib dirtopic-dataclassestype-bugAn unexpected behavior, bug, or error
@ringohoffman

Description

@ringohoffman

Bug report

Related:huggingface/transformers#8978

importcollectionsimportcopyimportdataclasses@dataclasses.dataclassclassModelOutputDictBase(dict):a:intb:int=2# workscopy.deepcopy(ModelOutputDictBase(a=1,b=2,    ))@dataclasses.dataclassclassModelOutputAllDefaults(collections.OrderedDict):a:int=1b:int=2# workscopy.deepcopy(ModelOutputAllDefaults(a=1,b=2,    ))@dataclasses.dataclassclassModelOutput(collections.OrderedDict):a:intb:int=2# failscopy.deepcopy(ModelOutput(a=1,b=2,    ))
---------------------------------------------------------------------------TypeError                                 Traceback (most recent call last)Cell In[4], line 3935     a:int36     b:int=2---> 39 copy.deepcopy(40     ModelOutput(41         a=1,42         b=2,43     )44 )File [...lib/python3.8/copy.py:172), in deepcopy(x, memo, _nil)170                 y= x171else:--> 172                 y = _reconstruct(x, memo, *rv)174# If is its own copy, don't memoize.175if yisnot x:File [.../lib/python3.8/copy.py:264), in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)262if deepand args:263     args= (deepcopy(arg, memo)for argin args)--> 264 y = func(*args)265if deep:266     memo[id(x)]= yTypeError:__init__() missing 1 required positional argument: 'a'

Your environment

  • CPython versions tested on: Python 3.8.16 (default, Jan 17 2023, 23:13:24) [GCC 11.2.0] :: Anaconda, Inc. on linux
  • Operating system and architecture: Ubuntu 20.04.6 LTS x86_64

Linked PRs

Metadata

Metadata

Labels

3.11only security fixes3.12only security fixes3.13bugs and security fixesstdlibPython modules in the Lib dirtopic-dataclassestype-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