Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
41eb7164
Commit
41eb7164
authored
Oct 27, 2006
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bug #1576241] Let functools.wraps work with built-in functions
parent
d3aad019
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletion
+8
-1
Lib/functools.py
Lib/functools.py
+1
-1
Lib/test/test_functools.py
Lib/test/test_functools.py
+7
-0
No files found.
Lib/functools.py
View file @
41eb7164
...
...
@@ -32,7 +32,7 @@ def update_wrapper(wrapper,
for
attr
in
assigned
:
setattr
(
wrapper
,
attr
,
getattr
(
wrapped
,
attr
))
for
attr
in
updated
:
getattr
(
wrapper
,
attr
).
update
(
getattr
(
wrapped
,
attr
))
getattr
(
wrapper
,
attr
).
update
(
getattr
(
wrapped
,
attr
,
{}
))
# Return the wrapper so this can be used as a decorator via partial()
return
wrapper
...
...
Lib/test/test_functools.py
View file @
41eb7164
...
...
@@ -210,6 +210,13 @@ class TestUpdateWrapper(unittest.TestCase):
self
.
assertEqual
(
wrapper
.
attr
,
'This is a different test'
)
self
.
assertEqual
(
wrapper
.
dict_attr
,
f
.
dict_attr
)
def
test_builtin_update
(
self
):
# Test for bug #1576241
def
wrapper
():
pass
functools
.
update_wrapper
(
wrapper
,
max
)
self
.
assertEqual
(
wrapper
.
__name__
,
'max'
)
self
.
assert_
(
wrapper
.
__doc__
.
startswith
(
'max('
))
class
TestWraps
(
TestUpdateWrapper
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment