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
ccf53aab
Commit
ccf53aab
authored
Jan 18, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix assert when accessing _ attribute
parent
96080385
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
src/runtime/classobj.cpp
src/runtime/classobj.cpp
+4
-4
test/tests/oldstyle_classes.py
test/tests/oldstyle_classes.py
+16
-0
No files found.
src/runtime/classobj.cpp
View file @
ccf53aab
...
...
@@ -217,7 +217,7 @@ static Box* classobjGetattribute(Box* _cls, Box* _attr) {
BoxedString
*
attr
=
static_cast
<
BoxedString
*>
(
_attr
);
// These are special cases in CPython as well:
if
(
attr
->
s
()[
0
]
==
'_'
&&
attr
->
s
()[
1
]
==
'_'
)
{
if
(
attr
->
data
()[
0
]
==
'_'
&&
attr
->
data
()[
1
]
==
'_'
)
{
if
(
attr
->
s
()
==
"__dict__"
)
return
cls
->
getAttrWrapper
();
...
...
@@ -448,7 +448,7 @@ static Box* _instanceGetattribute(Box* _inst, BoxedString* attr_str, bool raise_
BoxedInstance
*
inst
=
static_cast
<
BoxedInstance
*>
(
_inst
);
// These are special cases in CPython as well:
if
(
attr_str
->
s
()[
0
]
==
'_'
&&
attr_str
->
s
()[
1
]
==
'_'
)
{
if
(
attr_str
->
data
()[
0
]
==
'_'
&&
attr_str
->
data
()[
1
]
==
'_'
)
{
if
(
attr_str
->
s
()
==
"__dict__"
)
return
inst
->
getAttrWrapper
();
...
...
@@ -510,7 +510,7 @@ Box* instanceSetattroInternal(Box* _inst, Box* _attr, Box* value, SetattrRewrite
assert
(
value
);
// These are special cases in CPython as well:
if
(
attr
->
s
()[
0
]
==
'_'
&&
attr
->
s
()[
1
]
==
'_'
)
{
if
(
attr
->
data
()[
0
]
==
'_'
&&
attr
->
data
()[
1
]
==
'_'
)
{
if
(
attr
->
s
()
==
"__dict__"
)
Py_FatalError
(
"unimplemented"
);
...
...
@@ -571,7 +571,7 @@ Box* instanceDelattr(Box* _inst, Box* _attr) {
BoxedString
*
attr
=
static_cast
<
BoxedString
*>
(
_attr
);
// These are special cases in CPython as well:
if
(
attr
->
s
()[
0
]
==
'_'
&&
attr
->
s
()[
1
]
==
'_'
)
{
if
(
attr
->
data
()[
0
]
==
'_'
&&
attr
->
data
()[
1
]
==
'_'
)
{
if
(
attr
->
s
()
==
"__dict__"
)
raiseExcHelper
(
TypeError
,
"__dict__ must be set to a dictionary"
);
...
...
test/tests/oldstyle_classes.py
View file @
ccf53aab
...
...
@@ -511,3 +511,19 @@ for i in range(500):
if
i
==
150
:
C
.
__bases__
=
tuple
()
print
s1
,
s2
# we used to have problems with this
for
i
in
range
(
2
):
try
:
C
.
_
except
AttributeError
,
e
:
print
e
try
:
C
().
_
except
AttributeError
,
e
:
print
e
try
:
print
C
().
_
()
except
AttributeError
,
e
:
print
e
C
.
_
=
(
lambda
s
:
42
)
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