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
b7ffa456
Commit
b7ffa456
authored
Mar 29, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get delattr() working
parent
0604fb4f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
8 deletions
+9
-8
src/capi/object.cpp
src/capi/object.cpp
+5
-3
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+4
-2
test/tests/change_delattr.py
test/tests/change_delattr.py
+0
-1
test/tests/delattr.py
test/tests/delattr.py
+0
-1
test/tests/object_default_behavior.py
test/tests/object_default_behavior.py
+0
-1
No files found.
src/capi/object.cpp
View file @
b7ffa456
...
...
@@ -493,14 +493,16 @@ extern "C" int PyObject_GenericSetAttr(PyObject* obj, PyObject* name, PyObject*
}
BoxedString
*
str
=
static_cast
<
BoxedString
*>
(
name
);
incref
(
str
);
internStringMortalInplace
(
str
);
AUTO_DECREF
(
str
);
assert
(
PyString_Check
(
name
));
try
{
if
(
value
==
NULL
)
delattrGeneric
(
obj
,
str
,
NULL
);
else
setattrGeneric
<
NOT_REWRITABLE
>
(
obj
,
str
,
value
,
NULL
);
setattrGeneric
<
NOT_REWRITABLE
>
(
obj
,
str
,
incref
(
value
)
,
NULL
);
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
return
-
1
;
...
...
@@ -1139,8 +1141,8 @@ extern "C" void _Py_NegativeRefcount(const char* fname, int lineno, PyObject* op
char
buf
[
300
];
PyOS_snprintf
(
buf
,
sizeof
(
buf
),
"%s:%i object at %p has negative ref count "
"%"
PY_FORMAT_SIZE_T
"d"
,
fname
,
lineno
,
op
,
op
->
ob_refcnt
);
"%"
PY_FORMAT_SIZE_T
"d
.
\033
[40mwatch -l *(long*)%p
\033
[0m
"
,
fname
,
lineno
,
op
,
op
->
ob_refcnt
,
&
op
->
ob_refcnt
);
Py_FatalError
(
buf
);
}
...
...
src/runtime/builtin_modules/builtins.cpp
View file @
b7ffa456
...
...
@@ -511,13 +511,15 @@ Box* bltinImport(Box* name, Box* globals, Box* locals, Box** args) {
}
Box
*
delattrFunc
(
Box
*
obj
,
Box
*
_str
)
{
assert
(
0
&&
"check refcounting"
);
_str
=
coerceUnicodeToStr
<
CXX
>
(
_str
);
if
(
_str
->
cls
!=
str_cls
)
if
(
_str
->
cls
!=
str_cls
)
{
Py_DECREF
(
_str
);
raiseExcHelper
(
TypeError
,
"attribute name must be string, not '%s'"
,
getTypeName
(
_str
));
}
BoxedString
*
str
=
static_cast
<
BoxedString
*>
(
_str
);
internStringMortalInplace
(
str
);
AUTO_DECREF
(
str
);
delattr
(
obj
,
str
);
return
incref
(
None
);
...
...
test/tests/change_delattr.py
View file @
b7ffa456
# expected: reffail
class
C
(
object
):
pass
...
...
test/tests/delattr.py
View file @
b7ffa456
# expected: reffail
#delete attribute of built-in types
def
del_builtin_attr
(
o
):
try
:
...
...
test/tests/object_default_behavior.py
View file @
b7ffa456
# expected: reffail
class
C
(
object
):
def
__delattr__
(
self
,
attr
):
print
"delattr"
,
attr
...
...
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