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

gh-93627: Align copy module behaviour with pickle module#109498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
eendebakpt wants to merge18 commits intopython:main
base:main
Choose a base branch
Loading
fromeendebakpt:pickle_copy
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
18 commits
Select commitHold shift + click to select a range
1535893
Align copy module behaviour with pickle module
eendebakptSep 16, 2023
30d6b97
📜🤖 Added by blurb_it.
blurb-it[bot]Sep 16, 2023
c97105f
align behaviour of __replace__
eendebakptSep 16, 2023
7da7086
Merge branch 'pickle_copy' of github.com:eendebakpt/cpython into pick…
eendebakptSep 16, 2023
e54350f
Merge branch 'main' into pickle_copy
eendebakptSep 25, 2023
368f99e
Merge branch 'main' into pickle_copy
eendebakptOct 2, 2023
6d31123
Merge branch 'main' into pickle_copy
eendebakptOct 4, 2023
35046a4
Merge branch 'main' into pickle_copy
eendebakptOct 12, 2023
817077f
Merge branch 'main' into pickle_copy
eendebakptOct 16, 2023
2396484
Merge branch 'main' into pickle_copy
eendebakptNov 5, 2023
0b26813
Merge branch 'main' into pickle_copy
eendebakptDec 14, 2023
3aeb310
Merge branch 'main' into pickle_copy
eendebakptJan 18, 2024
a924c78
Merge branch 'main' into pickle_copy
eendebakptMar 29, 2024
7b6b57a
Merge branch 'main' into pickle_copy
skirpichevOct 13, 2024
f481db6
Merge branch 'main' into pickle_copy
eendebakptDec 10, 2024
d451ba4
lint
eendebakptDec 11, 2024
5148248
Merge branch 'main' into pickle_copy
eendebakptDec 11, 2024
ff7f162
Merge branch 'main' into pickle_copy
eendebakptMay 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
align behaviour of __replace__
  • Loading branch information
@eendebakpt
eendebakpt committedSep 16, 2023
commitc97105f0012f7e8380e469e81f25b56322bf50b4
4 changes: 2 additions & 2 deletionsLib/copy.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -301,7 +301,7 @@ def replace(obj, /, **changes):
frozen dataclasses.
"""
cls = obj.__class__
func = getattr(cls, '__replace__',None)
if func isNone:
func = getattr(cls, '__replace__',_NoValue)
if func is_NoValue:
raise TypeError(f"replace() does not support {cls.__name__} objects")
return func(obj, **changes)
7 changes: 7 additions & 0 deletionsLib/test/test_copy.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -981,6 +981,13 @@ class C:
with self.assertRaisesRegex(TypeError, 'unexpected keyword argument'):
copy.replace(c, x=1, error=2)

def test_invalid_replace_method(self):
class A:
__replace__ = None
a = A()
with self.assertRaises(TypeError):
copy.replace(a)


def global_foo(x, y): return x+y

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp