Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Boxiang Sun
Pyston
Commits
abb040c5
Commit
abb040c5
authored
May 13, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attrwrapper.update(iterable)
parent
433aa81e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
3 deletions
+16
-3
src/runtime/dict.h
src/runtime/dict.h
+1
-0
src/runtime/types.cpp
src/runtime/types.cpp
+11
-3
test/tests/dir.py
test/tests/dir.py
+4
-0
No files found.
src/runtime/dict.h
View file @
abb040c5
...
...
@@ -58,6 +58,7 @@ Box* dictViewKeysIter(Box* self);
Box
*
dictViewValuesIter
(
Box
*
self
);
Box
*
dictViewItemsIter
(
Box
*
self
);
void
dictMerge
(
BoxedDict
*
self
,
Box
*
other
);
Box
*
dictUpdate
(
BoxedDict
*
self
,
BoxedTuple
*
args
,
BoxedDict
*
kwargs
);
}
#endif
src/runtime/types.cpp
View file @
abb040c5
...
...
@@ -31,6 +31,7 @@
#include "gc/collector.h"
#include "runtime/capi.h"
#include "runtime/classobj.h"
#include "runtime/dict.h"
#include "runtime/file.h"
#include "runtime/ics.h"
#include "runtime/iterobject.h"
...
...
@@ -1541,14 +1542,21 @@ public:
for
(
const
auto
&
p
:
attrs
->
hcls
->
getStrAttrOffsets
())
{
self
->
b
->
setattr
(
p
.
first
(),
attrs
->
attr_list
->
attrs
[
p
.
second
],
NULL
);
}
}
else
if
(
_container
->
cls
==
dict_cls
)
{
}
else
{
// The update rules are too complicated to be worth duplicating here;
// just create a new dict object and defer to dictUpdate.
// Hopefully this does not happen very often.
if
(
!
isSubclass
(
_container
->
cls
,
dict_cls
))
{
BoxedDict
*
new_container
=
new
BoxedDict
();
dictUpdate
(
new_container
,
BoxedTuple
::
create
({
_container
}),
new
BoxedDict
());
_container
=
new_container
;
}
assert
(
isSubclass
(
_container
->
cls
,
dict_cls
));
BoxedDict
*
container
=
static_cast
<
BoxedDict
*>
(
_container
);
for
(
const
auto
&
p
:
container
->
d
)
{
AttrWrapper
::
setitem
(
self
,
p
.
first
,
p
.
second
);
}
}
else
{
RELEASE_ASSERT
(
0
,
"not implemented: %s"
,
_container
->
cls
->
tp_name
);
}
};
...
...
test/tests/dir.py
View file @
abb040c5
...
...
@@ -110,3 +110,7 @@ class TestClass3: # old-style
print
sorted
([
d
for
d
in
dir
(
TestClass3
)
if
not
d
.
startswith
(
'_'
)])
print
sorted
([
d
for
d
in
dir
(
TestClass3
())
if
not
d
.
startswith
(
'_'
)])
c
=
C1
()
c
.
__dict__
.
update
([(
'a'
,
1
),
(
'b'
,
2
)])
print
c
.
a
,
c
.
b
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