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
9b5137b1
Commit
9b5137b1
authored
Feb 02, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
object.__setattr__ convert unicode strings
parent
e3205e38
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
src/capi/object.cpp
src/capi/object.cpp
+13
-1
test/tests/setattr.py
test/tests/setattr.py
+3
-0
No files found.
src/capi/object.cpp
View file @
9b5137b1
...
...
@@ -479,9 +479,21 @@ extern "C" PyObject* PyObject_SelfIter(PyObject* obj) noexcept {
}
extern
"C"
int
PyObject_GenericSetAttr
(
PyObject
*
obj
,
PyObject
*
name
,
PyObject
*
value
)
noexcept
{
RELEASE_ASSERT
(
PyString_Check
(
name
),
""
);
if
(
!
PyString_Check
(
name
))
{
if
(
PyUnicode_Check
(
name
))
{
name
=
PyUnicode_AsEncodedString
(
name
,
NULL
,
NULL
);
if
(
name
==
NULL
)
return
-
1
;
}
else
{
PyErr_Format
(
PyExc_TypeError
,
"attribute name must be string, not '%.200s'"
,
Py_TYPE
(
name
)
->
tp_name
);
return
-
1
;
}
}
BoxedString
*
str
=
static_cast
<
BoxedString
*>
(
name
);
internStringMortalInplace
(
str
);
assert
(
PyString_Check
(
name
));
try
{
if
(
value
==
NULL
)
delattrGeneric
(
obj
,
str
,
NULL
);
...
...
test/tests/setattr.py
View file @
9b5137b1
...
...
@@ -38,3 +38,6 @@ class Test(object):
t
=
Test
()
t
.
a
=
1
object
.
__setattr__
(
t
,
u"ustr"
,
"42"
)
print
t
.
ustr
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