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
183aa5f7
Commit
183aa5f7
authored
May 09, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1166 from kmod/undo_changes
Undo a bunch of Pyston changes to cpython code
parents
d36b99b0
865898f5
Changes
30
Show whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
71 additions
and
255 deletions
+71
-255
from_cpython/Lib/_abcoll.py
from_cpython/Lib/_abcoll.py
+1
-3
from_cpython/Lib/bisect.py
from_cpython/Lib/bisect.py
+0
-4
from_cpython/Lib/codecs.py
from_cpython/Lib/codecs.py
+1
-5
from_cpython/Lib/collections.py
from_cpython/Lib/collections.py
+3
-30
from_cpython/Lib/test/test_abc.py
from_cpython/Lib/test/test_abc.py
+1
-2
from_cpython/Lib/test/test_array.py
from_cpython/Lib/test/test_array.py
+0
-2
from_cpython/Lib/test/test_complex.py
from_cpython/Lib/test/test_complex.py
+1
-4
from_cpython/Lib/test/test_file2k.py
from_cpython/Lib/test/test_file2k.py
+0
-2
from_cpython/Lib/test/test_fileio.py
from_cpython/Lib/test/test_fileio.py
+0
-2
from_cpython/Lib/test/test_mmap.py
from_cpython/Lib/test/test_mmap.py
+4
-16
from_cpython/Lib/test/test_set.py
from_cpython/Lib/test/test_set.py
+2
-6
from_cpython/Lib/test/test_signal.py
from_cpython/Lib/test/test_signal.py
+4
-6
from_cpython/Lib/types.py
from_cpython/Lib/types.py
+2
-5
from_cpython/Lib/unittest/loader.py
from_cpython/Lib/unittest/loader.py
+1
-4
from_cpython/Lib/unittest/result.py
from_cpython/Lib/unittest/result.py
+9
-12
from_cpython/Lib/warnings.py
from_cpython/Lib/warnings.py
+0
-6
from_cpython/Lib/weakref.py
from_cpython/Lib/weakref.py
+12
-56
from_cpython/Modules/_collectionsmodule.c
from_cpython/Modules/_collectionsmodule.c
+1
-3
from_cpython/Modules/_ctypes/cfield.c
from_cpython/Modules/_ctypes/cfield.c
+1
-3
from_cpython/Modules/_elementtree.c
from_cpython/Modules/_elementtree.c
+2
-3
from_cpython/Modules/_functoolsmodule.c
from_cpython/Modules/_functoolsmodule.c
+1
-2
from_cpython/Modules/_sre.c
from_cpython/Modules/_sre.c
+4
-12
from_cpython/Modules/cPickle.c
from_cpython/Modules/cPickle.c
+1
-0
from_cpython/Modules/itertoolsmodule.c
from_cpython/Modules/itertoolsmodule.c
+11
-40
from_cpython/Objects/fileobject.c
from_cpython/Objects/fileobject.c
+3
-9
from_cpython/Objects/unicodeobject.c
from_cpython/Objects/unicodeobject.c
+2
-3
from_cpython/Python/dtoa.c
from_cpython/Python/dtoa.c
+2
-6
from_cpython/Python/import.c
from_cpython/Python/import.c
+0
-1
from_cpython/Python/pyarena.c
from_cpython/Python/pyarena.c
+2
-4
src/runtime/capi.cpp
src/runtime/capi.cpp
+0
-4
No files found.
from_cpython/Lib/_abcoll.py
View file @
183aa5f7
...
@@ -23,9 +23,7 @@ __all__ = ["Hashable", "Iterable", "Iterator",
...
@@ -23,9 +23,7 @@ __all__ = ["Hashable", "Iterable", "Iterator",
def
_hasattr
(
C
,
attr
):
def
_hasattr
(
C
,
attr
):
try
:
try
:
# Pyston temporary workaround: make this a list comprehension instead of generator comprehension,
return
any
(
attr
in
B
.
__dict__
for
B
in
C
.
__mro__
)
# since any() can exit without exhausting the iterable.
return
any
([
attr
in
B
.
__dict__
for
B
in
C
.
__mro__
])
except
AttributeError
:
except
AttributeError
:
# Old-style class
# Old-style class
return
hasattr
(
C
,
attr
)
return
hasattr
(
C
,
attr
)
...
...
from_cpython/Lib/bisect.py
View file @
183aa5f7
...
@@ -87,10 +87,6 @@ def bisect_left(a, x, lo=0, hi=None):
...
@@ -87,10 +87,6 @@ def bisect_left(a, x, lo=0, hi=None):
# Overwrite above definitions with a fast C implementation
# Overwrite above definitions with a fast C implementation
try
:
try
:
# Pyston FIXME: somehow sys.modules['_bisect'] is being bound to 0, which is tripping an assert in importStar.
# import sys
# print '_bisect' in sys.modules
# print sys.modules['_bisect']
from
_bisect
import
*
from
_bisect
import
*
except
ImportError
:
except
ImportError
:
pass
pass
from_cpython/Lib/codecs.py
View file @
183aa5f7
...
@@ -14,11 +14,7 @@ import __builtin__, sys
...
@@ -14,11 +14,7 @@ import __builtin__, sys
try
:
try
:
from
_codecs
import
*
from
_codecs
import
*
except
ImportError
,
why
:
except
ImportError
,
why
:
# Pyston change: for now, let the ImportError propagate instead of
raise
SystemError
(
'Failed to load the builtin codecs: %s'
%
why
)
# converting to a SystemError. This leads to better handling by
# the importer
raise
# raise SystemError('Failed to load the builtin codecs: %s' % why)
__all__
=
[
"register"
,
"lookup"
,
"open"
,
"EncodedFile"
,
"BOM"
,
"BOM_BE"
,
__all__
=
[
"register"
,
"lookup"
,
"open"
,
"EncodedFile"
,
"BOM"
,
"BOM_BE"
,
"BOM_LE"
,
"BOM32_BE"
,
"BOM32_LE"
,
"BOM64_BE"
,
"BOM64_LE"
,
"BOM_LE"
,
"BOM32_BE"
,
"BOM32_LE"
,
"BOM64_BE"
,
"BOM64_LE"
,
...
...
from_cpython/Lib/collections.py
View file @
183aa5f7
__all__
=
[
'Counter'
,
'deque'
,
'defaultdict'
,
'namedtuple'
,
'OrderedDict'
]
__all__
=
[
'Counter'
,
'deque'
,
'defaultdict'
,
'namedtuple'
,
'OrderedDict'
]
# For bootstrapping reasons, the collection ABCs are defined in _abcoll.py.
# For bootstrapping reasons, the collection ABCs are defined in _abcoll.py.
# They should however be considered an integral part of collections.py.
# They should however be considered an integral part of collections.py.
# Pyston change: disable using the _abcoll module for now.
from
_abcoll
import
*
from
_abcoll
import
*
import
_abcoll
import
_abcoll
#
__all__ += _abcoll.__all__
__all__
+=
_abcoll
.
__all__
from
_collections
import
deque
,
defaultdict
from
_collections
import
deque
,
defaultdict
from
operator
import
itemgetter
as
_itemgetter
,
eq
as
_eq
from
operator
import
itemgetter
as
_itemgetter
,
eq
as
_eq
...
@@ -124,34 +123,7 @@ class OrderedDict(dict):
...
@@ -124,34 +123,7 @@ class OrderedDict(dict):
for
k
in
self
:
for
k
in
self
:
yield
(
k
,
self
[
k
])
yield
(
k
,
self
[
k
])
# Pyston change: copied the code in from _abcoll rather than calling "update = MutableMapping.update"
update
=
MutableMapping
.
update
def
update
(
*
args
,
**
kwds
):
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v
'''
if
len
(
args
)
>
2
:
raise
TypeError
(
"update() takes at most 2 positional "
"arguments ({} given)"
.
format
(
len
(
args
)))
elif
not
args
:
raise
TypeError
(
"update() takes at least 1 argument (0 given)"
)
self
=
args
[
0
]
other
=
args
[
1
]
if
len
(
args
)
>=
2
else
()
# Pyston change: changed this from "Mapping" to "dict"
if
isinstance
(
other
,
dict
):
for
key
in
other
:
self
[
key
]
=
other
[
key
]
elif
hasattr
(
other
,
"keys"
):
for
key
in
other
.
keys
():
self
[
key
]
=
other
[
key
]
else
:
for
key
,
value
in
other
:
self
[
key
]
=
value
for
key
,
value
in
kwds
.
items
():
self
[
key
]
=
value
__update
=
update
# let subclasses override update without breaking __init__
__update
=
update
# let subclasses override update without breaking __init__
...
@@ -407,6 +379,7 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
...
@@ -407,6 +379,7 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
return
result
return
result
########################################################################
########################################################################
### Counter
### Counter
########################################################################
########################################################################
...
...
from_cpython/Lib/test/test_abc.py
View file @
183aa5f7
...
@@ -223,8 +223,7 @@ class TestABC(unittest.TestCase):
...
@@ -223,8 +223,7 @@ class TestABC(unittest.TestCase):
C
().
f
()
C
().
f
()
del
C
del
C
test_support
.
gc_collect
()
test_support
.
gc_collect
()
# Pyston change: disable it for now.
self
.
assertEqual
(
r
(),
None
)
# self.assertEqual(r(), None)
def
test_main
():
def
test_main
():
test_support
.
run_unittest
(
TestABC
)
test_support
.
run_unittest
(
TestABC
)
...
...
from_cpython/Lib/test/test_array.py
View file @
183aa5f7
...
@@ -765,8 +765,6 @@ class BaseTest(unittest.TestCase):
...
@@ -765,8 +765,6 @@ class BaseTest(unittest.TestCase):
b
=
buffer
(
a
)
b
=
buffer
(
a
)
self
.
assertEqual
(
b
[
0
],
a
.
tostring
()[
0
])
self
.
assertEqual
(
b
[
0
],
a
.
tostring
()[
0
])
# Pyston change: disable this test because of our GC
@
unittest
.
skip
(
"Pyston"
in
sys
.
version
)
def
test_weakref
(
self
):
def
test_weakref
(
self
):
s
=
array
.
array
(
self
.
typecode
,
self
.
example
)
s
=
array
.
array
(
self
.
typecode
,
self
.
example
)
p
=
proxy
(
s
)
p
=
proxy
(
s
)
...
...
from_cpython/Lib/test/test_complex.py
View file @
183aa5f7
...
@@ -433,15 +433,12 @@ class ComplexTest(unittest.TestCase):
...
@@ -433,15 +433,12 @@ class ComplexTest(unittest.TestCase):
test_values
=
(
1
,
123.0
,
10
-
19j
,
xcomplex
(
1
+
2j
),
test_values
=
(
1
,
123.0
,
10
-
19j
,
xcomplex
(
1
+
2j
),
xcomplex
(
1
+
87j
),
xcomplex
(
10
+
90j
))
xcomplex
(
1
+
87j
),
xcomplex
(
10
+
90j
))
# Pyston change: if rhs is a subclass of lhs, then should try
# reverse the order. Pyston don't support it yet. Need to improve
# binop handing.
for
op
in
infix_binops
:
for
op
in
infix_binops
:
for
x
in
xcomplex_values
:
for
x
in
xcomplex_values
:
for
y
in
test_values
:
for
y
in
test_values
:
a
=
'x %s y'
%
op
a
=
'x %s y'
%
op
b
=
'y %s x'
%
op
b
=
'y %s x'
%
op
#
self.assertTrue(type(eval(a)) is type(eval(b)) is xcomplex)
self
.
assertTrue
(
type
(
eval
(
a
))
is
type
(
eval
(
b
))
is
xcomplex
)
def
test_hash
(
self
):
def
test_hash
(
self
):
for
x
in
xrange
(
-
30
,
30
):
for
x
in
xrange
(
-
30
,
30
):
...
...
from_cpython/Lib/test/test_file2k.py
View file @
183aa5f7
...
@@ -29,8 +29,6 @@ class AutoFileTests(unittest.TestCase):
...
@@ -29,8 +29,6 @@ class AutoFileTests(unittest.TestCase):
self
.
f
.
close
()
self
.
f
.
close
()
os
.
remove
(
TESTFN
)
os
.
remove
(
TESTFN
)
# Pyston change: disabled
@
unittest
.
skip
(
"this depends on refcounting"
)
def
testWeakRefs
(
self
):
def
testWeakRefs
(
self
):
# verify weak references
# verify weak references
p
=
proxy
(
self
.
f
)
p
=
proxy
(
self
.
f
)
...
...
from_cpython/Lib/test/test_fileio.py
View file @
183aa5f7
...
@@ -28,8 +28,6 @@ class AutoFileTests(unittest.TestCase):
...
@@ -28,8 +28,6 @@ class AutoFileTests(unittest.TestCase):
self
.
f
.
close
()
self
.
f
.
close
()
os
.
remove
(
TESTFN
)
os
.
remove
(
TESTFN
)
# Pyston change: disable this test becasue of GC
@
unittest
.
skip
(
"only works with refcounting"
)
def
testWeakRefs
(
self
):
def
testWeakRefs
(
self
):
# verify weak references
# verify weak references
p
=
proxy
(
self
.
f
)
p
=
proxy
(
self
.
f
)
...
...
from_cpython/Lib/test/test_mmap.py
View file @
183aa5f7
...
@@ -119,10 +119,7 @@ class MmapTests(unittest.TestCase):
...
@@ -119,10 +119,7 @@ class MmapTests(unittest.TestCase):
def
test_access_parameter
(
self
):
def
test_access_parameter
(
self
):
# Test for "access" keyword parameter
# Test for "access" keyword parameter
mapsize
=
10
mapsize
=
10
# Pyston change: use a with statement to not rely on the destructor being called:
open
(
TESTFN
,
"wb"
).
write
(
"a"
*
mapsize
)
# open(TESTFN, "wb").write("a"*mapsize)
with
open
(
TESTFN
,
"wb"
)
as
f
:
f
.
write
(
"a"
*
mapsize
)
f
=
open
(
TESTFN
,
"rb"
)
f
=
open
(
TESTFN
,
"rb"
)
m
=
mmap
.
mmap
(
f
.
fileno
(),
mapsize
,
access
=
mmap
.
ACCESS_READ
)
m
=
mmap
.
mmap
(
f
.
fileno
(),
mapsize
,
access
=
mmap
.
ACCESS_READ
)
self
.
assertEqual
(
m
[:],
'a'
*
mapsize
,
"Readonly memory map data incorrect."
)
self
.
assertEqual
(
m
[:],
'a'
*
mapsize
,
"Readonly memory map data incorrect."
)
...
@@ -541,10 +538,7 @@ class MmapTests(unittest.TestCase):
...
@@ -541,10 +538,7 @@ class MmapTests(unittest.TestCase):
@
unittest
.
skipUnless
(
hasattr
(
mmap
,
'PROT_READ'
),
"needs mmap.PROT_READ"
)
@
unittest
.
skipUnless
(
hasattr
(
mmap
,
'PROT_READ'
),
"needs mmap.PROT_READ"
)
def
test_prot_readonly
(
self
):
def
test_prot_readonly
(
self
):
mapsize
=
10
mapsize
=
10
# Pyston change: use a with statement to not rely on the destructor being called:
open
(
TESTFN
,
"wb"
).
write
(
"a"
*
mapsize
)
# open(TESTFN, "wb").write("a"*mapsize)
with
open
(
TESTFN
,
"wb"
)
as
f
:
f
.
write
(
"a"
*
mapsize
)
f
=
open
(
TESTFN
,
"rb"
)
f
=
open
(
TESTFN
,
"rb"
)
m
=
mmap
.
mmap
(
f
.
fileno
(),
mapsize
,
prot
=
mmap
.
PROT_READ
)
m
=
mmap
.
mmap
(
f
.
fileno
(),
mapsize
,
prot
=
mmap
.
PROT_READ
)
self
.
assertRaises
(
TypeError
,
m
.
write
,
"foo"
)
self
.
assertRaises
(
TypeError
,
m
.
write
,
"foo"
)
...
@@ -556,10 +550,7 @@ class MmapTests(unittest.TestCase):
...
@@ -556,10 +550,7 @@ class MmapTests(unittest.TestCase):
def
test_io_methods
(
self
):
def
test_io_methods
(
self
):
data
=
"0123456789"
data
=
"0123456789"
# Pyston change: use a with statement to not rely on the destructor being called:
open
(
TESTFN
,
"wb"
).
write
(
"x"
*
len
(
data
))
# open(TESTFN, "wb").write("x"*len(data))
with
open
(
TESTFN
,
"wb"
)
as
f
:
f
.
write
(
"x"
*
len
(
data
))
f
=
open
(
TESTFN
,
"r+b"
)
f
=
open
(
TESTFN
,
"r+b"
)
m
=
mmap
.
mmap
(
f
.
fileno
(),
len
(
data
))
m
=
mmap
.
mmap
(
f
.
fileno
(),
len
(
data
))
f
.
close
()
f
.
close
()
...
@@ -626,10 +617,7 @@ class MmapTests(unittest.TestCase):
...
@@ -626,10 +617,7 @@ class MmapTests(unittest.TestCase):
m
.
close
()
m
.
close
()
# Should not crash (Issue 5385)
# Should not crash (Issue 5385)
# Pyston change: use a with statement to not rely on the destructor being called:
open
(
TESTFN
,
"wb"
).
write
(
"x"
*
10
)
# open(TESTFN, "wb").write("x"*10)
with
open
(
TESTFN
,
"wb"
)
as
f
:
f
.
write
(
"x"
*
10
)
f
=
open
(
TESTFN
,
"r+b"
)
f
=
open
(
TESTFN
,
"r+b"
)
m
=
mmap
.
mmap
(
f
.
fileno
(),
0
)
m
=
mmap
.
mmap
(
f
.
fileno
(),
0
)
f
.
close
()
f
.
close
()
...
...
from_cpython/Lib/test/test_set.py
View file @
183aa5f7
...
@@ -337,9 +337,7 @@ class TestJointOps(unittest.TestCase):
...
@@ -337,9 +337,7 @@ class TestJointOps(unittest.TestCase):
obj
.
x
=
iter
(
container
)
obj
.
x
=
iter
(
container
)
del
obj
,
container
del
obj
,
container
gc
.
collect
()
gc
.
collect
()
# Pyston change: because with conservative scanning
self
.
assertTrue
(
ref
()
is
None
,
"Cycle was not collected"
)
# it is hard to guarantee finalizer calls
# self.assertTrue(ref() is None, "Cycle was not collected")
class
TestSet
(
TestJointOps
):
class
TestSet
(
TestJointOps
):
thetype
=
set
thetype
=
set
...
@@ -560,9 +558,7 @@ class TestSet(TestJointOps):
...
@@ -560,9 +558,7 @@ class TestSet(TestJointOps):
p
=
weakref
.
proxy
(
s
)
p
=
weakref
.
proxy
(
s
)
self
.
assertEqual
(
str
(
p
),
str
(
s
))
self
.
assertEqual
(
str
(
p
),
str
(
s
))
s
=
None
s
=
None
# Pyston change: because with conservative scanning
self
.
assertRaises
(
ReferenceError
,
str
,
p
)
# it is hard to guarantee finalizer calls
# self.assertRaises(ReferenceError, str, p)
@
unittest
.
skipUnless
(
hasattr
(
set
,
"test_c_api"
),
@
unittest
.
skipUnless
(
hasattr
(
set
,
"test_c_api"
),
'C API test only available in a debug build'
)
'C API test only available in a debug build'
)
...
...
from_cpython/Lib/test/test_signal.py
View file @
183aa5f7
...
@@ -79,8 +79,7 @@ class InterProcessSignalTests(unittest.TestCase):
...
@@ -79,8 +79,7 @@ class InterProcessSignalTests(unittest.TestCase):
# don't worry about re-setting the default handlers.
# don't worry about re-setting the default handlers.
signal
.
signal
(
signal
.
SIGHUP
,
self
.
handlerA
)
signal
.
signal
(
signal
.
SIGHUP
,
self
.
handlerA
)
signal
.
signal
(
signal
.
SIGUSR1
,
self
.
handlerB
)
signal
.
signal
(
signal
.
SIGUSR1
,
self
.
handlerB
)
# Pyston change: pyston uses SIGUSR2 internally
signal
.
signal
(
signal
.
SIGUSR2
,
signal
.
SIG_IGN
)
# signal.signal(signal.SIGUSR2, signal.SIG_IGN)
signal
.
signal
(
signal
.
SIGALRM
,
signal
.
default_int_handler
)
signal
.
signal
(
signal
.
SIGALRM
,
signal
.
default_int_handler
)
# Variables the signals will modify:
# Variables the signals will modify:
...
@@ -118,10 +117,9 @@ class InterProcessSignalTests(unittest.TestCase):
...
@@ -118,10 +117,9 @@ class InterProcessSignalTests(unittest.TestCase):
print
"HandlerBCalled exception caught"
print
"HandlerBCalled exception caught"
# Pyston change: pyston uses SIGUSR2 internally
child
=
ignoring_eintr
(
subprocess
.
Popen
,
[
'kill'
,
'-USR2'
,
str
(
pid
)])
# child = ignoring_eintr(subprocess.Popen, ['kill', '-USR2', str(pid)])
if
child
:
# if child:
self
.
wait
(
child
)
# Nothing should happen.
# self.wait(child) # Nothing should happen.
try
:
try
:
signal
.
alarm
(
1
)
signal
.
alarm
(
1
)
...
...
from_cpython/Lib/types.py
View file @
183aa5f7
...
@@ -71,16 +71,13 @@ try:
...
@@ -71,16 +71,13 @@ try:
except
TypeError
:
except
TypeError
:
tb
=
sys
.
exc_info
()[
2
]
tb
=
sys
.
exc_info
()[
2
]
TracebackType
=
type
(
tb
)
TracebackType
=
type
(
tb
)
# Pyston change (we don't support tb_frame yet):
FrameType
=
type
(
tb
.
tb_frame
)
FrameType
=
type
(
sys
.
_getframe
(
0
))
# FrameType = type(tb.tb_frame)
del
tb
del
tb
SliceType
=
slice
SliceType
=
slice
EllipsisType
=
type
(
Ellipsis
)
EllipsisType
=
type
(
Ellipsis
)
# Pyston change: don't support this yet
DictProxyType
=
type
(
TypeType
.
__dict__
)
# DictProxyType = type(TypeType.__dict__)
NotImplementedType
=
type
(
NotImplemented
)
NotImplementedType
=
type
(
NotImplemented
)
# Pyston change:
# Pyston change:
...
...
from_cpython/Lib/unittest/loader.py
View file @
183aa5f7
...
@@ -139,10 +139,7 @@ class TestLoader(object):
...
@@ -139,10 +139,7 @@ class TestLoader(object):
hasattr
(
getattr
(
testCaseClass
,
attrname
),
'__call__'
)
hasattr
(
getattr
(
testCaseClass
,
attrname
),
'__call__'
)
testFnNames
=
filter
(
isTestMethod
,
dir
(
testCaseClass
))
testFnNames
=
filter
(
isTestMethod
,
dir
(
testCaseClass
))
if
self
.
sortTestMethodsUsing
:
if
self
.
sortTestMethodsUsing
:
# Pyston change:
testFnNames
.
sort
(
key
=
_CmpToKey
(
self
.
sortTestMethodsUsing
))
# TODO(rntz): needs builtin `cmp` to work
#testFnNames.sort(key=_CmpToKey(self.sortTestMethodsUsing))
testFnNames
.
sort
()
return
testFnNames
return
testFnNames
def
discover
(
self
,
start_dir
,
pattern
=
'test*.py'
,
top_level_dir
=
None
):
def
discover
(
self
,
start_dir
,
pattern
=
'test*.py'
,
top_level_dir
=
None
):
...
...
from_cpython/Lib/unittest/result.py
View file @
183aa5f7
...
@@ -153,17 +153,14 @@ class TestResult(object):
...
@@ -153,17 +153,14 @@ class TestResult(object):
"""Converts a sys.exc_info()-style tuple of values into a string."""
"""Converts a sys.exc_info()-style tuple of values into a string."""
exctype
,
value
,
tb
=
err
exctype
,
value
,
tb
=
err
# Skip test runner traceback levels
# Skip test runner traceback levels
# Pyston change: I've commented this out for now. - rntz
while
tb
and
self
.
_is_relevant_tb_level
(
tb
):
# TODO(rntz): needs traceback stuff to work
tb
=
tb
.
tb_next
# while tb and self._is_relevant_tb_level(tb):
# tb = tb.tb_next
if
exctype
is
test
.
failureException
:
# Skip assert*() traceback levels
# if exctype is test.failureException:
length
=
self
.
_count_relevant_tb_levels
(
tb
)
# # Skip assert*() traceback levels
msgLines
=
traceback
.
format_exception
(
exctype
,
value
,
tb
,
length
)
# length = self._count_relevant_tb_levels(tb)
else
:
# msgLines = traceback.format_exception(exctype, value, tb, length)
# else:
# msgLines = traceback.format_exception(exctype, value, tb)
msgLines
=
traceback
.
format_exception
(
exctype
,
value
,
tb
)
msgLines
=
traceback
.
format_exception
(
exctype
,
value
,
tb
)
if
self
.
buffer
:
if
self
.
buffer
:
...
...
from_cpython/Lib/warnings.py
View file @
183aa5f7
...
@@ -183,12 +183,6 @@ def warn(message, category=None, stacklevel=1):
...
@@ -183,12 +183,6 @@ def warn(message, category=None, stacklevel=1):
assert
issubclass
(
category
,
Warning
)
assert
issubclass
(
category
,
Warning
)
# Get context information
# Get context information
try
:
try
:
# Pyston change: manually skip the call to _getframe.
# A ValueError() is supposed to specify that the "depth" argument is greater
# than the stack level, so it doesn't seem appropriate for us to throw as
# a signal that it's unimplemented.
raise
ValueError
()
caller
=
sys
.
_getframe
(
stacklevel
)
caller
=
sys
.
_getframe
(
stacklevel
)
except
ValueError
:
except
ValueError
:
globals
=
sys
.
__dict__
globals
=
sys
.
__dict__
...
...
from_cpython/Lib/weakref.py
View file @
183aa5f7
...
@@ -49,17 +49,8 @@ class WeakValueDictionary(UserDict.UserDict):
...
@@ -49,17 +49,8 @@ class WeakValueDictionary(UserDict.UserDict):
self
=
selfref
()
self
=
selfref
()
if
self
is
not
None
:
if
self
is
not
None
:
if
self
.
_iterating
:
if
self
.
_iterating
:
self
.
_pending_removals
.
append
(
wr
)
self
.
_pending_removals
.
append
(
wr
.
key
)
else
:
else
:
# Pyston change: adopted this pypy fix:
#
# Changed this for PyPy: made more resistent. The
# issue is that in some corner cases, self.data
# might already be changed or removed by the time
# this weakref's callback is called. If that is
# the case, we don't want to randomly kill an
# unrelated entry.
if
self
.
data
.
get
(
wr
.
key
)
is
wr
:
del
self
.
data
[
wr
.
key
]
del
self
.
data
[
wr
.
key
]
self
.
_remove
=
remove
self
.
_remove
=
remove
# A list of keys to be removed
# A list of keys to be removed
...
@@ -73,9 +64,7 @@ class WeakValueDictionary(UserDict.UserDict):
...
@@ -73,9 +64,7 @@ class WeakValueDictionary(UserDict.UserDict):
# We shouldn't encounter any KeyError, because this method should
# We shouldn't encounter any KeyError, because this method should
# always be called *before* mutating the dict.
# always be called *before* mutating the dict.
while
l
:
while
l
:
wr
=
l
.
pop
()
del
d
[
l
.
pop
()]
if
d
.
get
(
wr
.
key
)
is
wr
:
del
d
[
wr
.
key
]
def
__getitem__
(
self
,
key
):
def
__getitem__
(
self
,
key
):
o
=
self
.
data
[
key
]()
o
=
self
.
data
[
key
]()
...
@@ -291,32 +280,14 @@ class WeakKeyDictionary(UserDict.UserDict):
...
@@ -291,32 +280,14 @@ class WeakKeyDictionary(UserDict.UserDict):
"""
"""
def
__init__
(
self
,
dict
=
None
):
def
__init__
(
self
,
dict
=
None
):
# Pyston change:
# This implementation of WeakKeyDictionary originally relied on quick destruction
# of the weakref key objects and the immediate calling of their callback. With a gc,
# there can be multiple key removals before a collection happens, at which point we
# call remove() with keys that are not the most recent version.
#
# The approach here is to check the key in the dict to make sure it is still the same.
# This is a little bit complicated since 1) if the weakref.ref's referent gets freed,
# the ref object is no longer usable as a hash key, and 2) setting a value in a dict
# when the key already exists will not update the key.
#
# So in __setitem__, remove the existing key and replace it with the new one.
# Since there's no way to query for the current key inside a dict, given a lookup key,
# we keep a separate "refs" dict to look it up.
self
.
data
=
{}
self
.
data
=
{}
self
.
refs
=
{}
def
remove
(
k
,
selfref
=
ref
(
self
)):
def
remove
(
k
,
selfref
=
ref
(
self
)):
self
=
selfref
()
self
=
selfref
()
if
self
is
not
None
:
if
self
is
not
None
:
assert
len
(
self
.
data
)
==
len
(
self
.
refs
)
if
self
.
_iterating
:
if
self
.
_iterating
:
self
.
_pending_removals
.
append
(
k
)
self
.
_pending_removals
.
append
(
k
)
else
:
else
:
if
self
.
refs
.
get
(
k
)
is
k
:
del
self
.
data
[
k
]
del
self
.
data
[
k
]
del
self
.
refs
[
k
]
self
.
_remove
=
remove
self
.
_remove
=
remove
# A list of dead weakrefs (keys to be removed)
# A list of dead weakrefs (keys to be removed)
self
.
_pending_removals
=
[]
self
.
_pending_removals
=
[]
...
@@ -331,20 +302,14 @@ class WeakKeyDictionary(UserDict.UserDict):
...
@@ -331,20 +302,14 @@ class WeakKeyDictionary(UserDict.UserDict):
# However, it means keys may already have been removed.
# However, it means keys may already have been removed.
l
=
self
.
_pending_removals
l
=
self
.
_pending_removals
d
=
self
.
data
d
=
self
.
data
r
=
self
.
refs
while
l
:
while
l
:
try
:
try
:
k
=
l
.
pop
()
del
d
[
l
.
pop
()]
if
self
.
refs
.
get
(
k
)
is
k
:
del
d
[
k
]
del
r
[
k
]
except
KeyError
:
except
KeyError
:
pass
pass
def
__delitem__
(
self
,
key
):
def
__delitem__
(
self
,
key
):
r
=
ref
(
key
)
del
self
.
data
[
ref
(
key
)]
del
self
.
data
[
r
]
del
self
.
refs
[
r
]
def
__getitem__
(
self
,
key
):
def
__getitem__
(
self
,
key
):
return
self
.
data
[
ref
(
key
)]
return
self
.
data
[
ref
(
key
)]
...
@@ -353,11 +318,7 @@ class WeakKeyDictionary(UserDict.UserDict):
...
@@ -353,11 +318,7 @@ class WeakKeyDictionary(UserDict.UserDict):
return
"<WeakKeyDictionary at %s>"
%
id
(
self
)
return
"<WeakKeyDictionary at %s>"
%
id
(
self
)
def
__setitem__
(
self
,
key
,
value
):
def
__setitem__
(
self
,
key
,
value
):
r
=
ref
(
key
,
self
.
_remove
)
self
.
data
[
ref
(
key
,
self
.
_remove
)]
=
value
self
.
data
.
pop
(
r
,
None
)
self
.
refs
.
pop
(
r
,
None
)
self
.
data
[
r
]
=
value
self
.
refs
[
r
]
=
r
def
copy
(
self
):
def
copy
(
self
):
new
=
WeakKeyDictionary
()
new
=
WeakKeyDictionary
()
...
@@ -460,28 +421,23 @@ class WeakKeyDictionary(UserDict.UserDict):
...
@@ -460,28 +421,23 @@ class WeakKeyDictionary(UserDict.UserDict):
def
popitem
(
self
):
def
popitem
(
self
):
while
1
:
while
1
:
_
,
key
=
self
.
refs
.
popitem
()
key
,
value
=
self
.
data
.
popitem
()
value
=
self
.
data
.
pop
(
key
)
o
=
key
()
o
=
key
()
if
o
is
not
None
:
if
o
is
not
None
:
return
o
,
value
return
o
,
value
def
pop
(
self
,
key
,
*
args
):
def
pop
(
self
,
key
,
*
args
):
r
=
ref
(
key
)
return
self
.
data
.
pop
(
ref
(
key
),
*
args
)
self
.
refs
.
pop
(
r
,
None
)
return
self
.
data
.
pop
(
r
,
*
args
)
def
setdefault
(
self
,
key
,
default
=
None
):
def
setdefault
(
self
,
key
,
default
=
None
):
if
key
not
in
self
:
return
self
.
data
.
setdefault
(
ref
(
key
,
self
.
_remove
),
default
)
self
[
key
]
=
default
return
default
return
self
[
key
]
def
update
(
self
,
dict
=
None
,
**
kwargs
):
def
update
(
self
,
dict
=
None
,
**
kwargs
):
d
=
self
.
data
if
dict
is
not
None
:
if
dict
is
not
None
:
if
not
hasattr
(
dict
,
"items"
):
if
not
hasattr
(
dict
,
"items"
):
dict
=
type
({})(
dict
)
dict
=
type
({})(
dict
)
for
key
,
value
in
dict
.
items
():
for
key
,
value
in
dict
.
items
():
self
[
key
]
=
value
d
[
ref
(
key
,
self
.
_remove
)
]
=
value
if
len
(
kwargs
):
if
len
(
kwargs
):
self
.
update
(
kwargs
)
self
.
update
(
kwargs
)
from_cpython/Modules/_collectionsmodule.c
View file @
183aa5f7
...
@@ -55,9 +55,7 @@ typedef struct BLOCK {
...
@@ -55,9 +55,7 @@ typedef struct BLOCK {
struct
BLOCK
*
leftlink
;
struct
BLOCK
*
leftlink
;
}
block
;
}
block
;
// Pyston change: disable free block cache
#define MAXFREEBLOCKS 10
// #define MAXFREEBLOCKS 10
#define MAXFREEBLOCKS 0
static
Py_ssize_t
numfreeblocks
=
0
;
static
Py_ssize_t
numfreeblocks
=
0
;
static
block
*
freeblocks
[
MAXFREEBLOCKS
];
static
block
*
freeblocks
[
MAXFREEBLOCKS
];
...
...
from_cpython/Modules/_ctypes/cfield.c
View file @
183aa5f7
...
@@ -1291,9 +1291,7 @@ s_get(void *ptr, Py_ssize_t size)
...
@@ -1291,9 +1291,7 @@ s_get(void *ptr, Py_ssize_t size)
*/
*/
slen
=
strlen
(
PyString_AS_STRING
(
result
));
slen
=
strlen
(
PyString_AS_STRING
(
result
));
size
=
min
(
size
,
(
Py_ssize_t
)
slen
);
size
=
min
(
size
,
(
Py_ssize_t
)
slen
);
if
(
result
->
ob_refcnt
==
1
)
{
// Pyston change: no ob_refcnt
if
(
0
/*result->ob_refcnt == 1*/
)
{
/* shorten the result */
/* shorten the result */
_PyString_Resize
(
&
result
,
size
);
_PyString_Resize
(
&
result
,
size
);
return
result
;
return
result
;
...
...
from_cpython/Modules/_elementtree.c
View file @
183aa5f7
...
@@ -1791,8 +1791,7 @@ treebuilder_handle_data(TreeBuilderObject* self, PyObject* data)
...
@@ -1791,8 +1791,7 @@ treebuilder_handle_data(TreeBuilderObject* self, PyObject* data)
Py_INCREF
(
data
);
self
->
data
=
data
;
Py_INCREF
(
data
);
self
->
data
=
data
;
}
else
{
}
else
{
/* more than one item; use a list to collect items */
/* more than one item; use a list to collect items */
// Pyston change: Py_REFCNT(self->data) -> 2
if
(
PyString_CheckExact
(
self
->
data
)
&&
Py_REFCNT
(
self
->
data
)
==
1
&&
if
(
PyString_CheckExact
(
self
->
data
)
&&
/*Py_REFCNT(self->data)*/
2
==
1
&&
PyString_CheckExact
(
data
)
&&
PyString_GET_SIZE
(
data
)
==
1
)
{
PyString_CheckExact
(
data
)
&&
PyString_GET_SIZE
(
data
)
==
1
)
{
/* expat often generates single character data sections; handle
/* expat often generates single character data sections; handle
the most common case by resizing the existing string... */
the most common case by resizing the existing string... */
...
...
from_cpython/Modules/_functoolsmodule.c
View file @
183aa5f7
...
@@ -35,8 +35,7 @@ functools_reduce(PyObject *self, PyObject *args)
...
@@ -35,8 +35,7 @@ functools_reduce(PyObject *self, PyObject *args)
for
(;;)
{
for
(;;)
{
PyObject
*
op2
;
PyObject
*
op2
;
// Pyston change: can't do these sorts of refcount optimizations:
if
(
args
->
ob_refcnt
>
1
)
{
if
(
1
/*args->ob_refcnt > 1*/
)
{
Py_DECREF
(
args
);
Py_DECREF
(
args
);
if
((
args
=
PyTuple_New
(
2
))
==
NULL
)
if
((
args
=
PyTuple_New
(
2
))
==
NULL
)
goto
Fail
;
goto
Fail
;
...
...
from_cpython/Modules/_sre.c
View file @
183aa5f7
...
@@ -257,9 +257,7 @@ static void
...
@@ -257,9 +257,7 @@ static void
data_stack_dealloc
(
SRE_STATE
*
state
)
data_stack_dealloc
(
SRE_STATE
*
state
)
{
{
if
(
state
->
data_stack
)
{
if
(
state
->
data_stack
)
{
// Pyston change: use malloc
PyMem_FREE
(
state
->
data_stack
);
// PyMem_FREE(state->data_stack);
free
(
state
->
data_stack
);
state
->
data_stack
=
NULL
;
state
->
data_stack
=
NULL
;
}
}
state
->
data_stack_size
=
state
->
data_stack_base
=
0
;
state
->
data_stack_size
=
state
->
data_stack_base
=
0
;
...
@@ -275,9 +273,7 @@ data_stack_grow(SRE_STATE* state, Py_ssize_t size)
...
@@ -275,9 +273,7 @@ data_stack_grow(SRE_STATE* state, Py_ssize_t size)
void
*
stack
;
void
*
stack
;
cursize
=
minsize
+
minsize
/
4
+
1024
;
cursize
=
minsize
+
minsize
/
4
+
1024
;
TRACE
((
"allocate/grow stack %"
PY_FORMAT_SIZE_T
"d
\n
"
,
cursize
));
TRACE
((
"allocate/grow stack %"
PY_FORMAT_SIZE_T
"d
\n
"
,
cursize
));
// Pyston change: use malloc
stack
=
PyMem_REALLOC
(
state
->
data_stack
,
cursize
);
// stack = PyMem_REALLOC(state->data_stack, cursize);
stack
=
realloc
(
state
->
data_stack
,
cursize
);
if
(
!
stack
)
{
if
(
!
stack
)
{
data_stack_dealloc
(
state
);
data_stack_dealloc
(
state
);
return
SRE_ERROR_MEMORY
;
return
SRE_ERROR_MEMORY
;
...
@@ -1180,9 +1176,7 @@ entrance:
...
@@ -1180,9 +1176,7 @@ entrance:
ctx
->
pattern
[
1
],
ctx
->
pattern
[
2
]));
ctx
->
pattern
[
1
],
ctx
->
pattern
[
2
]));
/* install new repeat context */
/* install new repeat context */
// Pyston change: use malloc
ctx
->
u
.
rep
=
(
SRE_REPEAT
*
)
PyObject_MALLOC
(
sizeof
(
*
ctx
->
u
.
rep
));
// ctx->u.rep = (SRE_REPEAT*) PyObject_MALLOC(sizeof(*ctx->u.rep));
ctx
->
u
.
rep
=
(
SRE_REPEAT
*
)
malloc
(
sizeof
(
*
ctx
->
u
.
rep
));
if
(
!
ctx
->
u
.
rep
)
{
if
(
!
ctx
->
u
.
rep
)
{
PyErr_NoMemory
();
PyErr_NoMemory
();
RETURN_FAILURE
;
RETURN_FAILURE
;
...
@@ -1196,9 +1190,7 @@ entrance:
...
@@ -1196,9 +1190,7 @@ entrance:
state
->
ptr
=
ctx
->
ptr
;
state
->
ptr
=
ctx
->
ptr
;
DO_JUMP
(
JUMP_REPEAT
,
jump_repeat
,
ctx
->
pattern
+
ctx
->
pattern
[
0
]);
DO_JUMP
(
JUMP_REPEAT
,
jump_repeat
,
ctx
->
pattern
+
ctx
->
pattern
[
0
]);
state
->
repeat
=
ctx
->
u
.
rep
->
prev
;
state
->
repeat
=
ctx
->
u
.
rep
->
prev
;
// Pyston change: use malloc
PyObject_FREE
(
ctx
->
u
.
rep
);
// PyObject_FREE(ctx->u.rep);
free
(
ctx
->
u
.
rep
);
if
(
ret
)
{
if
(
ret
)
{
RETURN_ON_ERROR
(
ret
);
RETURN_ON_ERROR
(
ret
);
...
...
from_cpython/Modules/cPickle.c
View file @
183aa5f7
...
@@ -5955,6 +5955,7 @@ init_stuff(PyObject *module_dict)
...
@@ -5955,6 +5955,7 @@ init_stuff(PyObject *module_dict)
if
(
!
(
t
=
PyImport_ImportModule
(
"__builtin__"
)))
return
-
1
;
if
(
!
(
t
=
PyImport_ImportModule
(
"__builtin__"
)))
return
-
1
;
if
(
PyDict_SetItemString
(
module_dict
,
"__builtins__"
,
t
)
<
0
)
if
(
PyDict_SetItemString
(
module_dict
,
"__builtins__"
,
t
)
<
0
)
return
-
1
;
return
-
1
;
// Pyston change: I think you need this
Py_DECREF
(
t
);
Py_DECREF
(
t
);
if
(
!
(
t
=
PyDict_New
()))
return
-
1
;
if
(
!
(
t
=
PyDict_New
()))
return
-
1
;
...
...
from_cpython/Modules/itertoolsmodule.c
View file @
183aa5f7
...
@@ -405,7 +405,7 @@ static void
...
@@ -405,7 +405,7 @@ static void
teedataobject_safe_decref
(
PyObject
*
obj
)
teedataobject_safe_decref
(
PyObject
*
obj
)
{
{
while
(
obj
&&
Py_TYPE
(
obj
)
==
&
teedataobject_type
&&
while
(
obj
&&
Py_TYPE
(
obj
)
==
&
teedataobject_type
&&
2
/*Pyston change, was: Py_REFCNT(obj)*/
==
1
)
{
Py_REFCNT
(
obj
)
==
1
)
{
PyObject
*
nextlink
=
((
teedataobject
*
)
obj
)
->
nextlink
;
PyObject
*
nextlink
=
((
teedataobject
*
)
obj
)
->
nextlink
;
((
teedataobject
*
)
obj
)
->
nextlink
=
NULL
;
((
teedataobject
*
)
obj
)
->
nextlink
=
NULL
;
Py_DECREF
(
obj
);
Py_DECREF
(
obj
);
...
@@ -1942,7 +1942,7 @@ product_next(productobject *lz)
...
@@ -1942,7 +1942,7 @@ product_next(productobject *lz)
Py_ssize_t
*
indices
=
lz
->
indices
;
Py_ssize_t
*
indices
=
lz
->
indices
;
/* Copy the previous result tuple or re-use it if available */
/* Copy the previous result tuple or re-use it if available */
if
(
2
/*Pyston change, was: Py_REFCNT(result)*/
>
1
)
{
if
(
Py_REFCNT
(
result
)
>
1
)
{
PyObject
*
old_result
=
result
;
PyObject
*
old_result
=
result
;
result
=
PyTuple_New
(
npools
);
result
=
PyTuple_New
(
npools
);
if
(
result
==
NULL
)
if
(
result
==
NULL
)
...
@@ -1956,8 +1956,7 @@ product_next(productobject *lz)
...
@@ -1956,8 +1956,7 @@ product_next(productobject *lz)
Py_DECREF
(
old_result
);
Py_DECREF
(
old_result
);
}
}
/* Now, we've got the only copy so we can update it in-place */
/* Now, we've got the only copy so we can update it in-place */
// Pyston change: safe to comment this out since we will always create a new tuple:
assert
(
npools
==
0
||
Py_REFCNT
(
result
)
==
1
);
// assert (npools==0 || Py_REFCNT(result) == 1);
/* Update the pool indices right-to-left. Only advance to the
/* Update the pool indices right-to-left. Only advance to the
next pool when the previous one rolls-over */
next pool when the previous one rolls-over */
...
@@ -2171,7 +2170,7 @@ combinations_next(combinationsobject *co)
...
@@ -2171,7 +2170,7 @@ combinations_next(combinationsobject *co)
}
}
}
else
{
}
else
{
/* Copy the previous result tuple or re-use it if available */
/* Copy the previous result tuple or re-use it if available */
if
(
2
/*Pyston change, was: Py_REFCNT(result)*/
>
1
)
{
if
(
Py_REFCNT
(
result
)
>
1
)
{
PyObject
*
old_result
=
result
;
PyObject
*
old_result
=
result
;
result
=
PyTuple_New
(
r
);
result
=
PyTuple_New
(
r
);
if
(
result
==
NULL
)
if
(
result
==
NULL
)
...
@@ -2188,7 +2187,7 @@ combinations_next(combinationsobject *co)
...
@@ -2188,7 +2187,7 @@ combinations_next(combinationsobject *co)
* CPython's empty tuple is a singleton and cached in
* CPython's empty tuple is a singleton and cached in
* PyTuple's freelist.
* PyTuple's freelist.
*/
*/
assert
(
r
==
0
||
2
/*Pyston change, was: Py_REFCNT(result)*/
==
1
);
assert
(
r
==
0
||
Py_REFCNT
(
result
)
==
1
);
/* Scan indices right-to-left until finding one that is not
/* Scan indices right-to-left until finding one that is not
at its maximum (i + n - r). */
at its maximum (i + n - r). */
...
@@ -2420,7 +2419,7 @@ cwr_next(cwrobject *co)
...
@@ -2420,7 +2419,7 @@ cwr_next(cwrobject *co)
}
}
}
else
{
}
else
{
/* Copy the previous result tuple or re-use it if available */
/* Copy the previous result tuple or re-use it if available */
if
(
2
/*Pyston change, was: Py_REFCNT(result)*/
>
1
)
{
if
(
Py_REFCNT
(
result
)
>
1
)
{
PyObject
*
old_result
=
result
;
PyObject
*
old_result
=
result
;
result
=
PyTuple_New
(
r
);
result
=
PyTuple_New
(
r
);
if
(
result
==
NULL
)
if
(
result
==
NULL
)
...
@@ -2435,7 +2434,7 @@ cwr_next(cwrobject *co)
...
@@ -2435,7 +2434,7 @@ cwr_next(cwrobject *co)
}
}
/* Now, we've got the only copy so we can update it in-place CPython's
/* Now, we've got the only copy so we can update it in-place CPython's
empty tuple is a singleton and cached in PyTuple's freelist. */
empty tuple is a singleton and cached in PyTuple's freelist. */
assert
(
r
==
0
||
2
/*Pyston change, was: Py_REFCNT(result)*/
==
1
);
assert
(
r
==
0
||
Py_REFCNT
(
result
)
==
1
);
/* Scan indices right-to-left until finding one that is not
/* Scan indices right-to-left until finding one that is not
* at its maximum (n-1). */
* at its maximum (n-1). */
...
@@ -2683,7 +2682,7 @@ permutations_next(permutationsobject *po)
...
@@ -2683,7 +2682,7 @@ permutations_next(permutationsobject *po)
goto
empty
;
goto
empty
;
/* Copy the previous result tuple or re-use it if available */
/* Copy the previous result tuple or re-use it if available */
if
(
2
/*Pyston change, was: Py_REFCNT(result)*/
>
1
)
{
if
(
Py_REFCNT
(
result
)
>
1
)
{
PyObject
*
old_result
=
result
;
PyObject
*
old_result
=
result
;
result
=
PyTuple_New
(
r
);
result
=
PyTuple_New
(
r
);
if
(
result
==
NULL
)
if
(
result
==
NULL
)
...
@@ -2697,7 +2696,7 @@ permutations_next(permutationsobject *po)
...
@@ -2697,7 +2696,7 @@ permutations_next(permutationsobject *po)
Py_DECREF
(
old_result
);
Py_DECREF
(
old_result
);
}
}
/* Now, we've got the only copy so we can update it in-place */
/* Now, we've got the only copy so we can update it in-place */
assert
(
r
==
0
||
2
/*Pyston change, was: Py_REFCNT(result)*/
==
1
);
assert
(
r
==
0
||
Py_REFCNT
(
result
)
==
1
);
/* Decrement rightmost cycle, moving leftward upon zero rollover */
/* Decrement rightmost cycle, moving leftward upon zero rollover */
for
(
i
=
r
-
1
;
i
>=
0
;
i
--
)
{
for
(
i
=
r
-
1
;
i
>=
0
;
i
--
)
{
...
@@ -3584,7 +3583,7 @@ izip_next(izipobject *lz)
...
@@ -3584,7 +3583,7 @@ izip_next(izipobject *lz)
if
(
tuplesize
==
0
)
if
(
tuplesize
==
0
)
return
NULL
;
return
NULL
;
if
(
2
/*Pyston change, was: Py_REFCNT(result)*/
==
1
)
{
if
(
Py_REFCNT
(
result
)
==
1
)
{
Py_INCREF
(
result
);
Py_INCREF
(
result
);
for
(
i
=
0
;
i
<
tuplesize
;
i
++
)
{
for
(
i
=
0
;
i
<
tuplesize
;
i
++
)
{
it
=
PyTuple_GET_ITEM
(
lz
->
ittuple
,
i
);
it
=
PyTuple_GET_ITEM
(
lz
->
ittuple
,
i
);
...
@@ -3929,7 +3928,7 @@ izip_longest_next(iziplongestobject *lz)
...
@@ -3929,7 +3928,7 @@ izip_longest_next(iziplongestobject *lz)
return
NULL
;
return
NULL
;
if
(
lz
->
numactive
==
0
)
if
(
lz
->
numactive
==
0
)
return
NULL
;
return
NULL
;
if
(
2
/*Pyston change, was: Py_REFCNT(result)*/
==
1
)
{
if
(
Py_REFCNT
(
result
)
==
1
)
{
Py_INCREF
(
result
);
Py_INCREF
(
result
);
for
(
i
=
0
;
i
<
tuplesize
;
i
++
)
{
for
(
i
=
0
;
i
<
tuplesize
;
i
++
)
{
it
=
PyTuple_GET_ITEM
(
lz
->
ittuple
,
i
);
it
=
PyTuple_GET_ITEM
(
lz
->
ittuple
,
i
);
...
@@ -4081,34 +4080,6 @@ static PyMethodDef module_methods[] = {
...
@@ -4081,34 +4080,6 @@ static PyMethodDef module_methods[] = {
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
// Pyston change: These are types defined in this file that I manually
// checked. The ones that aren't commented out have a `tp_dealloc` that
// doesn't do anything in Pyston as we switched to garbage collection and
// the finalizer logic in Pyston wants to know that for optimization purposes.
PyTypeObject
*
Itertool_SafeDealloc_Types
[]
=
{
// &combinations_type,
// &cwr_type,
&
cycle_type
,
&
dropwhile_type
,
&
takewhile_type
,
&
islice_type
,
&
starmap_type
,
&
imap_type
,
&
chain_type
,
&
compress_type
,
&
ifilter_type
,
&
ifilterfalse_type
,
&
count_type
,
&
izip_type
,
&
iziplongest_type
,
// &permutations_type,
// &product_type,
&
repeat_type
,
&
groupby_type
,
NULL
};
PyMODINIT_FUNC
PyMODINIT_FUNC
inititertools
(
void
)
inititertools
(
void
)
{
{
...
...
from_cpython/Objects/fileobject.c
View file @
183aa5f7
...
@@ -429,9 +429,7 @@ close_the_file(PyFileObject *f)
...
@@ -429,9 +429,7 @@ close_the_file(PyFileObject *f)
if
(
local_fp
!=
NULL
)
{
if
(
local_fp
!=
NULL
)
{
local_close
=
f
->
f_close
;
local_close
=
f
->
f_close
;
if
(
local_close
!=
NULL
&&
f
->
unlocked_count
>
0
)
{
if
(
local_close
!=
NULL
&&
f
->
unlocked_count
>
0
)
{
// Pyston change:
if
(
f
->
ob_refcnt
>
0
)
{
// if (f->ob_refcnt > 0) {
if
(
/*f->ob_refcnt*/
2
>
0
)
{
PyErr_SetString
(
PyExc_IOError
,
PyErr_SetString
(
PyExc_IOError
,
"close() called during concurrent "
"close() called during concurrent "
"operation on the same file object."
);
"operation on the same file object."
);
...
@@ -1600,9 +1598,7 @@ PyFile_GetLine(PyObject *f, int n)
...
@@ -1600,9 +1598,7 @@ PyFile_GetLine(PyObject *f, int n)
"EOF when reading a line"
);
"EOF when reading a line"
);
}
}
else
if
(
s
[
len
-
1
]
==
'\n'
)
{
else
if
(
s
[
len
-
1
]
==
'\n'
)
{
// Pyston change:
if
(
result
->
ob_refcnt
==
1
)
{
// if (result->ob_refcnt == 1) {
if
(
/*result->ob_refcnt*/
2
==
1
)
{
if
(
_PyString_Resize
(
&
result
,
len
-
1
))
if
(
_PyString_Resize
(
&
result
,
len
-
1
))
return
NULL
;
return
NULL
;
}
}
...
@@ -1625,9 +1621,7 @@ PyFile_GetLine(PyObject *f, int n)
...
@@ -1625,9 +1621,7 @@ PyFile_GetLine(PyObject *f, int n)
"EOF when reading a line"
);
"EOF when reading a line"
);
}
}
else
if
(
s
[
len
-
1
]
==
'\n'
)
{
else
if
(
s
[
len
-
1
]
==
'\n'
)
{
// Pyston change:
if
(
result
->
ob_refcnt
==
1
)
// if (result->ob_refcnt == 1)
if
(
/*result->ob_refcnt*/
2
==
1
)
PyUnicode_Resize
(
&
result
,
len
-
1
);
PyUnicode_Resize
(
&
result
,
len
-
1
);
else
{
else
{
PyObject
*
v
;
PyObject
*
v
;
...
...
from_cpython/Objects/unicodeobject.c
View file @
183aa5f7
...
@@ -53,8 +53,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
...
@@ -53,8 +53,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* Limit for the Unicode object free list */
/* Limit for the Unicode object free list */
// Pyston change: set this to 0 (was 1024) to disable the free list since we can't track that through our GC.
#define PyUnicode_MAXFREELIST 1024
#define PyUnicode_MAXFREELIST 0
/* Limit for the Unicode object free list stay alive optimization.
/* Limit for the Unicode object free list stay alive optimization.
...
@@ -356,7 +355,7 @@ int _PyUnicode_Resize(PyUnicodeObject **unicode, Py_ssize_t length)
...
@@ -356,7 +355,7 @@ int _PyUnicode_Resize(PyUnicodeObject **unicode, Py_ssize_t length)
return
-
1
;
return
-
1
;
}
}
v
=
*
unicode
;
v
=
*
unicode
;
if
(
v
==
NULL
||
!
PyUnicode_Check
(
v
)
||
/* Pyston change, can't check this: Py_REFCNT(v) != 1 || */
length
<
0
)
{
if
(
v
==
NULL
||
!
PyUnicode_Check
(
v
)
||
Py_REFCNT
(
v
)
!=
1
||
length
<
0
)
{
PyErr_BadInternalCall
();
PyErr_BadInternalCall
();
return
-
1
;
return
-
1
;
}
}
...
...
from_cpython/Python/dtoa.c
View file @
183aa5f7
...
@@ -124,12 +124,8 @@
...
@@ -124,12 +124,8 @@
#include "float.h"
#include "float.h"
// Pyston change: use normal malloc allocator because it's faster and we can't use the GC
#define MALLOC PyMem_Malloc
// because the custom memory managment functions inside this file are not compatible with it.
#define FREE PyMem_Free
// #define MALLOC PyMem_Malloc
// #define FREE PyMem_Free
#define MALLOC malloc
#define FREE free
/* This code should also work for ARM mixed-endian format on little-endian
/* This code should also work for ARM mixed-endian format on little-endian
machines, where doubles have byte order 45670123 (in increasing address
machines, where doubles have byte order 45670123 (in increasing address
...
...
from_cpython/Python/import.c
View file @
183aa5f7
...
@@ -440,7 +440,6 @@ static char* sys_files[] = {
...
@@ -440,7 +440,6 @@ static char* sys_files[] = {
/* Un-initialize things, as good as we can */
/* Un-initialize things, as good as we can */
// Pyston change: we don't support calling cleanup currently
void
void
PyImport_Cleanup
(
void
)
PyImport_Cleanup
(
void
)
{
{
...
...
from_cpython/Python/pyarena.c
View file @
183aa5f7
...
@@ -130,8 +130,7 @@ block_alloc(block *b, size_t size)
...
@@ -130,8 +130,7 @@ block_alloc(block *b, size_t size)
PyArena
*
PyArena
*
PyArena_New
()
PyArena_New
()
{
{
// Pyston change: conservatively allocate the PyArena metadata object
PyArena
*
arena
=
(
PyArena
*
)
malloc
(
sizeof
(
PyArena
));
PyArena
*
arena
=
(
PyArena
*
)
PyMem_Malloc
(
sizeof
(
PyArena
));
if
(
!
arena
)
if
(
!
arena
)
return
(
PyArena
*
)
PyErr_NoMemory
();
return
(
PyArena
*
)
PyErr_NoMemory
();
...
@@ -177,8 +176,7 @@ PyArena_Free(PyArena *arena)
...
@@ -177,8 +176,7 @@ PyArena_Free(PyArena *arena)
*/
*/
Py_DECREF
(
arena
->
a_objects
);
Py_DECREF
(
arena
->
a_objects
);
// Pyston change:
free
(
arena
);
PyMem_Free
(
arena
);
}
}
void
*
void
*
...
...
src/runtime/capi.cpp
View file @
183aa5f7
...
@@ -1359,10 +1359,6 @@ extern "C" PyOS_sighandler_t PyOS_getsig(int sig) noexcept {
...
@@ -1359,10 +1359,6 @@ extern "C" PyOS_sighandler_t PyOS_getsig(int sig) noexcept {
}
}
extern
"C"
PyOS_sighandler_t
PyOS_setsig
(
int
sig
,
PyOS_sighandler_t
handler
)
noexcept
{
extern
"C"
PyOS_sighandler_t
PyOS_setsig
(
int
sig
,
PyOS_sighandler_t
handler
)
noexcept
{
if
(
sig
==
SIGUSR2
)
{
Py_FatalError
(
"SIGUSR2 is reserved for Pyston internal use"
);
}
#ifdef HAVE_SIGACTION
#ifdef HAVE_SIGACTION
/* Some code in Modules/signalmodule.c depends on sigaction() being
/* Some code in Modules/signalmodule.c depends on sigaction() being
* used here if HAVE_SIGACTION is defined. Fix that if this code
* used here if HAVE_SIGACTION is defined. Fix that if this code
...
...
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