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
ac53ab64
Commit
ac53ab64
authored
Dec 18, 2010
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#5587: add a repr to dict_proxy objects. Patch by David Stanek and Daniel Urban.
parent
197c9c94
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
1 deletion
+15
-1
Lib/test/test_descr.py
Lib/test/test_descr.py
+5
-0
Misc/NEWS
Misc/NEWS
+3
-0
Objects/descrobject.c
Objects/descrobject.c
+7
-1
No files found.
Lib/test/test_descr.py
View file @
ac53ab64
...
@@ -4268,6 +4268,11 @@ class DictProxyTests(unittest.TestCase):
...
@@ -4268,6 +4268,11 @@ class DictProxyTests(unittest.TestCase):
pass
pass
self
.
assertEqual
(
type
(
C
.
__dict__
),
type
(
B
.
__dict__
))
self
.
assertEqual
(
type
(
C
.
__dict__
),
type
(
B
.
__dict__
))
def
test_repr
(
self
):
# Testing dict_proxy.__repr__
dict_
=
{
k
:
v
for
k
,
v
in
self
.
C
.
__dict__
.
items
()}
self
.
assertEqual
(
repr
(
self
.
C
.
__dict__
),
'dict_proxy({!r})'
.
format
(
dict_
))
class
PTypesLongInitTest
(
unittest
.
TestCase
):
class
PTypesLongInitTest
(
unittest
.
TestCase
):
# This is in its own TestCase so that it can be run before any other tests.
# This is in its own TestCase so that it can be run before any other tests.
...
...
Misc/NEWS
View file @
ac53ab64
...
@@ -17,6 +17,9 @@ Core and Builtins
...
@@ -17,6 +17,9 @@ Core and Builtins
rather than the Py_IsInitialized flag, avoiding a Fatal Python
rather than the Py_IsInitialized flag, avoiding a Fatal Python
error in certain circumstances when an import is done in __del__.
error in certain circumstances when an import is done in __del__.
- Issue #5587: add a repr to dict_proxy objects. Patch by David Stanek and
Daniel Urban.
Library
Library
-------
-------
...
...
Objects/descrobject.c
View file @
ac53ab64
...
@@ -766,6 +766,12 @@ proxy_str(proxyobject *pp)
...
@@ -766,6 +766,12 @@ proxy_str(proxyobject *pp)
return
PyObject_Str
(
pp
->
dict
);
return
PyObject_Str
(
pp
->
dict
);
}
}
static
PyObject
*
proxy_repr
(
proxyobject
*
pp
)
{
return
PyUnicode_FromFormat
(
"dict_proxy(%R)"
,
pp
->
dict
);
}
static
int
static
int
proxy_traverse
(
PyObject
*
self
,
visitproc
visit
,
void
*
arg
)
proxy_traverse
(
PyObject
*
self
,
visitproc
visit
,
void
*
arg
)
{
{
...
@@ -791,7 +797,7 @@ PyTypeObject PyDictProxy_Type = {
...
@@ -791,7 +797,7 @@ PyTypeObject PyDictProxy_Type = {
0
,
/* tp_getattr */
0
,
/* tp_getattr */
0
,
/* tp_setattr */
0
,
/* tp_setattr */
0
,
/* tp_reserved */
0
,
/* tp_reserved */
0
,
/* tp_repr */
(
reprfunc
)
proxy_repr
,
/* tp_repr */
0
,
/* tp_as_number */
0
,
/* tp_as_number */
&
proxy_as_sequence
,
/* tp_as_sequence */
&
proxy_as_sequence
,
/* tp_as_sequence */
&
proxy_as_mapping
,
/* tp_as_mapping */
&
proxy_as_mapping
,
/* tp_as_mapping */
...
...
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