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
add17cc3
Commit
add17cc3
authored
Aug 14, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wow, I did not think that descriptors would apply here
parent
85501a49
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
src/runtime/types.cpp
src/runtime/types.cpp
+4
-1
test/tests/dunder_descriptors.py
test/tests/dunder_descriptors.py
+10
-6
No files found.
src/runtime/types.cpp
View file @
add17cc3
...
...
@@ -402,7 +402,10 @@ extern "C" Box* sliceNew(Box* cls, Box* start, Box* stop, Box** args) {
}
Box
*
instancemethodRepr
(
BoxedInstanceMethod
*
self
)
{
if
(
self
->
obj
)
return
boxStrConstant
(
"<bound instancemethod object>"
);
else
return
boxStrConstant
(
"<unbound instancemethod object>"
);
}
Box
*
sliceRepr
(
BoxedSlice
*
self
)
{
...
...
test/tests/dunder_descriptors.py
View file @
add17cc3
...
...
@@ -4,21 +4,25 @@
# Descriptors get processed when fetched as part of a dunder lookup
class
D
(
object
):
def
__init__
(
self
,
n
):
self
.
n
=
n
def
__get__
(
self
,
obj
,
cls
):
print
"__get__()"
,
obj
is
None
def
desc
():
print
"desc()"
return
1
print
"__get__()"
,
obj
is
None
,
self
.
n
def
desc
(
*
args
):
print
"desc()"
,
len
(
args
)
return
self
.
n
return
desc
def
__call__
(
self
):
print
"D.call"
return
2
return
self
.
n
class
C
(
object
):
__hash__
=
D
()
__hash__
=
D
(
1
)
__add__
=
D
(
2
)
c
=
C
()
print
C
.
__hash__
()
print
c
.
__hash__
()
print
hash
(
c
)
print
c
+
c
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