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
cd9b5c2f
Commit
cd9b5c2f
authored
Apr 26, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Plain Diff
Issue #26634: recursive_repr() now sets __qualname__ of wrapper.
Patch by Xiang Zhang.
parents
144da4ec
b3b366d8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
0 deletions
+18
-0
Lib/reprlib.py
Lib/reprlib.py
+1
-0
Lib/test/test_reprlib.py
Lib/test/test_reprlib.py
+14
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/reprlib.py
View file @
cd9b5c2f
...
...
@@ -30,6 +30,7 @@ def recursive_repr(fillvalue='...'):
wrapper
.
__module__
=
getattr
(
user_function
,
'__module__'
)
wrapper
.
__doc__
=
getattr
(
user_function
,
'__doc__'
)
wrapper
.
__name__
=
getattr
(
user_function
,
'__name__'
)
wrapper
.
__qualname__
=
getattr
(
user_function
,
'__qualname__'
)
wrapper
.
__annotations__
=
getattr
(
user_function
,
'__annotations__'
,
{})
return
wrapper
...
...
Lib/test/test_reprlib.py
View file @
cd9b5c2f
...
...
@@ -374,6 +374,13 @@ class MyContainer2(MyContainer):
def
__repr__
(
self
):
return
'<'
+
', '
.
join
(
map
(
str
,
self
.
values
))
+
'>'
class
MyContainer3
:
def
__repr__
(
self
):
'Test document content'
pass
wrapped
=
__repr__
wrapper
=
recursive_repr
()(
wrapped
)
class
TestRecursiveRepr
(
unittest
.
TestCase
):
def
test_recursive_repr
(
self
):
m
=
MyContainer
(
list
(
'abcde'
))
...
...
@@ -387,5 +394,12 @@ class TestRecursiveRepr(unittest.TestCase):
m
.
append
(
m
)
self
.
assertEqual
(
repr
(
m
),
'<a, b, c, d, e, +++, x, +++>'
)
def
test_assigned_attributes
(
self
):
from
functools
import
WRAPPER_ASSIGNMENTS
as
assigned
wrapped
=
MyContainer3
.
wrapped
wrapper
=
MyContainer3
.
wrapper
for
name
in
assigned
:
self
.
assertIs
(
getattr
(
wrapper
,
name
),
getattr
(
wrapped
,
name
))
if
__name__
==
"__main__"
:
unittest
.
main
()
Misc/NEWS
View file @
cd9b5c2f
...
...
@@ -256,6 +256,9 @@ Core and Builtins
Library
-------
-
Issue
#
26634
:
recursive_repr
()
now
sets
__qualname__
of
wrapper
.
Patch
by
Xiang
Zhang
.
-
Issue
#
26804
:
urllib
.
request
will
prefer
lower_case
proxy
environment
variables
over
UPPER_CASE
or
Mixed_Case
ones
.
Patch
contributed
by
Hans
-
Peter
Jansen
.
...
...
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