aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Rivera <stefano@rivera.za.net>2020-10-09 23:47:58 -0700
committerStefano Rivera <stefano@rivera.za.net>2020-10-09 23:47:58 -0700
commit561a10722008ff11486eb312a49e9e109f775115 (patch)
tree4f65b1fc7064dfeb07b7542a23dae3431fb4eb2d
parentbpo-30058: Fixed buffer overflow in select.kqueue.control(). (diff)
parenttypo (diff)
downloadpypy-561a10722008ff11486eb312a49e9e109f775115.tar.gz
pypy-561a10722008ff11486eb312a49e9e109f775115.tar.bz2
pypy-561a10722008ff11486eb312a49e9e109f775115.zip
merge default into stdlib-2.7.18-3
-rw-r--r--extra_tests/cffi_tests/test_c.py4
-rw-r--r--extra_tests/test_os.py103
-rw-r--r--lib-python/2.7/sysconfig.py21
-rw-r--r--lib-python/2.7/test/test_urllib2.py1
-rw-r--r--lib-python/2.7/urllib2.py8
-rw-r--r--lib_pypy/crypt/__init__.py16
-rw-r--r--lib_pypy/pypy_tools/build_cffi_imports.py7
-rw-r--r--pypy/doc/contributing.rst4
-rw-r--r--pypy/doc/index-of-whatsnew.rst1
-rw-r--r--pypy/doc/release-v7.3.2.rst1
-rw-r--r--pypy/doc/whatsnew-head.rst8
-rw-r--r--pypy/doc/whatsnew-pypy3-7.3.1.rst6
-rw-r--r--pypy/doc/whatsnew-pypy3-7.3.2.rst48
-rw-r--r--pypy/doc/whatsnew-pypy3-head.rst10
-rwxr-xr-xpypy/interpreter/app_main.py83
-rw-r--r--pypy/module/posix/test/test_posix2.py106
-rw-r--r--pypy/objspace/fake/objspace.py5
-rwxr-xr-xpypy/tool/release/repackage.sh20
-rw-r--r--rpython/rlib/rarithmetic.py7
-rw-r--r--rpython/rlib/rposix.py26
-rw-r--r--rpython/translator/c/primitive.py2
-rw-r--r--rpython/translator/c/test/test_typed.py10
-rw-r--r--rpython/translator/platform/darwin.py1
23 files changed, 323 insertions, 175 deletions
diff --git a/extra_tests/cffi_tests/test_c.py b/extra_tests/cffi_tests/test_c.py
index 95ca81274a..643cc904ee 100644
--- a/extra_tests/cffi_tests/test_c.py
+++ b/extra_tests/cffi_tests/test_c.py
@@ -4515,5 +4515,5 @@ def test_unaligned_types():
pbuf1 = cast(new_pointer_type(p), pbuf + 1)
pbuf1[0] = num
assert pbuf1[0] == num
- assert buf[0] == '\x00'
- assert buf[1 + size] == '\x00'
+ assert buf[0] == b'\x00'
+ assert buf[1 + size] == b'\x00'
diff --git a/extra_tests/test_os.py b/extra_tests/test_os.py
new file mode 100644
index 0000000000..0f60f370b8
--- /dev/null
+++ b/extra_tests/test_os.py
@@ -0,0 +1,103 @@
+import os
+import sys
+from pytest import raises, skip
+
+python = sys.executable
+
+if hasattr(os, "execv"):
+ def test_execv():
+ if not hasattr(os, "fork"):
+ skip("Need fork() to test execv()")
+ if not os.path.isdir('/tmp'):
+ skip("Need '/tmp' for test")
+ pid = os.fork()
+ if pid == 0:
+ os.execv("/usr/bin/env", ["env", python, "-c",
+ ("fid = open('/tmp/onefile0', 'w'); "
+ "fid.write('1'); "
+ "fid.close()")])
+ os.waitpid(pid, 0)
+ assert open("/tmp/onefile0").read() == "1"
+ os.unlink("/tmp/onefile0")
+
+ def test_execv_raising():
+ with raises(OSError):
+ os.execv("saddsadsadsadsa", ["saddsadsasaddsa"])
+
+ def test_execv_no_args():
+ with raises(ValueError):
+ os.execv("notepad", [])
+ # PyPy needs at least one arg, CPython 2.7 is fine without
+ with raises(ValueError):
+ os.execve("notepad", [], {})
+
+ def test_execv_raising2():
+ for n in 3, [3, "a"]:
+ with raises(TypeError):
+ os.execv("xxx", n)
+
+ def test_execv_unicode():
+ if not hasattr(os, "fork"):
+ skip("Need fork() to test execv()")
+ if not os.path.isdir('/tmp'):
+ skip("Need '/tmp' for test")
+ try:
+ output = u"caf\xe9 \u1234\n".encode(sys.getfilesystemencoding())
+ except UnicodeEncodeError:
+ skip("encoding not good enough")
+ pid = os.fork()
+ if pid == 0:
+ os.execv(u"/bin/sh", ["sh", "-c",
+ u"echo caf\xe9 \u1234 > /tmp/onefile1"])
+ os.waitpid(pid, 0)
+ with open("/tmp/onefile1") as fid:
+ assert fid.read() == output
+ os.unlink("/tmp/onefile1")
+
+ def test_execve():
+ if not hasattr(os, "fork"):
+ skip("Need fork() to test execve()")
+ if not os.path.isdir('/tmp'):
+ skip("Need '/tmp' for test")
+ pid = os.fork()
+ if pid == 0:
+ os.execve("/bin/sh",
+ ["sh", "-c", "echo -n $ddd > /tmp/onefile2"],
+ {'ddd': 'xxx'},
+ )
+ os.waitpid(pid, 0)
+ assert open("/tmp/onefile2").read() == "xxx"
+ os.unlink("/tmp/onefile2")
+
+ def test_execve_unicode():
+ if not hasattr(os, "fork"):
+ skip("Need fork() to test execve()")
+ if not os.path.isdir('/tmp'):
+ skip("Need '/tmp' for test")
+ try:
+ output = u"caf\xe9 \u1234\n".encode(sys.getfilesystemencoding())
+ except UnicodeEncodeError:
+ skip("encoding not good enough")
+ pid = os.fork()
+ if pid == 0:
+ os.execve(u"/bin/sh", ["sh", "-c",
+ u"echo caf\xe9 \u1234 > /tmp/onefile3"],
+ {'ddd': 'xxx'})
+ os.waitpid(pid, 0)
+ with open("/tmp/onefile3") as fid:
+ assert fid.read() == output
+ os.unlink("/tmp/onefile3")
+ pass # <- please, inspect.getsource(), don't crash
+
+if hasattr(os, "spawnv"):
+ def test_spawnv():
+ ret = os.spawnv(os.P_WAIT, python,
+ [python, '-c', 'raise(SystemExit(42))'])
+ assert ret == 42
+
+if hasattr(os, "spawnve"):
+ def test_spawnve():
+ env = {'FOOBAR': '42'}
+ cmd = "exit $FOOBAR"
+ ret = os.spawnve(os.P_WAIT, "/bin/sh", ["sh", '-c', cmd], env)
+ assert ret == 42
diff --git a/lib-python/2.7/sysconfig.py b/lib-python/2.7/sysconfig.py
index 2b958f2339..44d721db24 100644
--- a/lib-python/2.7/sysconfig.py
+++ b/lib-python/2.7/sysconfig.py
@@ -36,6 +36,16 @@ _INSTALL_SCHEMES = {
'scripts': '{base}/bin',
'data' : '{base}',
},
+ 'nt_pypy': {
+ 'stdlib': '{base}/lib-{implementation_lower}/{py_version_short}',
+ 'platstdlib': '{base}/lib-{implementation_lower}/{py_version_short}',
+ 'purelib': '{base}/site-packages',
+ 'platlib': '{base}/site-packages',
+ 'include': '{base}/include',
+ 'platinclude': '{base}/include',
+ 'scripts': '{base}/Scripts',
+ 'data' : '{base}',
+ },
'nt': {
'stdlib': '{base}/Lib',
'platstdlib': '{base}/Lib',
@@ -182,11 +192,14 @@ def _expand_vars(scheme, vars):
return res
def _get_default_scheme():
- if '__pypy__' in sys.builtin_module_names:
- return 'pypy'
- elif os.name == 'posix':
+ if os.name == 'posix':
+ if '__pypy__' in sys.builtin_module_names:
+ return 'pypy'
# the default scheme for posix is posix_prefix
return 'posix_prefix'
+ if os.name == 'nt':
+ if '__pypy__' in sys.builtin_module_names:
+ return 'nt_pypy'
return os.name
def _getuserbase():
@@ -530,6 +543,8 @@ def get_config_vars(*args):
# multi-architecture, multi-os-version installers
if sys.platform == 'darwin':
import _osx_support
+ #PyPy only - hardcode to 10.7, like in distutils/sysconfig_pypy.py
+ _CONFIG_VARS['MACOSX_DEPLOYMENT_TARGET'] = '10.7'
_osx_support.customize_config_vars(_CONFIG_VARS)
# PyPy:
diff --git a/lib-python/2.7/test/test_urllib2.py b/lib-python/2.7/test/test_urllib2.py
index 0adbb13c43..1829799a93 100644
--- a/lib-python/2.7/test/test_urllib2.py
+++ b/lib-python/2.7/test/test_urllib2.py
@@ -294,6 +294,7 @@ class MockHTTPClass:
self.req_headers = []
self.data = None
self.raise_on_endheaders = False
+ self.sock = None
self._tunnel_headers = {}
def __call__(self, host, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
diff --git a/lib-python/2.7/urllib2.py b/lib-python/2.7/urllib2.py
index b2d1fad6f2..e9fdd43320 100644
--- a/lib-python/2.7/urllib2.py
+++ b/lib-python/2.7/urllib2.py
@@ -1237,6 +1237,12 @@ class AbstractHTTPHandler(BaseHandler):
r = h.getresponse(buffering=True)
except TypeError: # buffering kw not supported
r = h.getresponse()
+ # If the server does not send us a 'Connection: close' header,
+ # HTTPConnection assumes the socket should be left open. Manually
+ # mark the socket to be closed when this response object goes away.
+ if h.sock:
+ h.sock.close()
+ h.sock = None
# Pick apart the HTTPResponse object to get the addinfourl
# object initialized properly.
@@ -1250,6 +1256,8 @@ class AbstractHTTPHandler(BaseHandler):
# out of socket._fileobject() and into a base class.
r.recv = r.read
+ r._reuse = lambda: None
+ r._drop = lambda: None
fp = socket._fileobject(r, close=True)
resp = addinfourl(fp, r.msg, req.get_full_url())
diff --git a/lib_pypy/crypt/__init__.py b/lib_pypy/crypt/__init__.py
index a5790e83ad..83e516011f 100644
--- a/lib_pypy/crypt/__init__.py
+++ b/lib_pypy/crypt/__init__.py
@@ -4,6 +4,12 @@ CFFI based implementation of the crypt module
import sys
import cffi
+import thread
+_lock = thread.allocate_lock()
+
+try: from __pypy__ import builtinify
+except ImportError: builtinify = lambda f: f
+
ffi = cffi.FFI()
ffi.cdef('char *crypt(char *word, char *salt);')
@@ -14,8 +20,10 @@ except OSError:
raise ImportError('crypt not available')
+@builtinify
def crypt(word, salt):
- res = lib.crypt(word, salt)
- if not res:
- return None
- return ffi.string(res)
+ with _lock:
+ res = lib.crypt(word, salt)
+ if not res:
+ return None
+ return ffi.string(res)
diff --git a/lib_pypy/pypy_tools/build_cffi_imports.py b/lib_pypy/pypy_tools/build_cffi_imports.py
index c7005f6461..12e791d695 100644
--- a/lib_pypy/pypy_tools/build_cffi_imports.py
+++ b/lib_pypy/pypy_tools/build_cffi_imports.py
@@ -130,8 +130,11 @@ def _build_dependency(name, patches=[]):
print('unpacking archive', archive, file=sys.stderr)
_unpack_tarfile(archive, deps_destdir)
- sources = os.path.join(deps_destdir, os.path.basename(archive)[:-7])
-
+ sources = os.path.join(
+ deps_destdir,
+ os.path.basename(archive).rsplit('.', 2)[0],
+ )
+
# apply any patches
if patches:
for patch in patches:
diff --git a/pypy/doc/contributing.rst b/pypy/doc/contributing.rst
index bb2f9b445e..f5477e5805 100644
--- a/pypy/doc/contributing.rst
+++ b/pypy/doc/contributing.rst
@@ -100,6 +100,10 @@ If you are new with Mercurial and Heptapod, you can read this `short tutorial`_
.. _`short tutorial`: https://heptapod.net/pages/quick-start-guide.html
+However, we recommend at this time you **not** use topic branches. We prefer
+the usual mercurial named branch model, as pointed out in the :ref:`FAQ
+<github>` about why we didn't move to git.
+
Get Access
----------
diff --git a/pypy/doc/index-of-whatsnew.rst b/pypy/doc/index-of-whatsnew.rst
index 50ee986f13..64061678a0 100644
--- a/pypy/doc/index-of-whatsnew.rst
+++ b/pypy/doc/index-of-whatsnew.rst
@@ -46,6 +46,7 @@ CPython 3.6 compatible versions
.. toctree::
whatsnew-pypy3-head.rst
+ whatsnew-pypy3-7.3.2.rst
whatsnew-pypy3-7.3.1.rst
whatsnew-pypy3-7.3.0.rst
whatsnew-pypy3-7.2.0.rst
diff --git a/pypy/doc/release-v7.3.2.rst b/pypy/doc/release-v7.3.2.rst
index 6013b334bc..a8a2f68a84 100644
--- a/pypy/doc/release-v7.3.2.rst
+++ b/pypy/doc/release-v7.3.2.rst
@@ -290,5 +290,6 @@ Python 3.6 C-API
.. _38243: https://bugs.python.org/issue38243
.. _37461: https://bugs.python.org/issue37461
.. _34155: https://bugs.python.org/issue34155
+.. _41004: https://bugs.python.org/issue41004
.. _`pybind11 2146`: https://github.com/pybind/pybind11/pull/2146
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
index b3cd90b274..242950d072 100644
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -9,3 +9,11 @@ What's new in PyPy2.7 7.3.2+
.. branch: cross_compilation_fixes
Respect PKG_CONFIG and CC in more places to allow cross-compilation
+
+.. branch: darwin-sendfile-2.7
+
+Add posix.sendfile to darwin for python3.6+
+
+.. branch: app_main
+
+avoid using ``import os`` until after ``import site`` in ``app_main``
diff --git a/pypy/doc/whatsnew-pypy3-7.3.1.rst b/pypy/doc/whatsnew-pypy3-7.3.1.rst
index b68cd25349..7b23126e4e 100644
--- a/pypy/doc/whatsnew-pypy3-7.3.1.rst
+++ b/pypy/doc/whatsnew-pypy3-7.3.1.rst
@@ -1,6 +1,6 @@
-==========================
-What's new in PyPy3 7.3.0+
-==========================
+=========================
+What's new in PyPy3 7.3.1
+=========================
.. this is the revision after release-pypy3.6-v7.3.0
.. startrev: a56889d5df88
diff --git a/pypy/doc/whatsnew-pypy3-7.3.2.rst b/pypy/doc/whatsnew-pypy3-7.3.2.rst
new file mode 100644
index 0000000000..34ae286f0f
--- /dev/null
+++ b/pypy/doc/whatsnew-pypy3-7.3.2.rst
@@ -0,0 +1,48 @@
+=========================
+What's new in PyPy3 7.3.2
+=========================
+
+.. this is the revision after release-pypy3.6-v7.3.1
+.. startrev: e81cea3ac65e
+
+.. branch: py3-recvmsg_into
+
+Implement socket.recvmsg_into().
+
+.. branch: py3-posix-fixes
+
+Fix return types in os.readlink() (issue #3177) and os.listdir().
+
+.. branch: winconsoleio
+
+Provide the ``_WindowsConsoleIO`` module on windows. Support may be incomplete.
+
+.. branch: fix-windows-utf8
+
+Fix os.listdir() on Windows with unicode file names
+
+.. branch: locale-encode-decode
+
+Use utf8 in locale.py, add `PyUnicode_{En,De}code_Locale`
+
+.. branch: exc.object
+
+Allow errorhandlers to modify the underlying str/bytes being converted
+
+.. branch: win-unicode
+
+Fix PyUnicode handling of windows where wchar_t is 2 bytes
+
+.. branch: list-with-longs
+
+Internally, integers are W_IntObject or W_LongObject depending on how large
+they are. It's possible to obtain W_LongObject even though the integer is
+small enough, depending on how you build it (e.g. dividing two very large
+integers). The problem now fixed was that these small W_LongObjects caused
+various optimizations to stop working: for example, storing one in a list
+of W_IntObjects caused the list to loose its int optimization (issue #3250).
+
+.. branch: redo-pr-639
+
+Add ``os.sched_rr_get_interval``, ``os.sched_getscheduler``,
+``sched_setscheduler``, ``sched_getparam``
diff --git a/pypy/doc/whatsnew-pypy3-head.rst b/pypy/doc/whatsnew-pypy3-head.rst
index d849f4a121..ea41c9ad25 100644
--- a/pypy/doc/whatsnew-pypy3-head.rst
+++ b/pypy/doc/whatsnew-pypy3-head.rst
@@ -1,7 +1,11 @@
==========================
-What's new in PyPy3 7.3.1+
+What's new in PyPy3 7.3.2+
==========================
-.. this is the revision after release-pypy3.6-v7.3.1
-.. startrev: e81cea3ac65e
+.. this is the revision after release-pypy3.6-v7.3.2
+.. startrev: 9e32f74fc751
+
+.. branch: hpy
+
+Provide a backend for HPy
diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
index 6f72eebb93..6f6879edc1 100755
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -75,6 +75,19 @@ def handle_sys_exit(e):
exitcode = 1
raise SystemExit(exitcode)
+WE_ARE_TRANSLATED = True # patch to False if we're not really translated
+IS_WINDOWS = 'nt' in sys.builtin_module_names
+def get_getenv():
+ try:
+ # we need a version of getenv before we import os
+ from __pypy__.os import real_getenv
+ except ImportError:
+ # dont fail on CPython tests here
+ import os
+ real_getenv = os.getenv
+ return real_getenv
+
+
@hidden_applevel
def run_toplevel(f, *fargs, **fkwds):
"""Calls f() and handles all OperationErrors.
@@ -191,13 +204,16 @@ def get_sys_executable():
return getattr(sys, 'executable', 'pypy')
def print_help(*args):
- import os
+ if IS_WINDOWS:
+ pathsep = ';'
+ else:
+ pathsep = ':'
print 'usage: %s [option] ... [-c cmd | -m mod | file | -] [arg] ...' % (
get_sys_executable(),)
print USAGE1,
if 'pypyjit' in sys.builtin_module_names:
print "--jit options: advanced JIT options: try 'off' or 'help'"
- print (USAGE2 % (os.pathsep,)),
+ print (USAGE2 % (pathsep,)),
raise SystemExit
def _print_jit_help():
@@ -297,18 +313,19 @@ def initstdio(unbuffered=False):
# ____________________________________________________________
# Main entry point
-WE_ARE_TRANSLATED = True # patch to False if we're not really translated
-IS_WINDOWS = 'nt' in sys.builtin_module_names
-
def setup_and_fix_paths(ignore_environment=False, **extra):
- import os
+ if IS_WINDOWS:
+ pathsep = ';'
+ else:
+ pathsep = ':'
+ getenv = get_getenv()
newpath = sys.path[:]
del sys.path[:]
# first prepend PYTHONPATH
readenv = not ignore_environment
- path = readenv and os.getenv('PYTHONPATH')
+ path = readenv and getenv('PYTHONPATH')
if path:
- sys.path.extend(path.split(os.pathsep))
+ sys.path.extend(path.split(pathsep))
# then add again the original entries, ignoring duplicates
_seen = set()
for dir in newpath:
@@ -317,9 +334,13 @@ def setup_and_fix_paths(ignore_environment=False, **extra):
_seen.add(dir)
def set_stdio_encodings(ignore_environment):
- import os
+ if IS_WINDOWS:
+ pathsep = ';'
+ else:
+ pathsep = ':'
+ getenv = get_getenv()
readenv = not ignore_environment
- io_encoding = readenv and os.getenv("PYTHONIOENCODING")
+ io_encoding = readenv and getenv("PYTHONIOENCODING")
if io_encoding:
errors = None
if ":" in io_encoding:
@@ -468,8 +489,8 @@ def handle_argument(c, options, iterargv, iterarg=iter(())):
def parse_env(name, key, options):
''' Modify options inplace if name exists in os.environ
'''
- import os
- v = os.getenv(name)
+ getenv = get_getenv()
+ v = getenv(name)
if v:
options[key] = max(1, options[key])
try:
@@ -481,7 +502,7 @@ def parse_env(name, key, options):
options[key] = max(options[key], newval)
def parse_command_line(argv):
- import os
+ getenv = get_getenv()
options = default_options.copy()
options['warnoptions'] = []
@@ -522,21 +543,21 @@ def parse_command_line(argv):
if not options["ignore_environment"]:
parse_env('PYTHONDEBUG', "debug", options)
- if os.getenv('PYTHONDONTWRITEBYTECODE'):
+ if getenv('PYTHONDONTWRITEBYTECODE'):
options["dont_write_bytecode"] = 1
- if os.getenv('PYTHONNOUSERSITE'):
+ if getenv('PYTHONNOUSERSITE'):
options["no_user_site"] = 1
- if os.getenv('PYTHONUNBUFFERED'):
+ if getenv('PYTHONUNBUFFERED'):
options["unbuffered"] = 1
parse_env('PYTHONVERBOSE', "verbose", options)
parse_env('PYTHONOPTIMIZE', "optimize", options)
if (options["interactive"] or
- (not options["ignore_environment"] and os.getenv('PYTHONINSPECT'))):
+ (not options["ignore_environment"] and getenv('PYTHONINSPECT'))):
options["inspect"] = 1
## We don't print the warning, because it offers no additional security
## in CPython either (http://bugs.python.org/issue14621)
-## if (options["hash_randomization"] or os.getenv('PYTHONHASHSEED')):
+## if (options["hash_randomization"] or getenv('PYTHONHASHSEED')):
## print >> sys.stderr, (
## "Warning: pypy does not implement hash randomization")
@@ -554,7 +575,7 @@ def parse_command_line(argv):
print >> sys.stderr, (
"Warning: pypy does not implement py3k warnings")
- if os.getenv('PYTHONFAULTHANDLER'):
+ if getenv('PYTHONFAULTHANDLER'):
run_faulthandler()
## if not WE_ARE_TRANSLATED:
@@ -580,7 +601,7 @@ def run_command_line(interactive,
# but we need more in the PyPy level for the compiler package
if not WE_ARE_TRANSLATED:
sys.setrecursionlimit(5000)
- import os
+ getenv = get_getenv()
if unbuffered:
set_unbuffered_io()
@@ -603,7 +624,7 @@ def run_command_line(interactive,
set_stdio_encodings(ignore_environment)
readenv = not ignore_environment
- pythonwarnings = readenv and os.getenv('PYTHONWARNINGS')
+ pythonwarnings = readenv and getenv('PYTHONWARNINGS')
if pythonwarnings:
warnoptions.extend(pythonwarnings.split(','))
if warnoptions:
@@ -647,15 +668,8 @@ def run_command_line(interactive,
# or
# * PYTHONINSPECT is set and stdin is a tty.
#
- try:
- # we need a version of getenv that bypasses Python caching
- from __pypy__.os import real_getenv
- except ImportError:
- # dont fail on CPython here
- real_getenv = os.getenv
-
return (interactive or
- ((inspect or (readenv and real_getenv('PYTHONINSPECT')))
+ ((inspect or (readenv and getenv('PYTHONINSPECT')))
and sys.stdin.isatty()))
try:
@@ -697,7 +711,7 @@ def run_command_line(interactive,
# If stdin is a tty or if "-i" is specified, we print
# a banner and run $PYTHONSTARTUP.
print_banner(not no_site)
- python_startup = readenv and os.getenv('PYTHONSTARTUP')
+ python_startup = readenv and getenv('PYTHONSTARTUP')
if python_startup:
try:
with open(python_startup) as f:
@@ -791,7 +805,7 @@ def run_command_line(interactive,
from _pypy_interact import interactive_console
pypy_version_info = getattr(sys, 'pypy_version_info', sys.version_info)
irc_topic = pypy_version_info[3] != 'final' or (
- readenv and os.getenv('PYPY_IRC_TOPIC'))
+ readenv and getenv('PYPY_IRC_TOPIC'))
flags = 0
for fname in __future__.all_feature_names:
feature = getattr(__future__, fname)
@@ -846,11 +860,10 @@ def setup_bootstrap_path(executable):
@hidden_applevel
def entry_point(executable, argv):
- # note that before calling setup_bootstrap_path, we are limited because we
+ # note that before calling 'import site', we are limited because we
# cannot import stdlib modules. In particular, we cannot use unicode
- # stuffs (because we need to be able to import encodings) and we cannot
- # import os, which is used a bit everywhere in app_main, but only imported
- # *after* setup_bootstrap_path
+ # stuffs (because we need to be able to import encodings). The full stdlib
+ # can only be used in a virtualenv after 'import site' in run_command_line
setup_bootstrap_path(executable)
try:
cmdline = parse_command_line(argv)
diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py
index 1529bd9ee7..37de0280c5 100644
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -479,112 +479,6 @@ class AppTestPosix:
_, status = os.waitpid(childpid, 0)
assert status >> 8 == 42
- if hasattr(__import__(os.name), "execv"):
- def test_execv(self):
- os = self.posix
- if not hasattr(os, "fork"):
- skip("Need fork() to test execv()")
- pid = os.fork()
- if pid == 0:
- os.execv("/usr/bin/env", ["env", self.python, "-c",
- ("fid = open('onefile', 'w'); "
- "fid.write('1'); "
- "fid.close()")])
- os.waitpid(pid, 0)
- assert open("onefile").read() == "1"
- os.unlink("onefile")
-
- def test_execv_raising(self):
- os = self.posix
- with raises(OSError):
- os.execv("saddsadsadsadsa", ["saddsadsasaddsa"])
-
- def test_execv_no_args(self):
- os = self.posix
- with raises(ValueError):
- os.execv("notepad", [])
- with raises(ValueError):
- os.execve("notepad", [], {})
-
- def test_execv_raising2(self):
- os = self.posix
- for n in 3, [3, "a"]:
- with raises(TypeError) as excinfo:
- os.execv("xxx", n)
-
- def test_execv_unicode(self):
- os = self.posix
- import sys
- if not hasattr(os, "fork"):
- skip("Need fork() to test execv()")
- try:
- output = u"caf\xe9 \u1234\n".encode(sys.getfilesystemencoding())
- except UnicodeEncodeError:
- skip("encoding not good enough")
- pid = os.fork()
- if pid == 0:
- os.execv(u"/bin/sh", ["sh", "-c",
- u"echo caf\xe9 \u1234 > onefile"])
- os.waitpid(pid, 0)
- with open("onefile") as fid:
- assert fid.read() == output
- os.unlink("onefile")
-
- def test_execve(self):
- os = self.posix
- if not hasattr(os, "fork"):
- skip("Need fork() to test execve()")
- pid = os.fork()
- if pid == 0:
- os.execve("/usr/bin/env", ["env", self.python, "-c",
- ("import os; fid = open('onefile', 'w'); "
- "fid.write(os.environ['ddd']); "
- "fid.close()")],
- {'ddd':'xxx'})
- os.waitpid(pid, 0)
- assert open("onefile").read() == "xxx"
- os.unlink("onefile")
-
- def test_execve_unicode(self):
- os = self.posix
- import sys
- if not hasattr(os, "fork"):
- skip("Need fork() to test execve()")
- try:
- output = u"caf\xe9 \u1234\n".encode(sys.getfilesystemencoding())
- except UnicodeEncodeError:
- skip("encoding not good enough")
- pid = os.fork()
- if pid == 0:
- os.execve(u"/bin/sh", ["sh", "-c",
- u"echo caf\xe9 \u1234 > onefile"],
- {'ddd': 'xxx'})
- os.waitpid(pid, 0)
- with open("onefile") as fid:
- assert fid.read() == output
- os.unlink("onefile")
- pass # <- please, inspect.getsource(), don't crash
-
- if hasattr(__import__(os.name), "spawnv"):
- # spawnv is from stdlib's os, so this test is never run
- def test_spawnv(self):
- os = self.posix
- import sys
- ret = os.spawnv(os.P_WAIT, self.python,
- [self.python, '-c', 'raise(SystemExit(42))'])
- assert ret == 42
-
- if hasattr(__import__(os.name), "spawnve"):
- # spawnve is from stdlib's os, so this test is never run
- def test_spawnve(self):
- os = self.posix
- env = {'PATH':os.environ['PATH'], 'FOOBAR': '42'}
- ret = os.spawnve(os.P_WAIT, self.python,
- [self.python, '-c',
- "raise(SystemExit(int(__import__('os').environ['FOOBAR'])))"],
- env)
- assert ret == 42
-
def test_popen(self):
os = self.posix
for i in range(5):
diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
index 82fe1dc774..aea250610a 100644
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -3,6 +3,7 @@ from rpython.rlib.objectmodel import (instantiate, we_are_translated, specialize
not_rpython)
from rpython.rlib.nonconst import NonConstant
from rpython.rlib.rarithmetic import r_uint, r_singlefloat
+from rpython.rlib.debug import make_sure_not_resized
from rpython.rtyper.extregistry import ExtRegistryEntry
from rpython.rtyper.lltypesystem import lltype
from pypy.tool.option import make_config
@@ -161,6 +162,7 @@ class FakeObjSpace(ObjSpace):
return w_some_obj()
def newtuple(self, list_w):
+ make_sure_not_resized(list_w)
for w_x in list_w:
is_root(w_x)
return w_some_obj()
@@ -173,6 +175,9 @@ class FakeObjSpace(ObjSpace):
newfrozenset = newset
def newlist(self, list_w):
+ # make sure that the annotator thinks that the list is resized
+ list_w.append(W_Root())
+ #
for w_x in list_w:
is_root(w_x)
return W_MyListObj()
diff --git a/pypy/tool/release/repackage.sh b/pypy/tool/release/repackage.sh
index 421e724a4b..b6b4f801c2 100755
--- a/pypy/tool/release/repackage.sh
+++ b/pypy/tool/release/repackage.sh
@@ -1,3 +1,5 @@
+#! /bin/bash
+
# Edit these appropriately before running this script
pmaj=2 # python main version: 2 or 3
pmin=7 # python minor version
@@ -103,21 +105,11 @@ function repackage_builds {
echo no download for $plat
fi
}
+
function repackage_source {
- # Download source and repackage
- # Requires a valid $tagname, note the untarred directory is pypy-pypy-<hash>
- # so make sure there is not another one
- if wget https://foss.heptapod.net/pypy/pypy/repository/$tagname/archive.tar.gz
- then
- tar -xf archive.tar.gz
- rm archive.tar.gz
- mv pypy-release-* $rel-src
- tar --owner=root --group=root --numeric-owner -cjf $rel-src.tar.bz2 $rel-src
- zip -rq $rel-src.zip $rel-src
- rm -rf $rel-src
- else
- echo source tarfile for $tagname not found on bitbucket, did you push the tag commit?
- fi
+ # Requires a valid $tagname
+ hg archive -r $tagname $rel-src.tar.bz2
+ hg archive -r $tagname $rel-src.zip
}
function print_sha256 {
diff --git a/rpython/rlib/rarithmetic.py b/rpython/rlib/rarithmetic.py
index 002eedc44e..d8f06d4ba4 100644
--- a/rpython/rlib/rarithmetic.py
+++ b/rpython/rlib/rarithmetic.py
@@ -715,6 +715,13 @@ class For_r_singlefloat_type_Entry(extregistry.ExtRegistryEntry):
return hop.genop('cast_primitive', [v],
resulttype = lltype.SingleFloat)
+class For_r_longfloat_values_Entry(extregistry.ExtRegistryEntry):
+ _type_ = r_longfloat
+
+ def compute_annotation(self):
+ from rpython.annotator import model as annmodel
+ return annmodel.SomeLongFloat()
+
def int_between(n, m, p):
""" check that n <= m < p. This assumes that n <= p. This is useful because
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
index e2678923f0..088c03022c 100644
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -2744,7 +2744,7 @@ if not _WIN32:
res = c_set_status_flags(fd, flags)
handle_posix_error('set_status_flags', res)
-if not _WIN32:
+if sys.platform.startswith('linux'):
sendfile_eci = ExternalCompilationInfo(includes=["sys/sendfile.h"])
_OFF_PTR_T = rffi.CArrayPtr(OFF_T)
c_sendfile = rffi.llexternal('sendfile',
@@ -2763,6 +2763,30 @@ if not _WIN32:
res = c_sendfile(out_fd, in_fd, lltype.nullptr(_OFF_PTR_T.TO), count)
return handle_posix_error('sendfile', res)
+elif not _WIN32:
+ # Neither on Windows nor on Linux, so probably a BSD derivative of
+ # some sort. Please note that the implementation below is partial;
+ # the VOIDP is an iovec for sending headers and trailers which
+ # CPython uses for the headers and trailers argument, and it also
+ # has a flags argument. None of these are currently supported.
+ sendfile_eci = ExternalCompilationInfo(includes=["sys/socket.h"])
+ _OFF_PTR_T = rffi.CArrayPtr(OFF_T)
+ # NB: the VOIDP is an struct sf_hdtr for sending headers and trailers
+ c_sendfile = rffi.llexternal('sendfile',
+ [rffi.INT, rffi.INT, OFF_T, _OFF_PTR_T, rffi.VOIDP, rffi.INT],
+ rffi.SSIZE_T, save_err=rffi.RFFI_SAVE_ERRNO,
+ compilation_info=sendfile_eci)
+
+ def sendfile(out_fd, in_fd, offset, count):
+ with lltype.scoped_alloc(_OFF_PTR_T.TO, 1) as p_len:
+ p_len[0] = rffi.cast(OFF_T, count)
+ res = c_sendfile(in_fd, out_fd, offset, p_len, lltype.nullptr(rffi.VOIDP.TO), 0)
+ if res != 0:
+ return handle_posix_error('sendfile', res)
+ res = p_len[0]
+ return res
+
+
# ____________________________________________________________
# Support for *xattr functions
diff --git a/rpython/translator/c/primitive.py b/rpython/translator/c/primitive.py
index 417fa9f068..922834f198 100644
--- a/rpython/translator/c/primitive.py
+++ b/rpython/translator/c/primitive.py
@@ -127,7 +127,7 @@ def name_float(value, db):
else:
return '(_PyPy_dg_stdnan(1))'
else:
- x = repr(value)
+ x = repr(float(value))
assert not x.startswith('n')
return x
name_longfloat = name_float
diff --git a/rpython/translator/c/test/test_typed.py b/rpython/translator/c/test/test_typed.py
index d6afbbfbae..e625f29917 100644
--- a/rpython/translator/c/test/test_typed.py
+++ b/rpython/translator/c/test/test_typed.py
@@ -1015,3 +1015,13 @@ class TestTypedTestCase(object):
f = self.getcompiled(func, [int, int, int])
res = f(1192871273, 1837632879, 2001286281)
assert res == 1573897320
+
+ def test_long_float(self):
+ from rpython.rlib.rarithmetic import r_longfloat
+
+ c = rffi.cast(lltype.LongFloat, 123)
+ def func():
+ return rffi.cast(lltype.Float, c)
+ f = self.getcompiled(func, [])
+ res = f()
+ assert res == 123.0
diff --git a/rpython/translator/platform/darwin.py b/rpython/translator/platform/darwin.py
index 2df648f157..73de52c688 100644
--- a/rpython/translator/platform/darwin.py
+++ b/rpython/translator/platform/darwin.py
@@ -20,7 +20,6 @@ class Darwin(posix.BasePosix):
link_flags = (DARWIN_VERSION_MIN,)
cflags = ('-O3',
'-fomit-frame-pointer',
- '-fno-stack-check',
DARWIN_VERSION_MIN,)
so_ext = 'dylib'