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
0922d716
Commit
0922d716
authored
Feb 07, 2007
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SF #1615701: make d.update(m) honor __getitem__() and keys() in dict subclasses
parent
814ef237
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
Lib/test/test_dict.py
Lib/test/test_dict.py
+8
-0
Objects/dictobject.c
Objects/dictobject.c
+1
-1
No files found.
Lib/test/test_dict.py
View file @
0922d716
...
...
@@ -189,6 +189,14 @@ class DictTest(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
{}.
update
,
[(
1
,
2
,
3
)])
# SF #1615701: make d.update(m) honor __getitem__() and keys() in dict subclasses
class
KeyUpperDict
(
dict
):
def
__getitem__
(
self
,
key
):
return
key
.
upper
()
d
.
clear
()
d
.
update
(
KeyUpperDict
.
fromkeys
(
'abc'
))
self
.
assertEqual
(
d
,
{
'a'
:
'A'
,
'b'
:
'B'
,
'c'
:
'C'
})
def
test_fromkeys
(
self
):
self
.
assertEqual
(
dict
.
fromkeys
(
'abc'
),
{
'a'
:
None
,
'b'
:
None
,
'c'
:
None
})
d
=
{}
...
...
Objects/dictobject.c
View file @
0922d716
...
...
@@ -1306,7 +1306,7 @@ PyDict_Merge(PyObject *a, PyObject *b, int override)
return
-
1
;
}
mp
=
(
dictobject
*
)
a
;
if
(
PyDict_Check
(
b
))
{
if
(
PyDict_Check
Exact
(
b
))
{
other
=
(
dictobject
*
)
b
;
if
(
other
==
mp
||
other
->
ma_used
==
0
)
/* a.update(a) or a.update({}); nothing to do */
...
...
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