[pypy-commit] pypy py3.5: hg merge py3k
rlamy
pypy.commits at gmail.com
Wed Jun 8 14:59:56 EDT 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5
Changeset: r85041:038f4cc08cb1
Date: 2016-06-08 19:59 +0100
http://bitbucket.org/pypy/pypy/changeset/038f4cc08cb1/
Log: hg merge py3k
diff too long, truncating to 2000 out of 40436 lines
diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -22,3 +22,7 @@
bbd45126bc691f669c4ebdfbd74456cd274c6b92 release-5.0.1
3260adbeba4a8b6659d1cc0d0b41f266769b74da release-5.1
b0a649e90b6642251fb4a765fe5b27a97b1319a9 release-5.1.1
+80ef432a32d9baa4b3c5a54c215e8ebe499f6374 release-5.1.2
+40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2
+40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2
+c09c19272c990a0611b17569a0085ad1ab00c8ff release-pypy2.7-v5.3
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -43,17 +43,17 @@
Samuele Pedroni
Matti Picus
Alex Gaynor
+ Philip Jenvey
Brian Kearns
- Philip Jenvey
+ Ronan Lamy
Michael Hudson
- Ronan Lamy
+ Manuel Jacob
David Schneider
- Manuel Jacob
Holger Krekel
Christian Tismer
Hakan Ardo
+ Richard Plangger
Benjamin Peterson
- Richard Plangger
Anders Chrigstrom
Eric van Riet Paap
Wim Lavrijsen
@@ -93,9 +93,9 @@
stian
Jan de Mooij
Tyler Wade
+ Vincent Legoll
Michael Foord
Stephan Diehl
- Vincent Legoll
Stefan Schwarzer
Valentino Volonghi
Tomek Meka
@@ -104,17 +104,20 @@
Bruno Gola
David Malcolm
Jean-Paul Calderone
+ Mark Young
Timo Paulssen
Squeaky
+ Devin Jeanpierre
Marius Gedminas
Alexandre Fayolle
Simon Burton
+ Stefano Rivera
Martin Matusiak
Konstantin Lopuhin
- Stefano Rivera
Wenzhu Man
John Witulski
Laurence Tratt
+ Raffael Tfirst
Ivan Sichmann Freitas
Greg Price
Dario Bertini
@@ -122,13 +125,13 @@
Simon Cross
Edd Barrett
Andreas Stührk
+ Tobias Pape
Jean-Philippe St. Pierre
Guido van Rossum
Pavel Vinogradov
Spenser Bauman
Jeremy Thurgood
Paweł Piotr Przeradowski
- Tobias Pape
Paul deGrandis
Ilya Osadchiy
marky1991
@@ -140,7 +143,6 @@
Georg Brandl
Bert Freudenberg
Stian Andreassen
- Mark Young
Wanja Saatkamp
Gerald Klix
Mike Blume
@@ -156,11 +158,13 @@
Dusty Phillips
Lukas Renggli
Guenter Jantzen
+ William Leslie
Ned Batchelder
Tim Felgentreff
Anton Gulenko
Amit Regmi
Ben Young
+ Sergey Matyunin
Nicolas Chauvat
Andrew Durdin
Andrew Chambers
@@ -171,9 +175,9 @@
Yichao Yu
Rocco Moretti
Gintautas Miliauskas
- Devin Jeanpierre
Michael Twomey
Lucian Branescu Mihaila
+ anatoly techtonik
Gabriel Lavoie
Olivier Dormond
Jared Grubb
@@ -183,8 +187,6 @@
Brian Dorsey
Victor Stinner
Andrews Medina
- anatoly techtonik
- Sergey Matyunin
Stuart Williams
Jasper Schulz
Christian Hudon
@@ -208,11 +210,11 @@
Alex Perry
Vaibhav Sood
Alan McIntyre
- William Leslie
Alexander Sedov
Attila Gobi
Jasper.Schulz
Christopher Pope
+ Florin Papa
Christian Tismer
Marc Abramowitz
Dan Stromberg
@@ -228,7 +230,6 @@
Lukas Vacek
Kunal Grover
Andrew Dalke
- Florin Papa
Sylvain Thenault
Jakub Stasiak
Nathan Taylor
@@ -270,8 +271,9 @@
Yury V. Zaytsev
Anna Katrina Dominguez
Bobby Impollonia
- timo at eistee.fritz.box
+ Vasantha Ganesh K
Andrew Thompson
+ florinpapa
Yusei Tahara
Aaron Tubbs
Ben Darnell
@@ -295,9 +297,9 @@
Akira Li
Gustavo Niemeyer
Stephan Busemann
- florinpapa
Rafał Gałczyński
Matt Bogosian
+ timo
Christian Muirhead
Berker Peksag
James Lan
diff --git a/TODO b/TODO
deleted file mode 100644
--- a/TODO
+++ /dev/null
@@ -1,2 +0,0 @@
-* reduce size of generated c code from slot definitions in slotdefs.
-* remove broken DEBUG_REFCOUNT from pyobject.py
diff --git a/dotviewer/graphserver.py b/dotviewer/graphserver.py
--- a/dotviewer/graphserver.py
+++ b/dotviewer/graphserver.py
@@ -143,6 +143,11 @@
if __name__ == '__main__':
if len(sys.argv) != 2:
+ if len(sys.argv) == 1:
+ # start locally
+ import sshgraphserver
+ sshgraphserver.ssh_graph_server(['LOCAL'])
+ sys.exit(0)
print >> sys.stderr, __doc__
sys.exit(2)
if sys.argv[1] == '--stdio':
diff --git a/dotviewer/sshgraphserver.py b/dotviewer/sshgraphserver.py
--- a/dotviewer/sshgraphserver.py
+++ b/dotviewer/sshgraphserver.py
@@ -4,11 +4,14 @@
Usage:
sshgraphserver.py hostname [more args for ssh...]
+ sshgraphserver.py LOCAL
This logs in to 'hostname' by passing the arguments on the command-line
to ssh. No further configuration is required: it works for all programs
using the dotviewer library as long as they run on 'hostname' under the
same username as the one sshgraphserver logs as.
+
+If 'hostname' is the string 'LOCAL', then it starts locally without ssh.
"""
import graphserver, socket, subprocess, random
@@ -18,12 +21,19 @@
s1 = socket.socket()
s1.bind(('127.0.0.1', socket.INADDR_ANY))
localhost, localport = s1.getsockname()
- remoteport = random.randrange(10000, 20000)
- # ^^^ and just hope there is no conflict
- args = ['ssh', '-S', 'none', '-C', '-R%d:127.0.0.1:%d' % (remoteport, localport)]
- args = args + sshargs + ['python -u -c "exec input()"']
- print ' '.join(args[:-1])
+ if sshargs[0] != 'LOCAL':
+ remoteport = random.randrange(10000, 20000)
+ # ^^^ and just hope there is no conflict
+
+ args = ['ssh', '-S', 'none', '-C', '-R%d:127.0.0.1:%d' % (
+ remoteport, localport)]
+ args = args + sshargs + ['python -u -c "exec input()"']
+ else:
+ remoteport = localport
+ args = ['python', '-u', '-c', 'exec input()']
+
+ print ' '.join(args)
p = subprocess.Popen(args, bufsize=0,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
diff --git a/lib-python/2.7/subprocess.py b/lib-python/2.7/subprocess.py
--- a/lib-python/2.7/subprocess.py
+++ b/lib-python/2.7/subprocess.py
@@ -834,54 +834,63 @@
c2pread, c2pwrite = None, None
errread, errwrite = None, None
+ ispread = False
if stdin is None:
p2cread = _subprocess.GetStdHandle(_subprocess.STD_INPUT_HANDLE)
if p2cread is None:
p2cread, _ = _subprocess.CreatePipe(None, 0)
+ ispread = True
elif stdin == PIPE:
p2cread, p2cwrite = _subprocess.CreatePipe(None, 0)
+ ispread = True
elif isinstance(stdin, int):
p2cread = msvcrt.get_osfhandle(stdin)
else:
# Assuming file-like object
p2cread = msvcrt.get_osfhandle(stdin.fileno())
- p2cread = self._make_inheritable(p2cread)
+ p2cread = self._make_inheritable(p2cread, ispread)
# We just duplicated the handle, it has to be closed at the end
to_close.add(p2cread)
if stdin == PIPE:
to_close.add(p2cwrite)
+ ispwrite = False
if stdout is None:
c2pwrite = _subprocess.GetStdHandle(_subprocess.STD_OUTPUT_HANDLE)
if c2pwrite is None:
_, c2pwrite = _subprocess.CreatePipe(None, 0)
+ ispwrite = True
elif stdout == PIPE:
c2pread, c2pwrite = _subprocess.CreatePipe(None, 0)
+ ispwrite = True
elif isinstance(stdout, int):
c2pwrite = msvcrt.get_osfhandle(stdout)
else:
# Assuming file-like object
c2pwrite = msvcrt.get_osfhandle(stdout.fileno())
- c2pwrite = self._make_inheritable(c2pwrite)
+ c2pwrite = self._make_inheritable(c2pwrite, ispwrite)
# We just duplicated the handle, it has to be closed at the end
to_close.add(c2pwrite)
if stdout == PIPE:
to_close.add(c2pread)
+ ispwrite = False
if stderr is None:
errwrite = _subprocess.GetStdHandle(_subprocess.STD_ERROR_HANDLE)
if errwrite is None:
_, errwrite = _subprocess.CreatePipe(None, 0)
+ ispwrite = True
elif stderr == PIPE:
errread, errwrite = _subprocess.CreatePipe(None, 0)
+ ispwrite = True
elif stderr == STDOUT:
- errwrite = c2pwrite.handle # pass id to not close it
+ errwrite = c2pwrite
elif isinstance(stderr, int):
errwrite = msvcrt.get_osfhandle(stderr)
else:
# Assuming file-like object
errwrite = msvcrt.get_osfhandle(stderr.fileno())
- errwrite = self._make_inheritable(errwrite)
+ errwrite = self._make_inheritable(errwrite, ispwrite)
# We just duplicated the handle, it has to be closed at the end
to_close.add(errwrite)
if stderr == PIPE:
@@ -892,13 +901,14 @@
errread, errwrite), to_close
- def _make_inheritable(self, handle):
+ def _make_inheritable(self, handle, close=False):
"""Return a duplicate of handle, which is inheritable"""
dupl = _subprocess.DuplicateHandle(_subprocess.GetCurrentProcess(),
handle, _subprocess.GetCurrentProcess(), 0, 1,
_subprocess.DUPLICATE_SAME_ACCESS)
- # If the initial handle was obtained with CreatePipe, close it.
- if not isinstance(handle, int):
+ # PyPy: If the initial handle was obtained with CreatePipe,
+ # close it.
+ if close:
handle.Close()
return dupl
diff --git a/lib-python/2.7/test/test_descr.py b/lib-python/2.7/test/test_descr.py
--- a/lib-python/2.7/test/test_descr.py
+++ b/lib-python/2.7/test/test_descr.py
@@ -1735,7 +1735,6 @@
("__reversed__", reversed, empty_seq, set(), {}),
("__length_hint__", list, zero, set(),
{"__iter__" : iden, "next" : stop}),
- ("__sizeof__", sys.getsizeof, zero, set(), {}),
("__instancecheck__", do_isinstance, return_true, set(), {}),
("__missing__", do_dict_missing, some_number,
set(("__class__",)), {}),
@@ -1747,6 +1746,8 @@
("__format__", format, format_impl, set(), {}),
("__dir__", dir, empty_seq, set(), {}),
]
+ if test_support.check_impl_detail():
+ specials.append(("__sizeof__", sys.getsizeof, zero, set(), {}))
class Checker(object):
def __getattr__(self, attr, test=self):
@@ -1768,10 +1769,6 @@
raise MyException
for name, runner, meth_impl, ok, env in specials:
- if name == '__length_hint__' or name == '__sizeof__':
- if not test_support.check_impl_detail():
- continue
-
class X(Checker):
pass
for attr, obj in env.iteritems():
diff --git a/lib-python/2.7/test/test_sys_settrace.py b/lib-python/2.7/test/test_sys_settrace.py
--- a/lib-python/2.7/test/test_sys_settrace.py
+++ b/lib-python/2.7/test/test_sys_settrace.py
@@ -328,8 +328,8 @@
def test_13_genexp(self):
if self.using_gc:
+ gc.enable()
test_support.gc_collect()
- gc.enable()
try:
self.run_test(generator_example)
# issue1265: if the trace function contains a generator,
diff --git a/lib-python/3/ctypes/test/test_python_api.py b/lib-python/3/ctypes/test/test_python_api.py
--- a/lib-python/3/ctypes/test/test_python_api.py
+++ b/lib-python/3/ctypes/test/test_python_api.py
@@ -18,6 +18,7 @@
class PythonAPITestCase(unittest.TestCase):
+ @xfail
def test_PyBytes_FromStringAndSize(self):
PyBytes_FromStringAndSize = pythonapi.PyBytes_FromStringAndSize
@@ -67,6 +68,7 @@
del pyobj
self.assertEqual(grc(s), ref)
+ @xfail
def test_PyOS_snprintf(self):
PyOS_snprintf = pythonapi.PyOS_snprintf
PyOS_snprintf.argtypes = POINTER(c_char), c_size_t, c_char_p
@@ -81,6 +83,7 @@
# not enough arguments
self.assertRaises(TypeError, PyOS_snprintf, buf)
+ @xfail
def test_pyobject_repr(self):
self.assertEqual(repr(py_object()), "py_object(<NULL>)")
self.assertEqual(repr(py_object(42)), "py_object(42)")
diff --git a/lib-python/3/ensurepip/__init__.py b/lib-python/3/ensurepip/__init__.py
--- a/lib-python/3/ensurepip/__init__.py
+++ b/lib-python/3/ensurepip/__init__.py
@@ -8,9 +8,9 @@
__all__ = ["version", "bootstrap"]
-_SETUPTOOLS_VERSION = "18.2"
+_SETUPTOOLS_VERSION = "21.2.1"
-_PIP_VERSION = "7.1.2"
+_PIP_VERSION = "8.1.2"
# pip currently requires ssl support, so we try to provide a nicer
# error message when that is missing (http://bugs.python.org/issue19744)
diff --git a/lib-python/3/ensurepip/_bundled/pip-8.1.2-py2.py3-none-any.whl b/lib-python/3/ensurepip/_bundled/pip-8.1.2-py2.py3-none-any.whl
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..cc49227a0c7e13757f4863a9b7ace1eb56c3ce61
GIT binary patch
[cut]
diff --git a/lib-python/3/ensurepip/_bundled/setuptools-21.2.1-py2.py3-none-any.whl b/lib-python/3/ensurepip/_bundled/setuptools-21.2.1-py2.py3-none-any.whl
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..fe36464f79ba87960c33f3bdff817deb9e4e5f7c
GIT binary patch
[cut]
diff --git a/lib-python/3/inspect.py b/lib-python/3/inspect.py
--- a/lib-python/3/inspect.py
+++ b/lib-python/3/inspect.py
@@ -1666,6 +1666,7 @@
_ClassMethodWrapper,
types.BuiltinFunctionType)
+_builtin_code_type = type(dict.update.__code__)
def _signature_get_user_defined_method(cls, method_name):
"""Private helper. Checks if ``cls`` has an attribute
@@ -1677,7 +1678,14 @@
except AttributeError:
return
else:
- if not isinstance(meth, _NonUserDefinedCallables):
+ # The particular check cpython uses to determine if a particular method
+ # is a builtin or not doesn't work on pypy. The following code is
+ # pypy-specific.
+ try:
+ code = meth.__code__
+ except AttributeError:
+ return
+ if not isinstance(code, _builtin_code_type):
# Once '__signature__' will be added to 'C'-level
# callables, this check won't be necessary
return meth
diff --git a/lib-python/3/subprocess.py b/lib-python/3/subprocess.py
--- a/lib-python/3/subprocess.py
+++ b/lib-python/3/subprocess.py
@@ -1124,15 +1124,18 @@
c2pread, c2pwrite = -1, -1
errread, errwrite = -1, -1
+ ispread = False
if stdin is None:
p2cread = _winapi.GetStdHandle(_winapi.STD_INPUT_HANDLE)
if p2cread is None:
p2cread, _ = _winapi.CreatePipe(None, 0)
p2cread = Handle(p2cread)
_winapi.CloseHandle(_)
+ ispread = True
elif stdin == PIPE:
p2cread, p2cwrite = _winapi.CreatePipe(None, 0)
p2cread, p2cwrite = Handle(p2cread), Handle(p2cwrite)
+ ispread = True
elif stdin == DEVNULL:
p2cread = msvcrt.get_osfhandle(self._get_devnull())
elif isinstance(stdin, int):
@@ -1140,17 +1143,20 @@
else:
# Assuming file-like object
p2cread = msvcrt.get_osfhandle(stdin.fileno())
- p2cread = self._make_inheritable(p2cread)
+ p2cread = self._make_inheritable(p2cread, ispread)
+ ispwrite = False
if stdout is None:
c2pwrite = _winapi.GetStdHandle(_winapi.STD_OUTPUT_HANDLE)
if c2pwrite is None:
_, c2pwrite = _winapi.CreatePipe(None, 0)
c2pwrite = Handle(c2pwrite)
_winapi.CloseHandle(_)
+ ispwrite = True
elif stdout == PIPE:
c2pread, c2pwrite = _winapi.CreatePipe(None, 0)
c2pread, c2pwrite = Handle(c2pread), Handle(c2pwrite)
+ ispwrite = True
elif stdout == DEVNULL:
c2pwrite = msvcrt.get_osfhandle(self._get_devnull())
elif isinstance(stdout, int):
@@ -1158,17 +1164,20 @@
else:
# Assuming file-like object
c2pwrite = msvcrt.get_osfhandle(stdout.fileno())
- c2pwrite = self._make_inheritable(c2pwrite)
+ c2pwrite = self._make_inheritable(c2pwrite, ispwrite)
+ ispwrite = False
if stderr is None:
errwrite = _winapi.GetStdHandle(_winapi.STD_ERROR_HANDLE)
if errwrite is None:
_, errwrite = _winapi.CreatePipe(None, 0)
errwrite = Handle(errwrite)
_winapi.CloseHandle(_)
+ ispwrite = True
elif stderr == PIPE:
errread, errwrite = _winapi.CreatePipe(None, 0)
errread, errwrite = Handle(errread), Handle(errwrite)
+ ispwrite = True
elif stderr == STDOUT:
errwrite = c2pwrite
elif stderr == DEVNULL:
@@ -1178,19 +1187,23 @@
else:
# Assuming file-like object
errwrite = msvcrt.get_osfhandle(stderr.fileno())
- errwrite = self._make_inheritable(errwrite)
+ errwrite = self._make_inheritable(errwrite, ispwrite)
return (p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite)
- def _make_inheritable(self, handle):
+ def _make_inheritable(self, handle, close=False):
"""Return a duplicate of handle, which is inheritable"""
h = _winapi.DuplicateHandle(
_winapi.GetCurrentProcess(), handle,
_winapi.GetCurrentProcess(), 0, 1,
_winapi.DUPLICATE_SAME_ACCESS)
+ # PyPy: If the initial handle was obtained with CreatePipe,
+ # close it.
+ if close:
+ handle.Close()
return Handle(h)
diff --git a/lib-python/3/sysconfig.py b/lib-python/3/sysconfig.py
--- a/lib-python/3/sysconfig.py
+++ b/lib-python/3/sysconfig.py
@@ -41,6 +41,16 @@
'scripts': '{base}/bin',
'data': '{base}',
},
+ 'pypy': {
+ 'stdlib': '{installed_base}/lib-python',
+ 'platstdlib': '{base}/lib-python',
+ 'purelib': '{base}/lib-python',
+ 'platlib': '{base}/lib-python',
+ 'include': '{installed_base}/include',
+ 'platinclude': '{installed_base}/include',
+ 'scripts': '{base}/bin',
+ 'data' : '{base}',
+ },
'nt': {
'stdlib': '{installed_base}/Lib',
'platstdlib': '{base}/Lib',
@@ -171,7 +181,9 @@
def _get_default_scheme():
- if os.name == 'posix':
+ if '__pypy__' in sys.builtin_module_names:
+ return 'pypy'
+ elif os.name == 'posix':
# the default scheme for posix is posix_prefix
return 'posix_prefix'
return os.name
diff --git a/lib-python/3/test/pickletester.py b/lib-python/3/test/pickletester.py
--- a/lib-python/3/test/pickletester.py
+++ b/lib-python/3/test/pickletester.py
@@ -13,7 +13,7 @@
from test.support import (
TestFailed, TESTFN, run_with_locale, no_tracing,
- _2G, _4G, bigmemtest, check_impl_detail
+ _2G, _4G, bigmemtest, check_impl_detail, impl_detail
)
from pickle import bytes_types
@@ -1781,6 +1781,7 @@
loaded = self.loads(dumped)
self.assert_is_copy(obj, loaded)
+ @impl_detail("pypy does not store attribute names", pypy=False)
def test_attribute_name_interning(self):
# Test that attribute names of pickled objects are interned when
# unpickling.
@@ -1795,6 +1796,7 @@
for x_key, y_key in zip(x_keys, y_keys):
self.assertIs(x_key, y_key)
+ @impl_detail("This test is too strong indeed", pypy=False)
def test_pickle_to_2x(self):
# Pickle non-trivial data with protocol 2, expecting that it yields
# the same result as Python 2.x did.
diff --git a/lib-python/3/test/test_cmd_line_script.py b/lib-python/3/test/test_cmd_line_script.py
--- a/lib-python/3/test/test_cmd_line_script.py
+++ b/lib-python/3/test/test_cmd_line_script.py
@@ -42,7 +42,11 @@
_loader = __loader__ if __loader__ is BuiltinImporter else type(__loader__)
print('__loader__==%a' % _loader)
print('__file__==%a' % __file__)
-print('__cached__==%a' % __cached__)
+if __cached__ is not None:
+ # XXX: test_script_compiled on PyPy
+ assertEqual(__file__, __cached__)
+ if not __cached__.endswith(('pyc', 'pyo')):
+ raise AssertionError('has __cached__ but not compiled')
print('__package__==%r' % __package__)
# Check PEP 451 details
import os.path
@@ -224,8 +228,9 @@
def test_basic_script(self):
with support.temp_dir() as script_dir:
script_name = _make_test_script(script_dir, 'script')
+ package = '' if support.check_impl_detail(pypy=True) else None
self._check_script(script_name, script_name, script_name,
- script_dir, None,
+ script_dir, package,
importlib.machinery.SourceFileLoader)
def test_script_compiled(self):
@@ -234,8 +239,9 @@
py_compile.compile(script_name, doraise=True)
os.remove(script_name)
pyc_file = support.make_legacy_pyc(script_name)
+ package = '' if support.check_impl_detail(pypy=True) else None
self._check_script(pyc_file, pyc_file,
- pyc_file, script_dir, None,
+ pyc_file, script_dir, package,
importlib.machinery.SourcelessFileLoader)
def test_directory(self):
diff --git a/lib-python/3/test/test_descr.py b/lib-python/3/test/test_descr.py
--- a/lib-python/3/test/test_descr.py
+++ b/lib-python/3/test/test_descr.py
@@ -1840,7 +1840,6 @@
("__reversed__", reversed, empty_seq, set(), {}),
("__length_hint__", list, zero, set(),
{"__iter__" : iden, "__next__" : stop}),
- ("__sizeof__", sys.getsizeof, zero, set(), {}),
("__instancecheck__", do_isinstance, return_true, set(), {}),
("__missing__", do_dict_missing, some_number,
set(("__class__",)), {}),
@@ -1857,6 +1856,8 @@
("__dir__", dir, empty_seq, set(), {}),
("__round__", round, zero, set(), {}),
]
+ if support.check_impl_detail():
+ specials.append(("__sizeof__", sys.getsizeof, zero, set(), {}))
class Checker(object):
def __getattr__(self, attr, test=self):
@@ -2019,7 +2020,8 @@
except TypeError as msg:
self.assertIn("weak reference", str(msg))
else:
- self.fail("weakref.ref(no) should be illegal")
+ if support.check_impl_detail(pypy=False):
+ self.fail("weakref.ref(no) should be illegal")
class Weak(object):
__slots__ = ['foo', '__weakref__']
yes = Weak()
@@ -4213,14 +4215,10 @@
self.assertNotEqual(l.__add__, [5].__add__)
self.assertNotEqual(l.__add__, l.__mul__)
self.assertEqual(l.__add__.__name__, '__add__')
- if hasattr(l.__add__, '__self__'):
+ self.assertIs(l.__add__.__self__, l)
+ if hasattr(l.__add__, '__objclass__'):
# CPython
- self.assertIs(l.__add__.__self__, l)
self.assertIs(l.__add__.__objclass__, list)
- else:
- # Python implementations where [].__add__ is a normal bound method
- self.assertIs(l.__add__.im_self, l)
- self.assertIs(l.__add__.im_class, list)
self.assertEqual(l.__add__.__doc__, list.__add__.__doc__)
try:
hash(l.__add__)
@@ -4430,9 +4428,9 @@
with self.assertRaises(TypeError) as cm:
type(list).__dict__["__doc__"].__set__(list, "blah")
self.assertIn("can't set list.__doc__", str(cm.exception))
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises((AttributeError, TypeError)) as cm:
type(X).__dict__["__doc__"].__delete__(X)
- self.assertIn("can't delete X.__doc__", str(cm.exception))
+ self.assertIn("delete", str(cm.exception))
self.assertEqual(X.__doc__, "banana")
def test_qualname(self):
@@ -4441,9 +4439,16 @@
# make sure we have an example of each type of descriptor
for d, n in zip(descriptors, types):
+ if (support.check_impl_detail(pypy=True) and
+ n in ('method', 'member', 'wrapper')):
+ # PyPy doesn't have these
+ continue
self.assertEqual(type(d).__name__, n + '_descriptor')
for d in descriptors:
+ if (support.check_impl_detail(pypy=True) and
+ not hasattr(d, '__objclass__')):
+ continue
qualname = d.__objclass__.__qualname__ + '.' + d.__name__
self.assertEqual(d.__qualname__, qualname)
@@ -4454,7 +4459,7 @@
class X:
pass
- with self.assertRaises(TypeError):
+ with self.assertRaises((AttributeError, TypeError)):
del X.__qualname__
self.assertRaises(TypeError, type.__dict__['__qualname__'].__set__,
@@ -4492,6 +4497,8 @@
for o in gc.get_objects():
self.assertIsNot(type(o), X)
+ @unittest.skipIf(support.check_impl_detail(pypy=True),
+ "https://bitbucket.org/pypy/pypy/issues/2306")
def test_object_new_and_init_with_parameters(self):
# See issue #1683368
class OverrideNeither:
@@ -4659,6 +4666,7 @@
class MiscTests(unittest.TestCase):
+ @support.cpython_only
def test_type_lookup_mro_reference(self):
# Issue #14199: _PyType_Lookup() has to keep a strong reference to
# the type MRO because it may be modified during the lookup, if
diff --git a/lib-python/3/test/test_ensurepip.py b/lib-python/3/test/test_ensurepip.py
--- a/lib-python/3/test/test_ensurepip.py
+++ b/lib-python/3/test/test_ensurepip.py
@@ -310,7 +310,7 @@
@requires_usable_pip
def test_bootstrap_version(self):
- with test.support.captured_stdout() as stdout:
+ with test.support.captured_stderr() as stdout:
with self.assertRaises(SystemExit):
ensurepip._main(["--version"])
result = stdout.getvalue().strip()
@@ -335,7 +335,7 @@
class TestUninstallationMainFunction(EnsurepipMixin, unittest.TestCase):
def test_uninstall_version(self):
- with test.support.captured_stdout() as stdout:
+ with test.support.captured_stderr() as stdout:
with self.assertRaises(SystemExit):
ensurepip._uninstall._main(["--version"])
result = stdout.getvalue().strip()
diff --git a/lib-python/3/test/test_exceptions.py b/lib-python/3/test/test_exceptions.py
--- a/lib-python/3/test/test_exceptions.py
+++ b/lib-python/3/test/test_exceptions.py
@@ -158,11 +158,12 @@
self.assertEqual(cm.exception.lineno, lineno)
self.assertEqual(cm.exception.offset, offset)
+ is_pypy = check_impl_detail(pypy=True)
check('def fact(x):\n\treturn x!\n', 2, 10)
- check('1 +\n', 1, 4)
- check('def spam():\n print(1)\n print(2)', 3, 10)
- check('Python = "Python" +', 1, 20)
- check('Python = "\u1e54\xfd\u0163\u0125\xf2\xf1" +', 1, 20)
+ check('1 +\n', 1, 4 - is_pypy)
+ check('def spam():\n print(1)\n print(2)', 3, 0 if is_pypy else 10)
+ check('Python = "Python" +', 1, 20 - is_pypy)
+ check('Python = "\u1e54\xfd\u0163\u0125\xf2\xf1" +', 1, 20 - is_pypy)
@cpython_only
def testSettingException(self):
@@ -417,10 +418,11 @@
self.fail("No exception raised")
def testInvalidAttrs(self):
+ delerrs = (AttributeError, TypeError)
self.assertRaises(TypeError, setattr, Exception(), '__cause__', 1)
- self.assertRaises(TypeError, delattr, Exception(), '__cause__')
+ self.assertRaises(delerrs, delattr, Exception(), '__cause__')
self.assertRaises(TypeError, setattr, Exception(), '__context__', 1)
- self.assertRaises(TypeError, delattr, Exception(), '__context__')
+ self.assertRaises(delerrs, delattr, Exception(), '__context__')
def testNoneClearsTracebackAttr(self):
try:
diff --git a/lib-python/3/test/test_site.py b/lib-python/3/test/test_site.py
--- a/lib-python/3/test/test_site.py
+++ b/lib-python/3/test/test_site.py
@@ -6,7 +6,8 @@
"""
import unittest
import test.support
-from test.support import captured_stderr, TESTFN, EnvironmentVarGuard
+from test.support import (
+ captured_stderr, check_impl_detail, TESTFN, EnvironmentVarGuard)
import builtins
import os
import sys
@@ -230,7 +231,11 @@
site.PREFIXES = ['xoxo']
dirs = site.getsitepackages()
- if (sys.platform == "darwin" and
+ if check_impl_detail(pypy=True):
+ self.assertEqual(len(dirs), 1)
+ wanted = os.path.join('xoxo', 'site-packages')
+ self.assertEqual(dirs[0], wanted)
+ elif (sys.platform == "darwin" and
sysconfig.get_config_var("PYTHONFRAMEWORK")):
# OS X framework builds
site.PREFIXES = ['Python.framework']
@@ -346,8 +351,10 @@
self.assertEqual(proc.returncode, 0)
os__file__, os__cached__ = stdout.splitlines()[:2]
- self.assertFalse(os.path.isabs(os__file__))
- self.assertFalse(os.path.isabs(os__cached__))
+ if check_impl_detail(cpython=True):
+ # XXX: should probably match cpython
+ self.assertFalse(os.path.isabs(os__file__))
+ self.assertFalse(os.path.isabs(os__cached__))
# Now, with 'import site', it works.
proc = subprocess.Popen([sys.executable, '-c', command],
env=env,
diff --git a/lib-python/3/test/test_socket.py b/lib-python/3/test/test_socket.py
--- a/lib-python/3/test/test_socket.py
+++ b/lib-python/3/test/test_socket.py
@@ -748,10 +748,11 @@
# wrong number of args
with self.assertRaises(TypeError) as cm:
s.sendto(b'foo')
- self.assertIn('(1 given)', str(cm.exception))
+ if support.check_impl_detail():
+ self.assertIn(' given)', str(cm.exception))
with self.assertRaises(TypeError) as cm:
s.sendto(b'foo', 0, sockname, 4)
- self.assertIn('(4 given)', str(cm.exception))
+ self.assertIn(' given', str(cm.exception))
def testCrucialConstants(self):
# Testing for mission critical constants
diff --git a/lib-python/3/test/test_sys_settrace.py b/lib-python/3/test/test_sys_settrace.py
--- a/lib-python/3/test/test_sys_settrace.py
+++ b/lib-python/3/test/test_sys_settrace.py
@@ -330,8 +330,8 @@
def test_13_genexp(self):
if self.using_gc:
+ gc.enable()
support.gc_collect()
- gc.enable()
try:
self.run_test(generator_example)
# issue1265: if the trace function contains a generator,
diff --git a/lib-python/3/test/test_sysconfig.py b/lib-python/3/test/test_sysconfig.py
--- a/lib-python/3/test/test_sysconfig.py
+++ b/lib-python/3/test/test_sysconfig.py
@@ -6,7 +6,8 @@
from copy import copy
from test.support import (run_unittest, TESTFN, unlink, check_warnings,
- captured_stdout, skip_unless_symlink, change_cwd)
+ captured_stdout, impl_detail, import_module,
+ skip_unless_symlink, change_cwd)
import sysconfig
from sysconfig import (get_paths, get_platform, get_config_vars,
@@ -235,7 +236,7 @@
def test_get_scheme_names(self):
wanted = ('nt', 'nt_user', 'osx_framework_user',
- 'posix_home', 'posix_prefix', 'posix_user')
+ 'posix_home', 'posix_prefix', 'posix_user', 'pypy')
self.assertEqual(get_scheme_names(), wanted)
@skip_unless_symlink
@@ -288,6 +289,7 @@
_main()
self.assertTrue(len(output.getvalue().split('\n')) > 0)
+ @impl_detail("PyPy lacks LDFLAGS/LDSHARED config vars", pypy=False)
@unittest.skipIf(sys.platform == "win32", "Does not apply to Windows")
def test_ldshared_value(self):
ldflags = sysconfig.get_config_var('LDFLAGS')
@@ -338,6 +340,7 @@
self.assertEqual(status, 0)
self.assertEqual(my_platform, test_platform)
+ @impl_detail("Test is not PyPy compatible", pypy=False)
def test_srcdir(self):
# See Issues #15322, #15364.
srcdir = sysconfig.get_config_var('srcdir')
@@ -407,6 +410,7 @@
class MakefileTests(unittest.TestCase):
+ @impl_detail("Test is not PyPy compatible", pypy=False)
@unittest.skipIf(sys.platform.startswith('win'),
'Test is not Windows compatible')
def test_get_makefile_filename(self):
diff --git a/lib-python/3/test/test_tempfile.py b/lib-python/3/test/test_tempfile.py
--- a/lib-python/3/test/test_tempfile.py
+++ b/lib-python/3/test/test_tempfile.py
@@ -1347,7 +1347,6 @@
"were deleted")
d2.cleanup()
- @support.cpython_only
def test_del_on_collection(self):
# A TemporaryDirectory is deleted when garbage collected
dir = tempfile.mkdtemp()
@@ -1355,6 +1354,7 @@
d = self.do_create(dir=dir)
name = d.name
del d # Rely on refcounting to invoke __del__
+ support.gc_collect()
self.assertFalse(os.path.exists(name),
"TemporaryDirectory %s exists after __del__" % name)
finally:
diff --git a/lib-python/3/test/test_threading.py b/lib-python/3/test/test_threading.py
--- a/lib-python/3/test/test_threading.py
+++ b/lib-python/3/test/test_threading.py
@@ -466,11 +466,16 @@
def test_is_alive_after_fork(self):
# Try hard to trigger #18418: is_alive() could sometimes be True on
# threads that vanished after a fork.
- old_interval = sys.getswitchinterval()
- self.addCleanup(sys.setswitchinterval, old_interval)
+ newgil = hasattr(sys, 'getswitchinterval')
+ if newgil:
+ geti, seti = sys.getswitchinterval, sys.setswitchinterval
+ else:
+ geti, seti = sys.getcheckinterval, sys.setcheckinterval
+ old_interval = geti()
+ self.addCleanup(seti, old_interval)
# Make the bug more likely to manifest.
- sys.setswitchinterval(1e-6)
+ seti(1e-6 if newgil else 1)
for i in range(20):
t = threading.Thread(target=lambda: None)
diff --git a/lib-python/conftest.py b/lib-python/conftest.py
--- a/lib-python/conftest.py
+++ b/lib-python/conftest.py
@@ -149,7 +149,7 @@
RegrTest('test_codecmaps_jp.py', usemodules='_multibytecodec'),
RegrTest('test_codecmaps_kr.py', usemodules='_multibytecodec'),
RegrTest('test_codecmaps_tw.py', usemodules='_multibytecodec'),
- RegrTest('test_codecs.py', core=True, usemodules='_multibytecodec'),
+ RegrTest('test_codecs.py', core=True, usemodules='_multibytecodec struct unicodedata array'),
RegrTest('test_codeop.py', core=True),
RegrTest('test_coding.py', core=True),
RegrTest('test_collections.py', usemodules='binascii struct'),
@@ -179,7 +179,7 @@
RegrTest('test_decimal.py'),
RegrTest('test_decorators.py', core=True),
RegrTest('test_defaultdict.py', usemodules='_collections'),
- RegrTest('test_deque.py', core=True, usemodules='_collections'),
+ RegrTest('test_deque.py', core=True, usemodules='_collections struct'),
RegrTest('test_descr.py', core=True, usemodules='_weakref'),
RegrTest('test_descrtut.py', core=True),
RegrTest('test_devpoll.py'),
@@ -196,6 +196,7 @@
RegrTest('test_dummy_threading.py', core=True),
RegrTest('test_dynamic.py'),
RegrTest('test_email', skip="XXX is a directory"),
+ RegrTest('test_ensurepip.py'),
RegrTest('test_enumerate.py', core=True),
RegrTest('test_eof.py', core=True),
RegrTest('test_epoll.py'),
@@ -256,7 +257,7 @@
RegrTest('test_importhooks.py', core=True),
RegrTest('test_importlib', 'XXX is a directory'),
RegrTest('test_index.py'),
- RegrTest('test_inspect.py'),
+ RegrTest('test_inspect.py', usemodules="struct unicodedata"),
RegrTest('test_int.py', core=True),
RegrTest('test_int_literal.py', core=True),
RegrTest('test_io.py', core=True, usemodules='array binascii'),
@@ -417,7 +418,7 @@
RegrTest('test_threading.py', usemodules="thread", core=True),
RegrTest('test_threading_local.py', usemodules="thread", core=True),
RegrTest('test_threadsignals.py', usemodules="thread"),
- RegrTest('test_time.py', core=True),
+ RegrTest('test_time.py', core=True, usemodules="struct"),
RegrTest('test_timeit.py'),
RegrTest('test_timeout.py'),
RegrTest('test_tk.py'),
diff --git a/lib_pypy/_collections.py b/lib_pypy/_collections.py
--- a/lib_pypy/_collections.py
+++ b/lib_pypy/_collections.py
@@ -384,6 +384,7 @@
return self
class defaultdict(dict):
+ __slots__ = ["default_factory"]
def __init__(self, *args, **kwds):
if len(args) > 0:
diff --git a/lib_pypy/_decimal.py b/lib_pypy/_decimal.py
--- a/lib_pypy/_decimal.py
+++ b/lib_pypy/_decimal.py
@@ -161,6 +161,15 @@
_codecs.register_error('_decimal_encode', _handle_decimaldigits)
+def _unsafe_check(name, lo, hi, value):
+ if not -_sys.maxsize-1 <= value <= _sys.maxsize:
+ raise OverflowError(
+ "Python int too large to convert to C ssize_t")
+ if not lo <= value <= hi:
+ raise ValueError("valid range for unsafe %s is [%d, %d]" %
+ (name, lo, hi))
+
+
# Decimal class
_DEC_MINALLOC = 4
@@ -298,7 +307,8 @@
raise ValueError("exponent must be an integer")
if not -_sys.maxsize-1 <= exponent <= _sys.maxsize:
# Compatibility with CPython
- raise OverflowError()
+ raise OverflowError(
+ "Python int too large to convert to C ssize_t")
# coefficients
if not digits and not is_special:
@@ -1501,6 +1511,19 @@
_mpdec.mpd_free(output)
return result.decode()
+ if _sys.maxsize < 2**63-1:
+ def _unsafe_setprec(self, value):
+ _unsafe_check('prec', 1, 1070000000, value)
+ self._ctx.prec = value
+
+ def _unsafe_setemin(self, value):
+ _unsafe_check('emin', -1070000000, 0, value)
+ self._ctx.emin = value
+
+ def _unsafe_setemax(self, value):
+ _unsafe_check('emax', 0, 1070000000, value)
+ self._ctx.emax = value
+
class _SignalDict(_collections.abc.MutableMapping):
diff --git a/lib_pypy/_libmpdec/vccompat.h b/lib_pypy/_libmpdec/vccompat.h
new file mode 100644
--- /dev/null
+++ b/lib_pypy/_libmpdec/vccompat.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2008-2016 Stefan Krah. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+#ifndef VCCOMPAT_H
+#define VCCOMPAT_H
+
+
+/* Visual C fixes: no stdint.h, no snprintf ... */
+#ifdef _MSC_VER
+ #include "vcstdint.h"
+ #undef inline
+ #define inline __inline
+ #undef random
+ #define random rand
+ #undef srandom
+ #define srandom srand
+ #undef snprintf
+ #define snprintf sprintf_s
+ #define HAVE_SNPRINTF
+ #undef strncasecmp
+ #define strncasecmp _strnicmp
+ #undef strcasecmp
+ #define strcasecmp _stricmp
+ #undef strtoll
+ #define strtoll _strtoi64
+ #define strdup _strdup
+ #define PRIi64 "I64i"
+ #define PRIu64 "I64u"
+ #define PRIi32 "I32i"
+ #define PRIu32 "I32u"
+#endif
+
+
+#endif /* VCCOMPAT_H */
+
+
+
diff --git a/lib_pypy/_libmpdec/vcdiv64.asm b/lib_pypy/_libmpdec/vcdiv64.asm
new file mode 100644
--- /dev/null
+++ b/lib_pypy/_libmpdec/vcdiv64.asm
@@ -0,0 +1,48 @@
+;
+; Copyright (c) 2008-2016 Stefan Krah. All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions
+; are met:
+;
+; 1. Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+;
+; 2. Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in the
+; documentation and/or other materials provided with the distribution.
+;
+; THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+; SUCH DAMAGE.
+;
+
+
+PUBLIC _mpd_div_words
+_TEXT SEGMENT
+q$ = 8
+r$ = 16
+hi$ = 24
+lo$ = 32
+d$ = 40
+_mpd_div_words PROC
+ mov r10, rdx
+ mov rdx, r8
+ mov rax, r9
+ div QWORD PTR d$[rsp]
+ mov QWORD PTR [r10], rdx
+ mov QWORD PTR [rcx], rax
+ ret 0
+_mpd_div_words ENDP
+_TEXT ENDS
+END
+
+
diff --git a/lib_pypy/_libmpdec/vcstdint.h b/lib_pypy/_libmpdec/vcstdint.h
new file mode 100644
--- /dev/null
+++ b/lib_pypy/_libmpdec/vcstdint.h
@@ -0,0 +1,232 @@
+// ISO C9x compliant stdint.h for Microsoft Visual Studio
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
+// Copyright (c) 2006-2008 Alexander Chemeris
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// 3. The name of the author may be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _MSC_VER // [
+#error "Use this header only with Microsoft Visual C++ compilers!"
+#endif // _MSC_VER ]
+
+#ifndef _MSC_STDINT_H_ // [
+#define _MSC_STDINT_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+#include <limits.h>
+
+// For Visual Studio 6 in C++ mode wrap <wchar.h> include with 'extern "C++" {}'
+// or compiler give many errors like this:
+// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
+#if (_MSC_VER < 1300) && defined(__cplusplus)
+ extern "C++" {
+#endif
+# include <wchar.h>
+#if (_MSC_VER < 1300) && defined(__cplusplus)
+ }
+#endif
+
+// Define _W64 macros to mark types changing their size, like intptr_t.
+#ifndef _W64
+# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
+# define _W64 __w64
+# else
+# define _W64
+# endif
+#endif
+
+
+// 7.18.1 Integer types
+
+// 7.18.1.1 Exact-width integer types
+typedef __int8 int8_t;
+typedef __int16 int16_t;
+typedef __int32 int32_t;
+typedef __int64 int64_t;
+typedef unsigned __int8 uint8_t;
+typedef unsigned __int16 uint16_t;
+typedef unsigned __int32 uint32_t;
+typedef unsigned __int64 uint64_t;
+
+// 7.18.1.2 Minimum-width integer types
+typedef int8_t int_least8_t;
+typedef int16_t int_least16_t;
+typedef int32_t int_least32_t;
+typedef int64_t int_least64_t;
+typedef uint8_t uint_least8_t;
+typedef uint16_t uint_least16_t;
+typedef uint32_t uint_least32_t;
+typedef uint64_t uint_least64_t;
+
+// 7.18.1.3 Fastest minimum-width integer types
+typedef int8_t int_fast8_t;
+typedef int16_t int_fast16_t;
+typedef int32_t int_fast32_t;
+typedef int64_t int_fast64_t;
+typedef uint8_t uint_fast8_t;
+typedef uint16_t uint_fast16_t;
+typedef uint32_t uint_fast32_t;
+typedef uint64_t uint_fast64_t;
+
+// 7.18.1.4 Integer types capable of holding object pointers
+#ifdef _WIN64 // [
+ typedef __int64 intptr_t;
+ typedef unsigned __int64 uintptr_t;
+#else // _WIN64 ][
+ typedef _W64 int intptr_t;
+ typedef _W64 unsigned int uintptr_t;
+#endif // _WIN64 ]
+
+// 7.18.1.5 Greatest-width integer types
+typedef int64_t intmax_t;
+typedef uint64_t uintmax_t;
+
+
+// 7.18.2 Limits of specified-width integer types
+
+#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
+
+// 7.18.2.1 Limits of exact-width integer types
+#define INT8_MIN ((int8_t)_I8_MIN)
+#define INT8_MAX _I8_MAX
+#define INT16_MIN ((int16_t)_I16_MIN)
+#define INT16_MAX _I16_MAX
+#define INT32_MIN ((int32_t)_I32_MIN)
+#define INT32_MAX _I32_MAX
+#define INT64_MIN ((int64_t)_I64_MIN)
+#define INT64_MAX _I64_MAX
+#define UINT8_MAX _UI8_MAX
+#define UINT16_MAX _UI16_MAX
+#define UINT32_MAX _UI32_MAX
+#define UINT64_MAX _UI64_MAX
+
+// 7.18.2.2 Limits of minimum-width integer types
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST8_MAX INT8_MAX
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST16_MAX INT16_MAX
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST32_MAX INT32_MAX
+#define INT_LEAST64_MIN INT64_MIN
+#define INT_LEAST64_MAX INT64_MAX
+#define UINT_LEAST8_MAX UINT8_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
+
+// 7.18.2.3 Limits of fastest minimum-width integer types
+#define INT_FAST8_MIN INT8_MIN
+#define INT_FAST8_MAX INT8_MAX
+#define INT_FAST16_MIN INT16_MIN
+#define INT_FAST16_MAX INT16_MAX
+#define INT_FAST32_MIN INT32_MIN
+#define INT_FAST32_MAX INT32_MAX
+#define INT_FAST64_MIN INT64_MIN
+#define INT_FAST64_MAX INT64_MAX
+#define UINT_FAST8_MAX UINT8_MAX
+#define UINT_FAST16_MAX UINT16_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+#define UINT_FAST64_MAX UINT64_MAX
+
+// 7.18.2.4 Limits of integer types capable of holding object pointers
+#ifdef _WIN64 // [
+# define INTPTR_MIN INT64_MIN
+# define INTPTR_MAX INT64_MAX
+# define UINTPTR_MAX UINT64_MAX
+#else // _WIN64 ][
+# define INTPTR_MIN INT32_MIN
+# define INTPTR_MAX INT32_MAX
+# define UINTPTR_MAX UINT32_MAX
+#endif // _WIN64 ]
+
+// 7.18.2.5 Limits of greatest-width integer types
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
+#define UINTMAX_MAX UINT64_MAX
+
+// 7.18.3 Limits of other integer types
+
+#ifdef _WIN64 // [
+# define PTRDIFF_MIN _I64_MIN
+# define PTRDIFF_MAX _I64_MAX
+#else // _WIN64 ][
+# define PTRDIFF_MIN _I32_MIN
+# define PTRDIFF_MAX _I32_MAX
+#endif // _WIN64 ]
+
+#define SIG_ATOMIC_MIN INT_MIN
+#define SIG_ATOMIC_MAX INT_MAX
+
+#ifndef SIZE_MAX // [
+# ifdef _WIN64 // [
+# define SIZE_MAX _UI64_MAX
+# else // _WIN64 ][
+# define SIZE_MAX _UI32_MAX
+# endif // _WIN64 ]
+#endif // SIZE_MAX ]
+
+// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
+#ifndef WCHAR_MIN // [
+# define WCHAR_MIN 0
+#endif // WCHAR_MIN ]
+#ifndef WCHAR_MAX // [
+# define WCHAR_MAX _UI16_MAX
+#endif // WCHAR_MAX ]
+
+#define WINT_MIN 0
+#define WINT_MAX _UI16_MAX
+
+#endif // __STDC_LIMIT_MACROS ]
+
+
+// 7.18.4 Limits of other integer types
+
+#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
+
+// 7.18.4.1 Macros for minimum-width integer constants
+
+#define INT8_C(val) val##i8
+#define INT16_C(val) val##i16
+#define INT32_C(val) val##i32
+#define INT64_C(val) val##i64
+
+#define UINT8_C(val) val##ui8
+#define UINT16_C(val) val##ui16
+#define UINT32_C(val) val##ui32
+#define UINT64_C(val) val##ui64
+
+// 7.18.4.2 Macros for greatest-width integer constants
+#define INTMAX_C INT64_C
+#define UINTMAX_C UINT64_C
+
+#endif // __STDC_CONSTANT_MACROS ]
+
+
+#endif // _MSC_STDINT_H_ ]
diff --git a/lib_pypy/_pypy_irc_topic.py b/lib_pypy/_pypy_irc_topic.py
--- a/lib_pypy/_pypy_irc_topic.py
+++ b/lib_pypy/_pypy_irc_topic.py
@@ -224,23 +224,9 @@
va ClCl orvat bayl zbqrengryl zntvp vf n tbbq guvat <psobym>
"""
-from string import ascii_uppercase, ascii_lowercase
-
def rot13(data):
- """ A simple rot-13 encoder since `str.encode('rot13')` was removed from
- Python as of version 3.0. It rotates both uppercase and lowercase letters individually.
- """
- total = []
- for char in data:
- if char in ascii_uppercase:
- index = (ascii_uppercase.find(char) + 13) % 26
- total.append(ascii_uppercase[index])
- elif char in ascii_lowercase:
- index = (ascii_lowercase.find(char) + 13) % 26
- total.append(ascii_lowercase[index])
- else:
- total.append(char)
- return "".join(total)
+ return ''.join(chr(ord(c)+(13 if 'A'<=c.upper()<='M' else
+ -13 if 'N'<=c.upper()<='Z' else 0)) for c in data)
def some_topic():
import time
diff --git a/lib_pypy/_subprocess.py b/lib_pypy/_subprocess.py
deleted file mode 100644
--- a/lib_pypy/_subprocess.py
+++ /dev/null
@@ -1,214 +0,0 @@
-"""
-Support routines for subprocess module.
-Currently, this extension module is only required when using the
-subprocess module on Windows.
-"""
-
-
-# Declare external Win32 functions
-
-import ctypes
-
-_kernel32 = ctypes.WinDLL('kernel32')
-
-_CloseHandle = _kernel32.CloseHandle
-_CloseHandle.argtypes = [ctypes.c_int]
-_CloseHandle.restype = ctypes.c_int
-
-_CreatePipe = _kernel32.CreatePipe
-_CreatePipe.argtypes = [ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int),
- ctypes.c_void_p, ctypes.c_int]
-_CreatePipe.restype = ctypes.c_int
-
-_GetCurrentProcess = _kernel32.GetCurrentProcess
-_GetCurrentProcess.argtypes = []
-_GetCurrentProcess.restype = ctypes.c_int
-
-GetVersion = _kernel32.GetVersion
-GetVersion.argtypes = []
-GetVersion.restype = ctypes.c_int
-
-_DuplicateHandle = _kernel32.DuplicateHandle
-_DuplicateHandle.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_int,
- ctypes.POINTER(ctypes.c_int),
- ctypes.c_int, ctypes.c_int, ctypes.c_int]
-_DuplicateHandle.restype = ctypes.c_int
-
-_WaitForSingleObject = _kernel32.WaitForSingleObject
-_WaitForSingleObject.argtypes = [ctypes.c_int, ctypes.c_uint]
-_WaitForSingleObject.restype = ctypes.c_int
-
-_GetExitCodeProcess = _kernel32.GetExitCodeProcess
-_GetExitCodeProcess.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_int)]
-_GetExitCodeProcess.restype = ctypes.c_int
-
-_TerminateProcess = _kernel32.TerminateProcess
-_TerminateProcess.argtypes = [ctypes.c_int, ctypes.c_int]
-_TerminateProcess.restype = ctypes.c_int
-
-_GetStdHandle = _kernel32.GetStdHandle
-_GetStdHandle.argtypes = [ctypes.c_int]
-_GetStdHandle.restype = ctypes.c_int
-
-class _STARTUPINFO(ctypes.Structure):
- _fields_ = [('cb', ctypes.c_int),
- ('lpReserved', ctypes.c_void_p),
- ('lpDesktop', ctypes.c_char_p),
- ('lpTitle', ctypes.c_char_p),
- ('dwX', ctypes.c_int),
- ('dwY', ctypes.c_int),
- ('dwXSize', ctypes.c_int),
- ('dwYSize', ctypes.c_int),
- ('dwXCountChars', ctypes.c_int),
- ('dwYCountChars', ctypes.c_int),
- ("dwFillAttribute", ctypes.c_int),
- ("dwFlags", ctypes.c_int),
- ("wShowWindow", ctypes.c_short),
- ("cbReserved2", ctypes.c_short),
- ("lpReserved2", ctypes.c_void_p),
- ("hStdInput", ctypes.c_int),
- ("hStdOutput", ctypes.c_int),
- ("hStdError", ctypes.c_int)
- ]
-
-class _PROCESS_INFORMATION(ctypes.Structure):
- _fields_ = [("hProcess", ctypes.c_int),
- ("hThread", ctypes.c_int),
- ("dwProcessID", ctypes.c_int),
- ("dwThreadID", ctypes.c_int)]
-
-_CreateProcess = _kernel32.CreateProcessW
-_CreateProcess.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_void_p, ctypes.c_void_p,
- ctypes.c_int, ctypes.c_int, ctypes.c_wchar_p, ctypes.c_wchar_p,
- ctypes.POINTER(_STARTUPINFO), ctypes.POINTER(_PROCESS_INFORMATION)]
-_CreateProcess.restype = ctypes.c_int
-
-del ctypes
-
-# Now the _subprocess module implementation
-
-from ctypes import c_int as _c_int, byref as _byref, WinError as _WinError
-
-class _handle:
- def __init__(self, handle):
- self.handle = handle
-
- def __int__(self):
- return self.handle
-
- def __del__(self):
- if self.handle is not None:
- _CloseHandle(self.handle)
-
- def Detach(self):
- handle, self.handle = self.handle, None
- return handle
-
- def Close(self):
- if self.handle not in (-1, None):
- _CloseHandle(self.handle)
- self.handle = None
-
-def CreatePipe(attributes, size):
- read = _c_int()
- write = _c_int()
-
- res = _CreatePipe(_byref(read), _byref(write), None, size)
-
- if not res:
- raise _WinError()
-
- return _handle(read.value), _handle(write.value)
-
-def GetCurrentProcess():
- return _handle(_GetCurrentProcess())
-
-def DuplicateHandle(source_process, source, target_process, access, inherit, options=0):
- target = _c_int()
-
- res = _DuplicateHandle(int(source_process), int(source), int(target_process),
- _byref(target),
- access, inherit, options)
-
- if not res:
- raise _WinError()
-
- return _handle(target.value)
-
-def CreateProcess(name, command_line, process_attr, thread_attr,
- inherit, flags, env, start_dir, startup_info):
- si = _STARTUPINFO()
- if startup_info is not None:
- si.dwFlags = startup_info.dwFlags
- si.wShowWindow = startup_info.wShowWindow
- if startup_info.hStdInput:
- si.hStdInput = int(startup_info.hStdInput)
- if startup_info.hStdOutput:
- si.hStdOutput = int(startup_info.hStdOutput)
- if startup_info.hStdError:
- si.hStdError = int(startup_info.hStdError)
-
- pi = _PROCESS_INFORMATION()
- flags |= CREATE_UNICODE_ENVIRONMENT
-
- if env is not None:
- envbuf = ""
- for k, v in env.items():
- envbuf += "%s=%s\0" % (k, v)
- envbuf += '\0'
- else:
- envbuf = None
-
- res = _CreateProcess(name, command_line, None, None, inherit, flags, envbuf,
- start_dir, _byref(si), _byref(pi))
-
- if not res:
- raise _WinError()
-
- return _handle(pi.hProcess), _handle(pi.hThread), pi.dwProcessID, pi.dwThreadID
-
-def WaitForSingleObject(handle, milliseconds):
- res = _WaitForSingleObject(int(handle), milliseconds)
-
- if res < 0:
- raise _WinError()
-
- return res
-
-def GetExitCodeProcess(handle):
- code = _c_int()
-
- res = _GetExitCodeProcess(int(handle), _byref(code))
-
- if not res:
- raise _WinError()
-
- return code.value
-
-def TerminateProcess(handle, exitcode):
- res = _TerminateProcess(int(handle), exitcode)
-
- if not res:
- raise _WinError()
-
-def GetStdHandle(stdhandle):
- res = _GetStdHandle(stdhandle)
-
- if not res:
- return None
- else:
- return res
-
-STD_INPUT_HANDLE = -10
-STD_OUTPUT_HANDLE = -11
-STD_ERROR_HANDLE = -12
-DUPLICATE_SAME_ACCESS = 2
-STARTF_USESTDHANDLES = 0x100
-STARTF_USESHOWWINDOW = 0x001
-SW_HIDE = 0
-INFINITE = 0xffffffff
-WAIT_OBJECT_0 = 0
-CREATE_NEW_CONSOLE = 0x010
-CREATE_NEW_PROCESS_GROUP = 0x200
-CREATE_UNICODE_ENVIRONMENT = 0x400
-STILL_ACTIVE = 259
diff --git a/lib_pypy/_winapi.py b/lib_pypy/_winapi.py
new file mode 100644
--- /dev/null
+++ b/lib_pypy/_winapi.py
@@ -0,0 +1,237 @@
+"""
+Support routines for subprocess module.
+Currently, this extension module is only required when using the
+subprocess module on Windows.
+"""
+
+import sys
+if sys.platform != 'win32':
+ raise ImportError("The '_subprocess' module is only available on Windows")
+
+# Declare external Win32 functions
+
+import ctypes
+
+_kernel32 = ctypes.WinDLL('kernel32')
+
+_CloseHandle = _kernel32.CloseHandle
+_CloseHandle.argtypes = [ctypes.c_int]
+_CloseHandle.restype = ctypes.c_int
+
+_CreatePipe = _kernel32.CreatePipe
+_CreatePipe.argtypes = [ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int),
+ ctypes.c_void_p, ctypes.c_int]
+_CreatePipe.restype = ctypes.c_int
+
+_GetCurrentProcess = _kernel32.GetCurrentProcess
+_GetCurrentProcess.argtypes = []
+_GetCurrentProcess.restype = ctypes.c_int
+
+GetVersion = _kernel32.GetVersion
+GetVersion.argtypes = []
+GetVersion.restype = ctypes.c_int
+
+_DuplicateHandle = _kernel32.DuplicateHandle
+_DuplicateHandle.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_int,
+ ctypes.POINTER(ctypes.c_int),
+ ctypes.c_int, ctypes.c_int, ctypes.c_int]
+_DuplicateHandle.restype = ctypes.c_int
+
+_WaitForSingleObject = _kernel32.WaitForSingleObject
+_WaitForSingleObject.argtypes = [ctypes.c_int, ctypes.c_uint]
+_WaitForSingleObject.restype = ctypes.c_int
+
+_GetExitCodeProcess = _kernel32.GetExitCodeProcess
+_GetExitCodeProcess.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_int)]
+_GetExitCodeProcess.restype = ctypes.c_int
+
+_TerminateProcess = _kernel32.TerminateProcess
+_TerminateProcess.argtypes = [ctypes.c_int, ctypes.c_int]
+_TerminateProcess.restype = ctypes.c_int
+
+_GetStdHandle = _kernel32.GetStdHandle
+_GetStdHandle.argtypes = [ctypes.c_int]
+_GetStdHandle.restype = ctypes.c_int
+
+_GetModuleFileNameW = _kernel32.GetModuleFileNameW
+_GetModuleFileNameW.argtypes = [ctypes.c_int, ctypes.c_wchar_p, ctypes.c_uint]
+_GetModuleFileNameW.restype = ctypes.c_int
+
+class _STARTUPINFO(ctypes.Structure):
+ _fields_ = [('cb', ctypes.c_int),
+ ('lpReserved', ctypes.c_void_p),
+ ('lpDesktop', ctypes.c_char_p),
+ ('lpTitle', ctypes.c_char_p),
+ ('dwX', ctypes.c_int),
+ ('dwY', ctypes.c_int),
+ ('dwXSize', ctypes.c_int),
+ ('dwYSize', ctypes.c_int),
+ ('dwXCountChars', ctypes.c_int),
+ ('dwYCountChars', ctypes.c_int),
+ ("dwFillAttribute", ctypes.c_int),
+ ("dwFlags", ctypes.c_int),
+ ("wShowWindow", ctypes.c_short),
+ ("cbReserved2", ctypes.c_short),
+ ("lpReserved2", ctypes.c_void_p),
+ ("hStdInput", ctypes.c_int),
+ ("hStdOutput", ctypes.c_int),
+ ("hStdError", ctypes.c_int)
+ ]
+
+class _PROCESS_INFORMATION(ctypes.Structure):
+ _fields_ = [("hProcess", ctypes.c_int),
+ ("hThread", ctypes.c_int),
+ ("dwProcessID", ctypes.c_int),
+ ("dwThreadID", ctypes.c_int)]
+
+_CreateProcess = _kernel32.CreateProcessW
+_CreateProcess.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_void_p, ctypes.c_void_p,
+ ctypes.c_int, ctypes.c_int, ctypes.c_wchar_p, ctypes.c_wchar_p,
+ ctypes.POINTER(_STARTUPINFO), ctypes.POINTER(_PROCESS_INFORMATION)]
+_CreateProcess.restype = ctypes.c_int
+
+del ctypes
+
+# Now the _winapi module implementation
+
+from ctypes import c_int as _c_int, byref as _byref, WinError as _WinError
+
+class _handle:
+ def __init__(self, handle):
+ self.handle = handle
+
+ def __int__(self):
+ return self.handle
+
+ def __del__(self):
+ if self.handle is not None:
+ _CloseHandle(self.handle)
+
+ def Detach(self):
+ handle, self.handle = self.handle, None
+ return handle
+
+ def Close(self):
+ if self.handle not in (-1, None):
+ _CloseHandle(self.handle)
+ self.handle = None
+
+def CreatePipe(attributes, size):
+ read = _c_int()
+ write = _c_int()
+
+ res = _CreatePipe(_byref(read), _byref(write), None, size)
+
+ if not res:
+ raise _WinError()
+
+ return _handle(read.value), _handle(write.value)
+
+def GetCurrentProcess():
+ return _handle(_GetCurrentProcess())
+
+def DuplicateHandle(source_process, source, target_process, access, inherit, options=0):
+ target = _c_int()
+
+ res = _DuplicateHandle(int(source_process), int(source), int(target_process),
+ _byref(target),
+ access, inherit, options)
+
+ if not res:
+ raise _WinError()
+
+ return _handle(target.value)
+
+def CreateProcess(name, command_line, process_attr, thread_attr,
+ inherit, flags, env, start_dir, startup_info):
+ si = _STARTUPINFO()
+ if startup_info is not None:
+ si.dwFlags = startup_info.dwFlags
+ si.wShowWindow = startup_info.wShowWindow
+ if startup_info.hStdInput:
+ si.hStdInput = int(startup_info.hStdInput)
+ if startup_info.hStdOutput:
+ si.hStdOutput = int(startup_info.hStdOutput)
+ if startup_info.hStdError:
+ si.hStdError = int(startup_info.hStdError)
+
+ pi = _PROCESS_INFORMATION()
+ flags |= CREATE_UNICODE_ENVIRONMENT
+
+ if env is not None:
+ envbuf = ""
+ for k, v in env.items():
+ envbuf += "%s=%s\0" % (k, v)
+ envbuf += '\0'
+ else:
+ envbuf = None
+
+ res = _CreateProcess(name, command_line, None, None, inherit, flags, envbuf,
+ start_dir, _byref(si), _byref(pi))
+
+ if not res:
+ raise _WinError()
+
+ return _handle(pi.hProcess), _handle(pi.hThread), pi.dwProcessID, pi.dwThreadID
+
+def WaitForSingleObject(handle, milliseconds):
+ res = _WaitForSingleObject(int(handle), milliseconds)
+
+ if res < 0:
+ raise _WinError()
+
+ return res
+
+def GetExitCodeProcess(handle):
+ code = _c_int()
+
+ res = _GetExitCodeProcess(int(handle), _byref(code))
+
+ if not res:
+ raise _WinError()
+
+ return code.value
+
+def TerminateProcess(handle, exitcode):
+ res = _TerminateProcess(int(handle), exitcode)
+
+ if not res:
+ raise _WinError()
+
+def GetStdHandle(stdhandle):
+ res = _GetStdHandle(stdhandle)
+
+ if not res:
+ return None
+ else:
+ return res
+
+def CloseHandle(handle):
+ res = _CloseHandle(handle)
+
+ if not res:
+ raise _WinError()
+
+def GetModuleFileName(module):
+ buf = ctypes.create_unicode_buffer(_MAX_PATH)
+ res = _GetModuleFileNameW(module, buf, _MAX_PATH)
+
+ if not res:
+ raise _WinError()
+ return buf.value
+
+STD_INPUT_HANDLE = -10
+STD_OUTPUT_HANDLE = -11
+STD_ERROR_HANDLE = -12
+DUPLICATE_SAME_ACCESS = 2
+STARTF_USESTDHANDLES = 0x100
+STARTF_USESHOWWINDOW = 0x001
+SW_HIDE = 0
+INFINITE = 0xffffffff
+WAIT_OBJECT_0 = 0
+WAIT_TIMEOUT = 0x102
+CREATE_NEW_CONSOLE = 0x010
+CREATE_NEW_PROCESS_GROUP = 0x200
+CREATE_UNICODE_ENVIRONMENT = 0x400
+STILL_ACTIVE = 259
+_MAX_PATH = 260
diff --git a/lib_pypy/cffi.egg-info/PKG-INFO b/lib_pypy/cffi.egg-info/PKG-INFO
--- a/lib_pypy/cffi.egg-info/PKG-INFO
+++ b/lib_pypy/cffi.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: cffi
-Version: 1.6.0
+Version: 1.7.0
Summary: Foreign Function Interface for Python calling C code.
Home-page: http://cffi.readthedocs.org
Author: Armin Rigo, Maciej Fijalkowski
diff --git a/lib_pypy/cffi/__init__.py b/lib_pypy/cffi/__init__.py
--- a/lib_pypy/cffi/__init__.py
+++ b/lib_pypy/cffi/__init__.py
@@ -4,8 +4,8 @@
from .api import FFI, CDefError, FFIError
from .ffiplatform import VerificationError, VerificationMissing
-__version__ = "1.6.0"
-__version_info__ = (1, 6, 0)
+__version__ = "1.7.0"
+__version_info__ = (1, 7, 0)
# The verifier module file names are based on the CRC32 of a string that
# contains the following version number. It may be older than __version__
diff --git a/lib_pypy/cffi/_cffi_include.h b/lib_pypy/cffi/_cffi_include.h
--- a/lib_pypy/cffi/_cffi_include.h
+++ b/lib_pypy/cffi/_cffi_include.h
@@ -57,6 +57,12 @@
# define _CFFI_UNUSED_FN /* nothing */
#endif
+#ifdef __cplusplus
+# ifndef _Bool
+# define _Bool bool /* semi-hackish: C++ has no _Bool; bool is builtin */
+# endif
+#endif
+
/********** CPython-specific section **********/
#ifndef PYPY_VERSION
diff --git a/lib_pypy/cffi/_embedding.h b/lib_pypy/cffi/_embedding.h
--- a/lib_pypy/cffi/_embedding.h
+++ b/lib_pypy/cffi/_embedding.h
@@ -233,7 +233,7 @@
f = PySys_GetObject((char *)"stderr");
if (f != NULL && f != Py_None) {
PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME
- "\ncompiled with cffi version: 1.6.0"
+ "\ncompiled with cffi version: 1.7.0"
"\n_cffi_backend module: ", f);
modules = PyImport_GetModuleDict();
mod = PyDict_GetItemString(modules, "_cffi_backend");
diff --git a/lib_pypy/cffi/api.py b/lib_pypy/cffi/api.py
--- a/lib_pypy/cffi/api.py
+++ b/lib_pypy/cffi/api.py
@@ -332,8 +332,8 @@
def from_buffer(self, python_buffer):
"""Return a <cdata 'char[]'> that points to the data of the
given Python object, which must support the buffer interface.
- Note that this is not meant to be used on the built-in types str,
- unicode, or bytearray (you can build 'char[]' arrays explicitly)
+ Note that this is not meant to be used on the built-in types
+ str or unicode (you can build 'char[]' arrays explicitly)
but only on objects containing large quantities of raw data
in some other format, like 'array.array' or numpy arrays.
"""
@@ -397,20 +397,7 @@
data. Later, when this new cdata object is garbage-collected,
'destructor(old_cdata_object)' will be called.
"""
- try:
- gcp = self._backend.gcp
- except AttributeError:
- pass
- else:
- return gcp(cdata, destructor)
- #
- with self._lock:
- try:
- gc_weakrefs = self.gc_weakrefs
- except AttributeError:
- from .gc_weakref import GcWeakrefs
- gc_weakrefs = self.gc_weakrefs = GcWeakrefs(self)
- return gc_weakrefs.build(cdata, destructor)
+ return self._backend.gcp(cdata, destructor)
def _get_cached_btype(self, type):
assert self._lock.acquire(False) is False
diff --git a/lib_pypy/cffi/backend_ctypes.py b/lib_pypy/cffi/backend_ctypes.py
--- a/lib_pypy/cffi/backend_ctypes.py
+++ b/lib_pypy/cffi/backend_ctypes.py
@@ -205,9 +205,7 @@
def __nonzero__(self):
More information about the pypy-commit
mailing list