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
365ee969
Commit
365ee969
authored
Mar 12, 2015
by
Chris Toshok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add slot tests for __setattr__ and __delattr__
parent
1d6c5fa4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
test/test_extension/slots_test.c
test/test_extension/slots_test.c
+10
-0
test/tests/capi_slots.py
test/tests/capi_slots.py
+50
-0
No files found.
test/test_extension/slots_test.c
View file @
365ee969
...
...
@@ -626,6 +626,16 @@ call_funcs(PyObject* _module, PyObject* args) {
printf
(
"tp_getattr doesnt exist
\n
"
);
}
// we aren't checking for tp_getattro. it's set in cpython and not in pyston
if
(
cls
->
tp_setattr
)
{
printf
(
"tp_setattr exists
\n
"
);
}
else
{
printf
(
"tp_setattr doesnt exist
\n
"
);
}
// we aren't checking for tp_setattro. it's set in cpython and not in pyston
if
(
cls
->
tp_as_mapping
)
{
printf
(
"tp_as_mapping exists
\n
"
);
PyMappingMethods
*
map
=
cls
->
tp_as_mapping
;
...
...
test/tests/capi_slots.py
View file @
365ee969
...
...
@@ -161,3 +161,53 @@ try:
print
c
.
foo
()
except
SystemError
,
e
:
print
e
print
"**** setattr on class def"
class
C7
(
C
):
def
__setattr__
(
self
,
attr
,
val
):
print
"setattr"
,
attr
,
val
c
=
C7
()
slots_test
.
call_funcs
(
c
)
c
.
foo
=
1
c
.
bar
=
2
c
.
baz
=
3
print
"**** setattr set after the fact"
def
_setattr_
(
self
,
attr
,
val
):
print
"_setattr_"
,
attr
,
val
c
=
C6
()
c
.
__setattr__
=
_setattr_
slots_test
.
call_funcs
(
c
)
c
.
foo
=
1
c
.
bar
=
2
c
.
baz
=
3
print
"**** delattr on class def"
class
C8
(
C
):
def
__delattr__
(
self
,
attr
):
print
"delattr"
,
attr
c
=
C8
()
slots_test
.
call_funcs
(
c
)
delattr
(
c
,
'foo'
)
del
c
.
bar
print
"**** delattr set after the fact"
def
_delattr_
(
self
,
attr
):
print
"_delattr_"
,
attr
c
=
C6
()
c
.
__delattr__
=
_delattr_
slots_test
.
call_funcs
(
c
)
try
:
delattr
(
c
,
'foo'
)
except
Exception
as
e
:
pass
try
:
del
c
.
bar
except
Exception
as
e
:
pass
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