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
fb2009bb
Commit
fb2009bb
authored
Mar 29, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some attrwrapper behavior
parent
64a7ab2a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
22 deletions
+19
-22
src/runtime/dict.cpp
src/runtime/dict.cpp
+3
-2
src/runtime/types.cpp
src/runtime/types.cpp
+8
-19
test/tests/attrwrapper_iter.py
test/tests/attrwrapper_iter.py
+8
-0
test/tests/dir.py
test/tests/dir.py
+0
-1
No files found.
src/runtime/dict.cpp
View file @
fb2009bb
...
@@ -724,7 +724,8 @@ void dictMergeFromSeq2(BoxedDict* self, Box* other) {
...
@@ -724,7 +724,8 @@ void dictMergeFromSeq2(BoxedDict* self, Box* other) {
int
idx
=
0
;
int
idx
=
0
;
// raises if not iterable
// raises if not iterable
for
(
const
auto
&
element
:
other
->
pyElements
())
{
for
(
Box
*
element
:
other
->
pyElements
())
{
AUTO_DECREF
(
element
);
// should this check subclasses? anyway to check if something is iterable...
// should this check subclasses? anyway to check if something is iterable...
if
(
element
->
cls
==
list_cls
)
{
if
(
element
->
cls
==
list_cls
)
{
...
@@ -782,7 +783,7 @@ Box* dictUpdate(BoxedDict* self, BoxedTuple* args, BoxedDict* kwargs) {
...
@@ -782,7 +783,7 @@ Box* dictUpdate(BoxedDict* self, BoxedTuple* args, BoxedDict* kwargs) {
if
(
args
->
size
())
{
if
(
args
->
size
())
{
Box
*
arg
=
args
->
elts
[
0
];
Box
*
arg
=
args
->
elts
[
0
];
static
BoxedString
*
keys_str
=
getStaticString
(
"keys"
);
static
BoxedString
*
keys_str
=
getStaticString
(
"keys"
);
if
(
autoDecref
(
getattrInternal
<
ExceptionStyle
::
CXX
>
(
arg
,
keys_str
)))
{
if
(
auto
X
Decref
(
getattrInternal
<
ExceptionStyle
::
CXX
>
(
arg
,
keys_str
)))
{
dictMerge
(
self
,
arg
);
dictMerge
(
self
,
arg
);
}
else
{
}
else
{
dictMergeFromSeq2
(
self
,
arg
);
dictMergeFromSeq2
(
self
,
arg
);
...
...
src/runtime/types.cpp
View file @
fb2009bb
...
@@ -2535,17 +2535,17 @@ public:
...
@@ -2535,17 +2535,17 @@ public:
static
Box
*
iterkeys
(
Box
*
_self
)
{
static
Box
*
iterkeys
(
Box
*
_self
)
{
Box
*
r
=
AttrWrapper
::
keys
(
_self
);
Box
*
r
=
AttrWrapper
::
keys
(
_self
);
return
getiter
(
r
);
return
getiter
(
autoDecref
(
r
)
);
}
}
static
Box
*
itervalues
(
Box
*
_self
)
{
static
Box
*
itervalues
(
Box
*
_self
)
{
Box
*
r
=
AttrWrapper
::
values
(
_self
);
Box
*
r
=
AttrWrapper
::
values
(
_self
);
return
getiter
(
r
);
return
getiter
(
autoDecref
(
r
)
);
}
}
static
Box
*
iteritems
(
Box
*
_self
)
{
static
Box
*
iteritems
(
Box
*
_self
)
{
Box
*
r
=
AttrWrapper
::
items
(
_self
);
Box
*
r
=
AttrWrapper
::
items
(
_self
);
return
getiter
(
r
);
return
getiter
(
autoDecref
(
r
)
);
}
}
static
Box
*
copy
(
Box
*
_self
)
{
static
Box
*
copy
(
Box
*
_self
)
{
...
@@ -2648,7 +2648,7 @@ public:
...
@@ -2648,7 +2648,7 @@ public:
// Hopefully this does not happen very often.
// Hopefully this does not happen very often.
if
(
!
PyDict_Check
(
_container
))
{
if
(
!
PyDict_Check
(
_container
))
{
BoxedDict
*
new_container
=
new
BoxedDict
();
BoxedDict
*
new_container
=
new
BoxedDict
();
dictUpdate
(
new_container
,
autoDecref
(
BoxedTuple
::
create
({
_container
})),
NULL
);
autoDecref
(
dictUpdate
(
new_container
,
autoDecref
(
BoxedTuple
::
create
({
_container
})),
NULL
)
);
_container
=
new_container
;
_container
=
new_container
;
}
else
{
}
else
{
Py_INCREF
(
_container
);
Py_INCREF
(
_container
);
...
@@ -2727,7 +2727,7 @@ Box* AttrWrapperIter::next(Box* _self) {
...
@@ -2727,7 +2727,7 @@ Box* AttrWrapperIter::next(Box* _self) {
assert
(
self
->
it
!=
self
->
hcls
->
getStrAttrOffsets
().
end
());
assert
(
self
->
it
!=
self
->
hcls
->
getStrAttrOffsets
().
end
());
Box
*
r
=
self
->
it
->
first
;
Box
*
r
=
self
->
it
->
first
;
++
self
->
it
;
++
self
->
it
;
return
r
;
return
incref
(
r
)
;
}
}
Box
*
AttrWrapperIter
::
next_capi
(
Box
*
_self
)
noexcept
{
Box
*
AttrWrapperIter
::
next_capi
(
Box
*
_self
)
noexcept
{
...
@@ -2739,7 +2739,7 @@ Box* AttrWrapperIter::next_capi(Box* _self) noexcept {
...
@@ -2739,7 +2739,7 @@ Box* AttrWrapperIter::next_capi(Box* _self) noexcept {
return
NULL
;
return
NULL
;
Box
*
r
=
self
->
it
->
first
;
Box
*
r
=
self
->
it
->
first
;
++
self
->
it
;
++
self
->
it
;
return
r
;
return
incref
(
r
)
;
}
}
void
Box
::
giveAttrDescriptor
(
const
char
*
attr
,
Box
*
(
*
get
)(
Box
*
,
void
*
),
void
(
*
set
)(
Box
*
,
Box
*
,
void
*
))
{
void
Box
::
giveAttrDescriptor
(
const
char
*
attr
,
Box
*
(
*
get
)(
Box
*
,
void
*
),
void
(
*
set
)(
Box
*
,
Box
*
,
void
*
))
{
...
@@ -3992,19 +3992,9 @@ int HCAttrs::traverse(visitproc visit, void* arg) noexcept {
...
@@ -3992,19 +3992,9 @@ int HCAttrs::traverse(visitproc visit, void* arg) noexcept {
void
AttrWrapperIter
::
dealloc
(
Box
*
_o
)
noexcept
{
void
AttrWrapperIter
::
dealloc
(
Box
*
_o
)
noexcept
{
AttrWrapperIter
*
o
=
(
AttrWrapperIter
*
)
_o
;
AttrWrapperIter
*
o
=
(
AttrWrapperIter
*
)
_o
;
Py_FatalError
(
"unimplemented?"
);
o
->
cls
->
tp_free
(
o
);
o
->
cls
->
tp_free
(
o
);
}
}
int
AttrWrapperIter
::
traverse
(
Box
*
_o
,
visitproc
visit
,
void
*
arg
)
noexcept
{
AttrWrapperIter
*
o
=
(
AttrWrapperIter
*
)
_o
;
Py_FatalError
(
"unimplemented?"
);
return
0
;
}
void
BoxedClosure
::
dealloc
(
Box
*
_o
)
noexcept
{
void
BoxedClosure
::
dealloc
(
Box
*
_o
)
noexcept
{
BoxedClosure
*
o
=
(
BoxedClosure
*
)
_o
;
BoxedClosure
*
o
=
(
BoxedClosure
*
)
_o
;
...
@@ -4361,9 +4351,8 @@ void setupRuntime() {
...
@@ -4361,9 +4351,8 @@ void setupRuntime() {
classmethod_cls
=
BoxedClass
::
create
(
type_cls
,
object_cls
,
0
,
0
,
sizeof
(
BoxedClassmethod
),
false
,
"classmethod"
,
classmethod_cls
=
BoxedClass
::
create
(
type_cls
,
object_cls
,
0
,
0
,
sizeof
(
BoxedClassmethod
),
false
,
"classmethod"
,
true
,
BoxedClassmethod
::
dealloc
,
NULL
,
true
,
BoxedClassmethod
::
traverse
,
true
,
BoxedClassmethod
::
dealloc
,
NULL
,
true
,
BoxedClassmethod
::
traverse
,
BoxedClassmethod
::
clear
);
BoxedClassmethod
::
clear
);
attrwrapperiter_cls
attrwrapperiter_cls
=
BoxedClass
::
create
(
type_cls
,
object_cls
,
0
,
0
,
sizeof
(
AttrWrapperIter
),
false
,
=
BoxedClass
::
create
(
type_cls
,
object_cls
,
0
,
0
,
sizeof
(
AttrWrapperIter
),
false
,
"attrwrapperiter"
,
true
,
"attrwrapperiter"
,
true
,
AttrWrapperIter
::
dealloc
,
NULL
,
false
);
AttrWrapperIter
::
dealloc
,
NULL
,
true
,
AttrWrapperIter
::
traverse
,
NOCLEAR
);
pyston_getset_cls
->
giveAttr
(
"__get__"
,
pyston_getset_cls
->
giveAttr
(
"__get__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
getsetGet
,
UNKNOWN
,
3
),
{
None
}));
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
getsetGet
,
UNKNOWN
,
3
),
{
None
}));
...
...
test/tests/attrwrapper_iter.py
0 → 100644
View file @
fb2009bb
def
f
():
pass
f
.
a
=
1
f
.
b
=
2
i
=
iter
(
f
.
__dict__
)
del
f
print
list
(
i
)
test/tests/dir.py
View file @
fb2009bb
# expected: reffail
import
sys
import
sys
...
...
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