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
a3f0d747
Commit
a3f0d747
authored
Apr 06, 2015
by
Michael Arntzenius
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add _make to our NamedTuple stub, add test for bug found implementing it
parent
cd9f3a0f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
0 deletions
+37
-0
from_cpython/Lib/collections.py
from_cpython/Lib/collections.py
+7
-0
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+1
-0
test/tests/return_selfreferential.py
test/tests/return_selfreferential.py
+29
-0
No files found.
from_cpython/Lib/collections.py
View file @
a3f0d747
...
...
@@ -422,6 +422,13 @@ def namedtuple(name, fields):
for
i
in
xrange
(
len
(
fields
)):
setattr
(
self
,
fields
[
i
],
args
[
i
])
@
classmethod
def
_make
(
cls
,
iterable
):
t
=
tuple
(
iterable
)
if
len
(
t
)
!=
len
(
fields
):
raise
TypeError
(
'Expected %d arguments, got %d'
%
(
len
(
fields
),
len
(
t
)))
return
cls
(
*
t
)
def
__getitem__
(
self
,
idx
):
assert
0
<=
idx
<
len
(
fields
)
return
getattr
(
self
,
fields
[
idx
])
...
...
src/codegen/irgen/irgenerator.cpp
View file @
a3f0d747
...
...
@@ -1832,6 +1832,7 @@ private:
endBlock
(
DEAD
);
// This is tripping in test/tests/return_selfreferential.py
ASSERT
(
rtn
->
getVrefs
()
==
1
,
"%d"
,
rtn
->
getVrefs
());
assert
(
rtn
->
getValue
());
emitter
.
getBuilder
()
->
CreateRet
(
rtn
->
getValue
());
...
...
test/tests/return_selfreferential.py
0 → 100644
View file @
a3f0d747
# fail-if: ('-n' in EXTRA_JIT_ARGS) or ('-O' in EXTRA_JIT_ARGS)
# trips an assert about vref counts in irgenerator.cpp: IrGeneratorImpl::doReturn()
def
f1
():
def
bar
(
x
):
print
'bar(%s)'
%
x
if
x
:
return
bar
(
0
)
return
x
return
bar
g
=
f1
()
print
g
(
2
)
def
makeA
():
class
A
(
object
):
def
__init__
(
self
,
*
args
):
self
.
args
=
args
@
classmethod
def
_make
(
cls
,
*
args
):
tmp
=
A
return
cls
(
*
args
)
return
A
def
f2
():
A
=
makeA
()
return
A
(
1
,
2
,
3
)
a
=
f2
()
print
a
.
args
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