[pypy-commit] pypy default: add one test and add signextenstion needed for one case (s390x)

2016-11-09 Thread plan_rich
Author: Richard Plangger 
Branch: 
Changeset: r88247:ce81e2bb2517
Date: 2016-11-09 09:40 +0100
http://bitbucket.org/pypy/pypy/changeset/ce81e2bb2517/

Log:add one test and add signextenstion needed for one case (s390x)

diff --git a/rpython/jit/backend/zarch/instructions.py 
b/rpython/jit/backend/zarch/instructions.py
--- a/rpython/jit/backend/zarch/instructions.py
+++ b/rpython/jit/backend/zarch/instructions.py
@@ -76,7 +76,6 @@
 'CLGRJ':   ('rie_b',  ['\xEC','\x65']),
 # compare and swap
 'CSG': ('rsy_a', ['\xEB','\x30']),
-
 }
 
 logic_mnemonic_codes = {
@@ -340,7 +339,7 @@
 'VLVG':  ('vrs_b', ['\xE7','\x22']),
 'VLGV':  ('vrs_c', ['\xE7','\x21']),
 
-# '': ('', ['','']),
+'VSEG':  ('vrr_a', ['\xE7','\x5F'], 'v,v,m'),
 }
 
 all_mnemonic_codes.update(arith_mnemonic_codes)
diff --git a/rpython/jit/backend/zarch/vector_ext.py 
b/rpython/jit/backend/zarch/vector_ext.py
--- a/rpython/jit/backend/zarch/vector_ext.py
+++ b/rpython/jit/backend/zarch/vector_ext.py
@@ -139,6 +139,8 @@
 self.mc.VLVG(resloc, r.SCRATCH, l.addr(0), 
l.itemsize_to_mask(nsize))
 self.mc.VLGV(r.SCRATCH, loc0, l.addr(1), l.itemsize_to_mask(osize))
 self.mc.VLVG(resloc, r.SCRATCH, l.addr(1), 
l.itemsize_to_mask(nsize))
+if nsize == 8:
+self.mc.VSEG(resloc, resloc, l.itemsize_to_mask(osize))
 
 def emit_vec_float_abs(self, op, arglocs, regalloc):
 resloc, argloc, sizeloc = arglocs
diff --git a/rpython/jit/metainterp/optimizeopt/schedule.py 
b/rpython/jit/metainterp/optimizeopt/schedule.py
--- a/rpython/jit/metainterp/optimizeopt/schedule.py
+++ b/rpython/jit/metainterp/optimizeopt/schedule.py
@@ -14,6 +14,7 @@
 from rpython.jit.metainterp.jitexc import NotAVectorizeableLoop, 
NotAProfitableLoop
 from rpython.rtyper.lltypesystem.lloperation import llop
 from rpython.rtyper.lltypesystem import lltype
+from rpython.rlib.debug import debug_print
 
 
 def forwarded_vecinfo(op):
@@ -315,11 +316,8 @@
 
 def failnbail_transformation(msg):
 msg = '%s\n' % msg
-if we_are_translated():
-llop.debug_print(lltype.Void, msg)
-else:
-import pdb; pdb.set_trace()
-raise NotImplementedError(msg)
+debug_print(msg)
+raise NotAVectorizeableLoop
 
 def turn_into_vector(state, pack):
 """ Turn a pack into a vector instruction """
diff --git a/rpython/jit/metainterp/test/test_vector.py 
b/rpython/jit/metainterp/test/test_vector.py
--- a/rpython/jit/metainterp/test/test_vector.py
+++ b/rpython/jit/metainterp/test/test_vector.py
@@ -860,6 +860,37 @@
 free_raw_storage(vb)
 free_raw_storage(vc)
 
+def test_float_int32_casts(self):
+myjitdriver = JitDriver(greens = [], reds = 'auto', vectorize=True)
+def f(bytecount, va, vb, vc):
+i = 0
+j = 0
+while i < bytecount:
+myjitdriver.jit_merge_point()
+a = raw_storage_getitem(rffi.DOUBLE,va,j)
+b = raw_storage_getitem(rffi.INT,vb,i)
+c = a+rffi.cast(rffi.DOUBLE,b)
+raw_storage_setitem(vc, j, c)
+i += 4
+j += 8
+
+count = 32
+va = alloc_raw_storage(8*count, zero=True)
+vb = alloc_raw_storage(4*count, zero=True)
+for i,v in enumerate([1.0,2.0,3.0,4.0]*(count/4)):
+raw_storage_setitem(va, i*8, rffi.cast(rffi.DOUBLE,v))
+for i,v in enumerate([-1,-2,-3,-4]*(count/4)):
+raw_storage_setitem(vb, i*4, rffi.cast(rffi.INT,v))
+vc = alloc_raw_storage(8*count, zero=True)
+self.meta_interp(f, [8*count, va, vb, vc], vec=True)
+
+for i in range(count):
+assert raw_storage_getitem(rffi.DOUBLE,vc,i*8) == 0.0
+
+free_raw_storage(va)
+free_raw_storage(vb)
+free_raw_storage(vc)
+
 
 class TestLLtype(LLJitMixin, VectorizeTests):
 # skip some tests on this backend
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-pypy2.7-5.x: update repackage script

2016-11-09 Thread mattip
Author: Matti Picus 
Branch: release-pypy2.7-5.x
Changeset: r88248:6b7427d2e889
Date: 2016-11-09 08:21 +0200
http://bitbucket.org/pypy/pypy/changeset/6b7427d2e889/

Log:update repackage script

diff --git a/pypy/tool/release/repackage.sh b/pypy/tool/release/repackage.sh
--- a/pypy/tool/release/repackage.sh
+++ b/pypy/tool/release/repackage.sh
@@ -1,7 +1,7 @@
 # Edit these appropriately before running this script
 maj=5
-min=4
-rev=1
+min=6
+rev=0
 branchname=release-$maj.x  # ==OR== release-$maj.$min.x
 tagname=release-pypy2.7-v$maj.$min.$rev  # ==OR== release-$maj.$min
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-pypy2.7-5.x: add one test and add signextenstion needed for one case (s390x)

2016-11-09 Thread plan_rich
Author: Richard Plangger 
Branch: release-pypy2.7-5.x
Changeset: r88249:9ffb23134573
Date: 2016-11-09 09:40 +0100
http://bitbucket.org/pypy/pypy/changeset/9ffb23134573/

Log:add one test and add signextenstion needed for one case (s390x)

diff --git a/rpython/jit/backend/zarch/instructions.py 
b/rpython/jit/backend/zarch/instructions.py
--- a/rpython/jit/backend/zarch/instructions.py
+++ b/rpython/jit/backend/zarch/instructions.py
@@ -76,7 +76,6 @@
 'CLGRJ':   ('rie_b',  ['\xEC','\x65']),
 # compare and swap
 'CSG': ('rsy_a', ['\xEB','\x30']),
-
 }
 
 logic_mnemonic_codes = {
@@ -340,7 +339,7 @@
 'VLVG':  ('vrs_b', ['\xE7','\x22']),
 'VLGV':  ('vrs_c', ['\xE7','\x21']),
 
-# '': ('', ['','']),
+'VSEG':  ('vrr_a', ['\xE7','\x5F'], 'v,v,m'),
 }
 
 all_mnemonic_codes.update(arith_mnemonic_codes)
diff --git a/rpython/jit/backend/zarch/vector_ext.py 
b/rpython/jit/backend/zarch/vector_ext.py
--- a/rpython/jit/backend/zarch/vector_ext.py
+++ b/rpython/jit/backend/zarch/vector_ext.py
@@ -139,6 +139,8 @@
 self.mc.VLVG(resloc, r.SCRATCH, l.addr(0), 
l.itemsize_to_mask(nsize))
 self.mc.VLGV(r.SCRATCH, loc0, l.addr(1), l.itemsize_to_mask(osize))
 self.mc.VLVG(resloc, r.SCRATCH, l.addr(1), 
l.itemsize_to_mask(nsize))
+if nsize == 8:
+self.mc.VSEG(resloc, resloc, l.itemsize_to_mask(osize))
 
 def emit_vec_float_abs(self, op, arglocs, regalloc):
 resloc, argloc, sizeloc = arglocs
diff --git a/rpython/jit/metainterp/optimizeopt/schedule.py 
b/rpython/jit/metainterp/optimizeopt/schedule.py
--- a/rpython/jit/metainterp/optimizeopt/schedule.py
+++ b/rpython/jit/metainterp/optimizeopt/schedule.py
@@ -14,6 +14,7 @@
 from rpython.jit.metainterp.jitexc import NotAVectorizeableLoop, 
NotAProfitableLoop
 from rpython.rtyper.lltypesystem.lloperation import llop
 from rpython.rtyper.lltypesystem import lltype
+from rpython.rlib.debug import debug_print
 
 
 def forwarded_vecinfo(op):
@@ -315,11 +316,8 @@
 
 def failnbail_transformation(msg):
 msg = '%s\n' % msg
-if we_are_translated():
-llop.debug_print(lltype.Void, msg)
-else:
-import pdb; pdb.set_trace()
-raise NotImplementedError(msg)
+debug_print(msg)
+raise NotAVectorizeableLoop
 
 def turn_into_vector(state, pack):
 """ Turn a pack into a vector instruction """
diff --git a/rpython/jit/metainterp/test/test_vector.py 
b/rpython/jit/metainterp/test/test_vector.py
--- a/rpython/jit/metainterp/test/test_vector.py
+++ b/rpython/jit/metainterp/test/test_vector.py
@@ -862,6 +862,37 @@
 free_raw_storage(vb)
 free_raw_storage(vc)
 
+def test_float_int32_casts(self):
+myjitdriver = JitDriver(greens = [], reds = 'auto', vectorize=True)
+def f(bytecount, va, vb, vc):
+i = 0
+j = 0
+while i < bytecount:
+myjitdriver.jit_merge_point()
+a = raw_storage_getitem(rffi.DOUBLE,va,j)
+b = raw_storage_getitem(rffi.INT,vb,i)
+c = a+rffi.cast(rffi.DOUBLE,b)
+raw_storage_setitem(vc, j, c)
+i += 4
+j += 8
+
+count = 32
+va = alloc_raw_storage(8*count, zero=True)
+vb = alloc_raw_storage(4*count, zero=True)
+for i,v in enumerate([1.0,2.0,3.0,4.0]*(count/4)):
+raw_storage_setitem(va, i*8, rffi.cast(rffi.DOUBLE,v))
+for i,v in enumerate([-1,-2,-3,-4]*(count/4)):
+raw_storage_setitem(vb, i*4, rffi.cast(rffi.INT,v))
+vc = alloc_raw_storage(8*count, zero=True)
+self.meta_interp(f, [8*count, va, vb, vc], vec=True)
+
+for i in range(count):
+assert raw_storage_getitem(rffi.DOUBLE,vc,i*8) == 0.0
+
+free_raw_storage(va)
+free_raw_storage(vb)
+free_raw_storage(vc)
+
 
 class TestLLtype(LLJitMixin, VectorizeTests):
 # skip some tests on this backend
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-pypy2.7-5.x: Win32: pass/skip a few tests

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: release-pypy2.7-5.x
Changeset: r88250:a129d217cb0f
Date: 2016-11-08 20:22 +0100
http://bitbucket.org/pypy/pypy/changeset/a129d217cb0f/

Log:Win32: pass/skip a few tests

diff --git a/pypy/module/posix/test/test_posix2.py 
b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -1157,12 +1157,19 @@
 def setup_class(cls):
 cls.w_path = space.wrap(str(path))
 
-def test_environ(self):
-import posix
-assert posix.environ['PATH']
-del posix.environ['PATH']
-def fn(): posix.environ['PATH']
-raises(KeyError, fn)
+if sys.platform != 'win32':
+def test_environ(self):
+import posix
+assert posix.environ['PATH']
+del posix.environ['PATH']
+def fn(): posix.environ['PATH']
+raises(KeyError, fn)
+else:
+def test_environ(self):
+import nt
+assert 'ADLDJSSLDFKJSD' not in nt.environ
+def fn(): nt.environ['ADLDJSSLDFKJSD']
+raises(KeyError, fn)
 
 if hasattr(__import__(os.name), "unsetenv"):
 def test_unsetenv_nonexisting(self):
@@ -1184,6 +1191,8 @@
 
 class AppTestPosixUnicode:
 def setup_class(cls):
+if sys.platform == 'win32':
+py.test.skip("Posix-only tests")
 if cls.runappdirect:
 # Can't change encoding
 try:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-pypy2.7-5.x: Win32: fix making sockets non-inheritable

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: release-pypy2.7-5.x
Changeset: r88254:536a00a9e525
Date: 2016-11-08 20:02 +0100
http://bitbucket.org/pypy/pypy/changeset/536a00a9e525/

Log:Win32: fix making sockets non-inheritable

diff --git a/rpython/rlib/rposix_stat.py b/rpython/rlib/rposix_stat.py
--- a/rpython/rlib/rposix_stat.py
+++ b/rpython/rlib/rposix_stat.py
@@ -641,6 +641,7 @@
 
 @specialize.arg(0)
 def win32_xstat(traits, path, traverse=False):
+# XXX 'traverse' is ignored
 win32traits = make_win32_traits(traits)
 with lltype.scoped_alloc(
 win32traits.WIN32_FILE_ATTRIBUTE_DATA) as data:
diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -1062,11 +1062,32 @@
 return result
 make_socket._annspecialcase_ = 'specialize:arg(4)'
 
-def sock_set_inheritable(fd, inheritable):
-try:
-rposix.set_inheritable(fd, inheritable)
-except OSError as e:
-raise CSocketError(e.errno)
+if _c.WIN32:
+def sock_set_inheritable(fd, inheritable):
+handle = rffi.cast(rwin32.HANDLE, fd)
+try:
+rwin32.set_handle_inheritable(handle, inheritable)
+except WindowsError:
+raise RSocketError("SetHandleInformation failed")   # xxx
+
+def sock_get_inheritable(fd):
+handle = rffi.cast(rwin32.HANDLE, fd)
+try:
+return rwin32.get_handle_inheritable(handle)
+except WindowsError:
+raise RSocketError("GetHandleInformation failed")   # xxx
+else:
+def sock_set_inheritable(fd, inheritable):
+try:
+rposix.set_inheritable(fd, inheritable)
+except OSError as e:
+raise CSocketError(e.errno)
+
+def sock_get_inheritable(fd):
+try:
+return rposix.get_inheritable(fd)
+except OSError as e:
+raise CSocketError(e.errno)
 
 class SocketError(Exception):
 applevelerrcls = 'error'
diff --git a/rpython/rlib/rwin32.py b/rpython/rlib/rwin32.py
--- a/rpython/rlib/rwin32.py
+++ b/rpython/rlib/rwin32.py
@@ -481,6 +481,10 @@
 
 def set_inheritable(fd, inheritable):
 handle = get_osfhandle(fd)
+set_handle_inheritable(handle, inheritable)
+
+def set_handle_inheritable(handle, inheritable):
+assert lltype.typeOf(handle) is HANDLE
 if inheritable:
 flags = HANDLE_FLAG_INHERIT
 else:
@@ -490,6 +494,10 @@
 
 def get_inheritable(fd):
 handle = get_osfhandle(fd)
+return get_handle_inheritable(handle)
+
+def get_handle_inheritable(handle):
+assert lltype.typeOf(handle) is HANDLE
 pflags = lltype.malloc(LPDWORD.TO, 1, flavor='raw')
 try:
 if not _GetHandleInformation(handle, pflags):
diff --git a/rpython/rlib/test/test_rsocket.py 
b/rpython/rlib/test/test_rsocket.py
--- a/rpython/rlib/test/test_rsocket.py
+++ b/rpython/rlib/test/test_rsocket.py
@@ -124,8 +124,8 @@
 py.test.skip('No socketpair on Windows')
 for inh in [False, True]:
 s1, s2 = socketpair(inheritable=inh)
-assert rposix.get_inheritable(s1.fd) == inh
-assert rposix.get_inheritable(s2.fd) == inh
+assert sock_get_inheritable(s1.fd) == inh
+assert sock_get_inheritable(s2.fd) == inh
 s1.close()
 s2.close()
 
@@ -391,7 +391,7 @@
 def test_inheritable():
 for inh in [False, True]:
 s1 = RSocket(inheritable=inh)
-assert rposix.get_inheritable(s1.fd) == inh
+assert sock_get_inheritable(s1.fd) == inh
 s1.close()
 
 def test_getaddrinfo_http():
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-pypy2.7-5.x: Win32: remove rposix.fdlistdir()

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: release-pypy2.7-5.x
Changeset: r88253:67c58d8dae1a
Date: 2016-11-08 19:15 +0100
http://bitbucket.org/pypy/pypy/changeset/67c58d8dae1a/

Log:Win32: remove rposix.fdlistdir()

diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -679,21 +679,22 @@
 raise OSError(error, "readdir failed")
 return result
 
-def fdlistdir(dirfd):
-"""
-Like listdir(), except that the directory is specified as an open
-file descriptor.
+if not _WIN32:
+def fdlistdir(dirfd):
+"""
+Like listdir(), except that the directory is specified as an open
+file descriptor.
 
-Note: fdlistdir() closes the file descriptor.  To emulate the
-Python 3.x 'os.opendir(dirfd)', you must first duplicate the
-file descriptor.
-"""
-dirp = c_fdopendir(dirfd)
-if not dirp:
-error = get_saved_errno()
-c_close(dirfd)
-raise OSError(error, "opendir failed")
-return _listdir(dirp, rewind=True)
+Note: fdlistdir() closes the file descriptor.  To emulate the
+Python 3.x 'os.opendir(dirfd)', you must first duplicate the
+file descriptor.
+"""
+dirp = c_fdopendir(dirfd)
+if not dirp:
+error = get_saved_errno()
+c_close(dirfd)
+raise OSError(error, "opendir failed")
+return _listdir(dirp, rewind=True)
 
 @replace_os_function('listdir')
 @specialize.argtype(0)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-pypy2.7-5.x: Win32: pass test_rposix.test_putenv

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: release-pypy2.7-5.x
Changeset: r88252:b967d45102c1
Date: 2016-11-08 19:09 +0100
http://bitbucket.org/pypy/pypy/changeset/b967d45102c1/

Log:Win32: pass test_rposix.test_putenv

diff --git a/rpython/rlib/rposix_environ.py b/rpython/rlib/rposix_environ.py
--- a/rpython/rlib/rposix_environ.py
+++ b/rpython/rlib/rposix_environ.py
@@ -201,6 +201,8 @@
 # default implementation for platforms without a real unsetenv()
 r_putenv(name, '')
 
+REAL_UNSETENV = False
+
 if hasattr(__import__(os.name), 'unsetenv'):
 os_unsetenv = rffi.llexternal('unsetenv', [rffi.CCHARP], rffi.INT,
   save_err=rffi.RFFI_SAVE_ERRNO)
@@ -222,3 +224,4 @@
 register_external(r_unsetenv, [str0], annmodel.s_None,
   export_name='ll_os.ll_os_unsetenv',
   llimpl=unsetenv_llimpl)
+REAL_UNSETENV = True
diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -470,11 +470,18 @@
 assert rposix.is_valid_fd(fd) == 0
 
 def test_putenv(self):
+from rpython.rlib import rposix_environ
+
 def f():
 rposix.putenv(self.path, self.path)
 rposix.unsetenv(self.path)
 
-interpret(f, []) # does not crash
+interpret(f, [], # does not crash
+  malloc_check=rposix_environ.REAL_UNSETENV)
+# If we have a real unsetenv(), check that it frees the string
+# kept alive by putenv().  Otherwise, we can't check that,
+# because unsetenv() will keep another string alive itself.
+test_putenv.dont_track_allocations = True
 
 
 class TestPosixAscii(BasePosixUnicodeOrAscii):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-pypy2.7-5.x: Win32: fix set_inheritable tests

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: release-pypy2.7-5.x
Changeset: r88251:c03abff8ff75
Date: 2016-11-08 18:44 +0100
http://bitbucket.org/pypy/pypy/changeset/c03abff8ff75/

Log:Win32: fix set_inheritable tests

diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -1166,6 +1166,10 @@
 @replace_os_function('pipe')
 def pipe(flags=0):
 # 'flags' might be ignored.  Check the result.
+# The handles returned are always inheritable on Posix.
+# The situation on Windows is not completely clear: I think
+# it should always return non-inheritable handles, but CPython
+# uses SECURITY_ATTRIBUTES to ensure that and we don't.
 if _WIN32:
 # 'flags' ignored
 ralloc = lltype.scoped_alloc(rwin32.LPHANDLE.TO, 1)
@@ -2146,8 +2150,9 @@
 handle_posix_error('mknodat', error)
 
 
-eci_inheritable = eci.merge(ExternalCompilationInfo(
-separate_module_sources=[r"""
+if not _WIN32:
+eci_inheritable = eci.merge(ExternalCompilationInfo(
+separate_module_sources=[r"""
 #include 
 #include 
 
@@ -2200,10 +2205,6 @@
 RPY_EXTERN
 int rpy_dup_noninheritable(int fd)
 {
-#ifdef _WIN32
-#error NotImplementedError
-#endif
-
 #ifdef F_DUPFD_CLOEXEC
 return fcntl(fd, F_DUPFD_CLOEXEC, 0);
 #else
@@ -2221,10 +,6 @@
 RPY_EXTERN
 int rpy_dup2_noninheritable(int fd, int fd2)
 {
-#ifdef _WIN32
-#error NotImplementedError
-#endif
-
 #ifdef F_DUP2FD_CLOEXEC
 return fcntl(fd, F_DUP2FD_CLOEXEC, fd2);
 
@@ -2249,33 +2246,41 @@
 return 0;
 #endif
 }
-""" % {'HAVE_DUP3': HAVE_DUP3}],
-post_include_bits=['RPY_EXTERN int rpy_set_inheritable(int, int);\n'
-   'RPY_EXTERN int rpy_get_inheritable(int);\n'
-   'RPY_EXTERN int rpy_dup_noninheritable(int);\n'
-   'RPY_EXTERN int rpy_dup2_noninheritable(int, int);\n']))
+""" % {'HAVE_DUP3': HAVE_DUP3}],
+post_include_bits=['RPY_EXTERN int rpy_set_inheritable(int, int);\n'
+   'RPY_EXTERN int rpy_get_inheritable(int);\n'
+   'RPY_EXTERN int rpy_dup_noninheritable(int);\n'
+   'RPY_EXTERN int rpy_dup2_noninheritable(int, 
int);\n'
+   ]))
 
-c_set_inheritable = external('rpy_set_inheritable', [rffi.INT, rffi.INT],
- rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO,
- compilation_info=eci_inheritable)
-c_get_inheritable = external('rpy_get_inheritable', [rffi.INT],
- rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO,
- compilation_info=eci_inheritable)
-c_dup_noninheritable = external('rpy_dup_noninheritable', [rffi.INT],
-rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO,
-compilation_info=eci_inheritable)
-c_dup2_noninheritable = external('rpy_dup2_noninheritable', 
[rffi.INT,rffi.INT],
- rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO,
- compilation_info=eci_inheritable)
+_c_set_inheritable = external('rpy_set_inheritable', [rffi.INT, rffi.INT],
+  rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO,
+  compilation_info=eci_inheritable)
+_c_get_inheritable = external('rpy_get_inheritable', [rffi.INT],
+  rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO,
+  compilation_info=eci_inheritable)
+c_dup_noninheritable = external('rpy_dup_noninheritable', [rffi.INT],
+rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO,
+compilation_info=eci_inheritable)
+c_dup2_noninheritable = external('rpy_dup2_noninheritable', 
[rffi.INT,rffi.INT],
+ rffi.INT, save_err=rffi.RFFI_SAVE_ERRNO,
+ compilation_info=eci_inheritable)
 
-def set_inheritable(fd, inheritable):
-result = c_set_inheritable(fd, inheritable)
-handle_posix_error('set_inheritable', result)
+def set_inheritable(fd, inheritable):
+result = _c_set_inheritable(fd, inheritable)
+handle_posix_error('set_inheritable', result)
 
-def get_inheritable(fd):
-res = c_get_inheritable(fd)
-res = handle_posix_error('get_inheritable', res)
-return res != 0
+def get_inheritable(fd):
+res = _c_get_inheritable(fd)
+res = handle_posix_error('get_inheritable', res)
+return res != 0
+
+else:
+# _WIN32
+from rpython.rlib.rwin32 import set_inheritable, get_inheritable
+from rpython.rlib.rwin32 import c_dup_noninheritable
+from rpython.rlib.rwin32 import c_dup2_noninheritable
+
 
 class SetNonInheritableCache(object):
 """Make one prebuilt instance of this for each path that creates
diff --git a/rpython/rlib/rwin32.py b/rpython/rlib/rwin32.

[pypy-commit] pypy default: test wrote just after the bounds of the array (test was not broke, just did to much work)

2016-11-09 Thread plan_rich
Author: Richard Plangger 
Branch: 
Changeset: r88255:56484fd5b3d5
Date: 2016-11-09 12:05 +0100
http://bitbucket.org/pypy/pypy/changeset/56484fd5b3d5/

Log:test wrote just after the bounds of the array (test was not broke,
just did to much work)

diff --git a/rpython/jit/metainterp/test/test_vector.py 
b/rpython/jit/metainterp/test/test_vector.py
--- a/rpython/jit/metainterp/test/test_vector.py
+++ b/rpython/jit/metainterp/test/test_vector.py
@@ -865,7 +865,7 @@
 def f(bytecount, va, vb, vc):
 i = 0
 j = 0
-while i < bytecount:
+while j < bytecount:
 myjitdriver.jit_merge_point()
 a = raw_storage_getitem(rffi.DOUBLE,va,j)
 b = raw_storage_getitem(rffi.INT,vb,i)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-pypy2.7-5.x: test wrote just after the bounds of the array (test was not broke, just did to much work)

2016-11-09 Thread plan_rich
Author: Richard Plangger 
Branch: release-pypy2.7-5.x
Changeset: r88257:bf1730c272d9
Date: 2016-11-09 12:05 +0100
http://bitbucket.org/pypy/pypy/changeset/bf1730c272d9/

Log:test wrote just after the bounds of the array (test was not broke,
just did to much work)

diff --git a/rpython/jit/metainterp/test/test_vector.py 
b/rpython/jit/metainterp/test/test_vector.py
--- a/rpython/jit/metainterp/test/test_vector.py
+++ b/rpython/jit/metainterp/test/test_vector.py
@@ -867,7 +867,7 @@
 def f(bytecount, va, vb, vc):
 i = 0
 j = 0
-while i < bytecount:
+while j < bytecount:
 myjitdriver.jit_merge_point()
 a = raw_storage_getitem(rffi.DOUBLE,va,j)
 b = raw_storage_getitem(rffi.INT,vb,i)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-pypy2.7-5.x: account for vector guards while parsing the textual jit log

2016-11-09 Thread plan_rich
Author: Richard Plangger 
Branch: release-pypy2.7-5.x
Changeset: r88256:8629fbc03fd8
Date: 2016-11-08 20:13 +0100
http://bitbucket.org/pypy/pypy/changeset/8629fbc03fd8/

Log:account for vector guards while parsing the textual jit log

diff --git a/rpython/tool/jitlogparser/storage.py 
b/rpython/tool/jitlogparser/storage.py
--- a/rpython/tool/jitlogparser/storage.py
+++ b/rpython/tool/jitlogparser/storage.py
@@ -62,7 +62,7 @@
 guard_dict = {}
 for loop_no, loop in enumerate(loops):
 for op in loop.operations:
-if op.name.startswith('guard_'):
+if op.name.startswith('guard_') or 
op.name.startswith('vec_guard_'):
 guard_dict[int(op.descr[len('https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy space-newtext: _rawffi

2016-11-09 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: space-newtext
Changeset: r88258:6d72a3ca1108
Date: 2016-11-07 18:40 +0100
http://bitbucket.org/pypy/pypy/changeset/6d72a3ca1108/

Log:_rawffi

diff --git a/pypy/module/_rawffi/alt/interp_ffitype.py 
b/pypy/module/_rawffi/alt/interp_ffitype.py
--- a/pypy/module/_rawffi/alt/interp_ffitype.py
+++ b/pypy/module/_rawffi/alt/interp_ffitype.py
@@ -37,7 +37,7 @@
 
 def descr_sizeof(self, space):
 try:
-return space.wrap(self.sizeof())
+return space.newint(self.sizeof())
 except ValueError:
 raise oefmt(space.w_ValueError,
 "Operation not permitted on an incomplete type")
@@ -49,7 +49,7 @@
 return intmask(self.get_ffitype().c_alignment)
 
 def repr(self, space):
-return space.wrap(self.__repr__())
+return space.newtext(self.__repr__())
 
 def __repr__(self):
 name = self.name
diff --git a/pypy/module/_rawffi/alt/interp_funcptr.py 
b/pypy/module/_rawffi/alt/interp_funcptr.py
--- a/pypy/module/_rawffi/alt/interp_funcptr.py
+++ b/pypy/module/_rawffi/alt/interp_funcptr.py
@@ -114,7 +114,7 @@
 try:
 return func_caller.do_and_wrap(self.w_restype)
 except StackCheckError as e:
-raise OperationError(space.w_ValueError, space.wrap(e.message))
+raise OperationError(space.w_ValueError, space.newtext(e.message))
 #return self._do_call(space, argchain)
 
 def free_temp_buffers(self, space):
@@ -129,7 +129,7 @@
 """
 Return the physical address in memory of the function
 """
-return space.wrap(rffi.cast(rffi.LONG, self.func.funcsym))
+return space.newint(rffi.cast(rffi.LONG, self.func.funcsym))
 
 
 class PushArgumentConverter(FromAppLevelConverter):
@@ -213,7 +213,7 @@
 # the correct value, and to be sure to handle the signed/unsigned case
 # correctly, we need to cast the result to the correct type.  After
 # that, we cast it back to LONG, because this is what we want to pass
-# to space.wrap in order to get a nice applevel .
+# to space.newint in order to get a nice applevel .
 #
 restype = w_ffitype.get_ffitype()
 call = self.func.call
@@ -337,11 +337,11 @@
 except KeyError:
 raise oefmt(space.w_ValueError,
 "No symbol %s found in library %s", name, self.name)
-return space.wrap(address_as_uint)
+return space.newint(address_as_uint)
 
 @unwrap_spec(name='str_or_None', mode=int)
 def descr_new_cdll(space, w_type, name, mode=-1):
-return space.wrap(W_CDLL(space, name, mode))
+return W_CDLL(space, name, mode)
 
 
 W_CDLL.typedef = TypeDef(
@@ -358,7 +358,7 @@
 
 @unwrap_spec(name='str_or_None', mode=int)
 def descr_new_windll(space, w_type, name, mode=-1):
-return space.wrap(W_WinDLL(space, name, mode))
+return W_WinDLL(space, name, mode)
 
 
 W_WinDLL.typedef = TypeDef(
@@ -372,7 +372,7 @@
 
 def get_libc(space):
 try:
-return space.wrap(W_CDLL(space, get_libc_name(), -1))
+return W_CDLL(space, get_libc_name(), -1)
 except OSError as e:
 raise wrap_oserror(space, e)
 
diff --git a/pypy/module/_rawffi/alt/interp_struct.py 
b/pypy/module/_rawffi/alt/interp_struct.py
--- a/pypy/module/_rawffi/alt/interp_struct.py
+++ b/pypy/module/_rawffi/alt/interp_struct.py
@@ -176,7 +176,7 @@
 
 def getaddr(self, space):
 addr = rffi.cast(rffi.ULONG, self.rawmem)
-return space.wrap(addr)
+return space.newint(addr)
 
 @unwrap_spec(name=str)
 def getfield(self, space, name):
diff --git a/pypy/module/_rawffi/alt/type_converter.py 
b/pypy/module/_rawffi/alt/type_converter.py
--- a/pypy/module/_rawffi/alt/type_converter.py
+++ b/pypy/module/_rawffi/alt/type_converter.py
@@ -202,7 +202,7 @@
 return self._longlong(w_ffitype)
 elif w_ffitype.is_signed():
 intval = self.get_signed(w_ffitype)
-return space.wrap(intval)
+return space.newint(intval)
 elif (w_ffitype is app_types.ulonglong or
   w_ffitype is app_types.ulong or (libffi.IS_32_BIT and
w_ffitype is app_types.uint)):
@@ -216,19 +216,19 @@
 # and app-evel .  This is why we need to treat it separately
 # than the other unsigned types.
 uintval = self.get_unsigned(w_ffitype)
-return space.wrap(uintval)
+return space.newint(uintval)
 elif w_ffitype.is_unsigned(): # note that ulong is handled just before
 intval = self.get_unsigned_which_fits_into_a_signed(w_ffitype)
-return space.wrap(intval)
+return space.newint(intval)
 elif w_ffitype.is_pointer():
 uintval = self.get_pointer(w_ffitype)
-return space.wrap(uintval)
+return space.newint(uintval)
 elif w_ffityp

[pypy-commit] pypy space-newtext: various fixes

2016-11-09 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: space-newtext
Changeset: r88260:bfc7301d9344
Date: 2016-11-08 14:24 +0100
http://bitbucket.org/pypy/pypy/changeset/bfc7301d9344/

Log:various fixes

diff --git a/pypy/module/_codecs/interp_codecs.py 
b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -478,7 +478,7 @@
 res, consumed, byteorder = runicode.str_decode_utf_16_helper(
 data, len(data), errors, final, state.decode_error_handler, byteorder)
 return space.newtuple([space.newunicode(res), space.newint(consumed),
-   space.newtext(byteorder)])
+   space.newint(byteorder)])
 
 @unwrap_spec(data='bufferstr', errors='str_or_None', byteorder=int,
  w_final=WrappedDefault(False))
@@ -497,7 +497,7 @@
 res, consumed, byteorder = runicode.str_decode_utf_32_helper(
 data, len(data), errors, final, state.decode_error_handler, byteorder)
 return space.newtuple([space.newunicode(res), space.newint(consumed),
-   space.newtext(byteorder)])
+   space.newint(byteorder)])
 
 # 
 # Charmap
diff --git a/pypy/module/_csv/interp_csv.py b/pypy/module/_csv/interp_csv.py
--- a/pypy/module/_csv/interp_csv.py
+++ b/pypy/module/_csv/interp_csv.py
@@ -22,7 +22,7 @@
 ]
 
 def _fetch(space, w_dialect, name):
-return space.findattr(w_dialect, space.wrap(name))
+return space.findattr(w_dialect, space.newtext(name))
 
 def _get_bool(space, w_src, default):
 if w_src is None:
@@ -134,7 +134,7 @@
  w_escapechar, w_lineterminator, w_quotechar,
  w_quoting, w_skipinitialspace, w_strict)
 if space.is_w(w_subtype, space.gettypeobject(W_Dialect.typedef)):
-return space.wrap(dialect)
+return dialect
 else:
 subdialect = space.allocate_instance(W_Dialect, w_subtype)
 subdialect.delimiter= dialect.delimiter
@@ -145,18 +145,18 @@
 subdialect.quoting  = dialect.quoting
 subdialect.skipinitialspace = dialect.skipinitialspace
 subdialect.strict   = dialect.strict
-return space.wrap(subdialect)
+return subdialect
 
 
 def _get_escapechar(space, dialect):
 if dialect.escapechar == '\0':
 return space.w_None
-return space.wrap(dialect.escapechar)
+return space.newtext(dialect.escapechar)
 
 def _get_quotechar(space, dialect):
 if dialect.quotechar == '\0':
 return space.w_None
-return space.wrap(dialect.quotechar)
+return space.newtext(dialect.quotechar)
 
 
 W_Dialect.typedef = TypeDef(
diff --git a/pypy/module/_csv/interp_writer.py 
b/pypy/module/_csv/interp_writer.py
--- a/pypy/module/_csv/interp_writer.py
+++ b/pypy/module/_csv/interp_writer.py
@@ -13,7 +13,7 @@
 def __init__(self, space, dialect, w_fileobj):
 self.space = space
 self.dialect = dialect
-self.w_filewrite = space.getattr(w_fileobj, space.wrap('write'))
+self.w_filewrite = space.getattr(w_fileobj, space.newtext('write'))
 # precompute this
 special = dialect.delimiter + dialect.lineterminator
 if dialect.escapechar != '\0':
@@ -26,8 +26,8 @@
 def error(self, msg):
 space = self.space
 w_module = space.getbuiltinmodule('_csv')
-w_error = space.getattr(w_module, space.wrap('Error'))
-raise OperationError(w_error, space.wrap(msg))
+w_error = space.getattr(w_module, space.newtext('Error'))
+raise OperationError(w_error, space.newtext(msg))
 
 def writerow(self, w_fields):
 """Construct and write a CSV record from a sequence of fields.
@@ -115,7 +115,7 @@
 rec.append(dialect.lineterminator)
 
 line = rec.build()
-return space.call_function(self.w_filewrite, space.wrap(line))
+return space.call_function(self.w_filewrite, space.newtext(line))
 
 def writerows(self, w_seqseq):
 """Construct and write a series of sequences to a csv file.
diff --git a/pypy/module/_demo/demo.py b/pypy/module/_demo/demo.py
--- a/pypy/module/_demo/demo.py
+++ b/pypy/module/_demo/demo.py
@@ -15,7 +15,7 @@
 
 def get(space, name):
 w_module = space.getbuiltinmodule('_demo')
-return space.getattr(w_module, space.wrap(name))
+return space.getattr(w_module, space.newtext(name))
 
 
 @unwrap_spec(repetitions=int)
@@ -27,7 +27,7 @@
 for i in range(repetitions):
 space.call_function(w_callable)
 endtime = time(0)
-return space.wrap(endtime - starttime)
+return space.newint(endtime - starttime)
 
 @unwrap_spec(n=int)
 def sieve(space, n):
@@ -55,10 +55,10 @@
 def multiply(self, w_y):
 space = self.space
 y = space.int_w(w_y)
-return space.wrap(self.x * y)
+return space.newint(self.x * y)
 
 def fget_x(self

[pypy-commit] pypy space-newtext: _cffi_backend (there's a bug somewhere)

2016-11-09 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: space-newtext
Changeset: r88261:ff029105d0dc
Date: 2016-11-08 14:26 +0100
http://bitbucket.org/pypy/pypy/changeset/ff029105d0dc/

Log:_cffi_backend (there's a bug somewhere)

diff --git a/pypy/module/_cffi_backend/allocator.py 
b/pypy/module/_cffi_backend/allocator.py
--- a/pypy/module/_cffi_backend/allocator.py
+++ b/pypy/module/_cffi_backend/allocator.py
@@ -27,7 +27,7 @@
 return cdataobj.W_CDataNewStd(space, ptr, ctype, length)
 else:
 w_raw_cdata = space.call_function(self.w_alloc,
-  space.wrap(datasize))
+  space.newint(datasize))
 if not isinstance(w_raw_cdata, cdataobj.W_CData):
 raise oefmt(space.w_TypeError,
 "alloc() must return a cdata object (got %T)",
@@ -76,7 +76,7 @@
 if w_alloc is None and w_free is not None:
 raise oefmt(space.w_TypeError, "cannot pass 'free' without 'alloc'")
 alloc = W_Allocator(ffi, w_alloc, w_free, bool(should_clear_after_alloc))
-return space.wrap(alloc)
+return alloc
 
 
 default_allocator = W_Allocator(None, None, None, 
should_clear_after_alloc=True)
diff --git a/pypy/module/_cffi_backend/call_python.py 
b/pypy/module/_cffi_backend/call_python.py
--- a/pypy/module/_cffi_backend/call_python.py
+++ b/pypy/module/_cffi_backend/call_python.py
@@ -90,7 +90,7 @@
 ffi = space.interp_w(W_FFIObject, w_ffi)
 
 if space.is_w(w_name, space.w_None):
-w_name = space.getattr(w_python_callable, space.wrap('__name__'))
+w_name = space.getattr(w_python_callable, space.newtext('__name__'))
 name = space.str_w(w_name)
 
 ctx = ffi.ctxobj.ctx
@@ -130,4 +130,4 @@
 
 @specialize.memo()
 def get_generic_decorator(space):
-return space.wrap(interp2app(externpy_deco))
+return space.wrap(interp2app(externpy_deco)) # init time
diff --git a/pypy/module/_cffi_backend/cdataobj.py 
b/pypy/module/_cffi_backend/cdataobj.py
--- a/pypy/module/_cffi_backend/cdataobj.py
+++ b/pypy/module/_cffi_backend/cdataobj.py
@@ -66,13 +66,13 @@
 from pypy.module._cffi_backend import ctypestruct
 if isinstance(self.ctype, ctypestruct.W_CTypeStructOrUnion):
 extra1 = ' &'
-return self.space.wrap("" % (
+return self.space.newtext("" % (
 self.ctype.name, extra1, extra2))
 
 def nonzero(self):
 with self as ptr:
 nonzero = self.ctype.nonzero(ptr)
-return self.space.wrap(nonzero)
+return self.space.newbool(nonzero)
 
 def int(self, space):
 with self as ptr:
@@ -95,7 +95,7 @@
 from pypy.module._cffi_backend import ctypearray
 space = self.space
 if isinstance(self.ctype, ctypearray.W_CTypeArray):
-return space.wrap(self.get_array_length())
+return space.newint(self.get_array_length())
 raise oefmt(space.w_TypeError,
 "cdata of type '%s' has no len()", self.ctype.name)
 
@@ -137,7 +137,7 @@
 # alignment (to 4, 8, maybe 16 bytes), so we use the following
 # formula to avoid the trailing bits being always 0.
 h = h ^ (h >> 4)
-return self.space.wrap(h)
+return self.space.newint(h)
 
 def getitem(self, w_index):
 space = self.space
@@ -319,7 +319,7 @@
 "pointer subtraction: the distance between the two "
 "pointers is not a multiple of the item size")
 diff //= itemsize
-return space.wrap(diff)
+return space.newint(diff)
 #
 return self._add_or_sub(w_other, -1)
 
@@ -430,7 +430,7 @@
 if isinstance(ct, W_CTypePointer):
 ct = ct.ctitem
 lst = ct.cdata_dir()
-return space.newlist([space.wrap(s) for s in lst])
+return space.newlist([space.newtext(s) for s in lst])
 
 def get_structobj(self):
 return None
diff --git a/pypy/module/_cffi_backend/cerrno.py 
b/pypy/module/_cffi_backend/cerrno.py
--- a/pypy/module/_cffi_backend/cerrno.py
+++ b/pypy/module/_cffi_backend/cerrno.py
@@ -13,7 +13,7 @@
 _errno_after  = rposix._errno_after
 
 def get_errno(space):
-return space.wrap(rposix.get_saved_alterrno())
+return space.newint(rposix.get_saved_alterrno())
 
 @unwrap_spec(errno=int)
 def set_errno(space, errno):
@@ -27,4 +27,4 @@
 if code == -1:
 code = GetLastError_alt_saved()
 message = FormatError(code)
-return space.newtuple([space.wrap(code), space.wrap(message)])
+return space.newtuple([space.newint(code), space.newtext(message)])
diff --git a/pypy/module/_cffi_backend/cffi1_module.py 
b/pypy/module/_cffi_backend/cffi1_module.py
--- a/pypy/module/_cffi_backend/cffi1_module.py
+++ b/pypy/module/_cffi_backend/cffi1_module.py
@@ -39,12 +39,12 @@
 if src_ctx.c_includes:
 lib.make_includes_from(src_ctx.c_includes)

[pypy-commit] pypy space-newtext: imp

2016-11-09 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: space-newtext
Changeset: r88262:ea22f9a7e6e7
Date: 2016-11-08 14:38 +0100
http://bitbucket.org/pypy/pypy/changeset/ea22f9a7e6e7/

Log:imp

diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -61,7 +61,7 @@
 verbose = space.sys.get_flag('verbose')
 if verbose >= level:
 w_stderr = space.sys.get('stderr')
-space.call_method(w_stderr, "write", space.wrap(message))
+space.call_method(w_stderr, "write", space.newtext(message))
 
 def file_exists(path):
 """Tests whether the given path is an existing regular file."""
@@ -152,7 +152,6 @@
 return result
 
 def _get_relative_name(space, modulename, level, w_globals):
-w = space.wrap
 ctxt_w_package = space.finditem_str(w_globals, '__package__')
 ctxt_w_package = jit.promote(ctxt_w_package)
 level = jit.promote(level)
@@ -193,7 +192,7 @@
 else:
 msg = ("Parent module '%s' not found while handling absolute "
"import" % ctxt_package)
-space.warn(space.wrap(msg), space.w_RuntimeWarning)
+space.warn(space.newtext(msg), space.w_RuntimeWarning)
 
 rel_modulename = ctxt_package[:dot_position]
 rel_level = rel_modulename.count('.') + 1
@@ -232,15 +231,15 @@
 
 if ctxt_w_path is not None:
 # __path__ is set, so __name__ is already the package name
-space.setitem(w_globals, w("__package__"), ctxt_w_name)
+space.setitem(w_globals, space.newtext("__package__"), ctxt_w_name)
 else:
 # Normal module, so work out the package name if any
 last_dot_position = ctxt_name.rfind('.')
 if last_dot_position < 0:
-space.setitem(w_globals, w("__package__"), space.w_None)
+space.setitem(w_globals, space.newtext("__package__"), 
space.w_None)
 else:
-space.setitem(w_globals, w("__package__"),
-  w(ctxt_name[:last_dot_position]))
+space.setitem(w_globals, space.newtext("__package__"),
+  space.newtext(ctxt_name[:last_dot_position]))
 
 if modulename:
 if rel_modulename:
@@ -257,7 +256,6 @@
 modulename = name
 if not modulename and level < 0:
 raise oefmt(space.w_ValueError, "Empty module name")
-w = space.wrap
 
 if w_fromlist is not None and not space.is_true(w_fromlist):
 w_fromlist = None
@@ -291,7 +289,7 @@
 
 w_mod = absolute_import(space, modulename, 0, w_fromlist, tentative=0)
 if rel_modulename is not None:
-space.setitem(space.sys.get('modules'), w(rel_modulename), 
space.w_None)
+space.setitem(space.sys.get('modules'), space.newtext(rel_modulename), 
space.w_None)
 return w_mod
 
 def absolute_import(space, modulename, baselevel, w_fromlist, tentative):
@@ -329,7 +327,7 @@
 w_mod = check_sys_modules_w(space, modulename)
 first = w_mod
 if w_fromlist is not None and w_mod is not None:
-w_path = try_getattr(space, w_mod, space.wrap('__path__'))
+w_path = try_getattr(space, w_mod, space.newtext('__path__'))
 else:
 level = 0
 first = None
@@ -344,7 +342,7 @@
 if level == baselevel:
 first = w_mod
 if w_fromlist is not None:
-w_path = try_getattr(space, w_mod, space.wrap('__path__'))
+w_path = try_getattr(space, w_mod, space.newtext('__path__'))
 level += 1
 if w_fromlist is not None:
 # bit artificial code but important to not just unwrap w_fromlist
@@ -353,9 +351,9 @@
 if w_path is not None:
 length = space.len_w(w_fromlist)
 if length == 1 and space.eq_w(
-space.getitem(w_fromlist, space.wrap(0)),
-space.wrap('*')):
-w_all = try_getattr(space, w_mod, space.wrap('__all__'))
+space.getitem(w_fromlist, space.newint(0)),
+space.newtext('*')):
+w_all = try_getattr(space, w_mod, space.newtext('__all__'))
 if w_all is not None:
 w_fromlist = w_all
 length = space.len_w(w_fromlist)
@@ -367,15 +365,13 @@
 
 if w_fromlist is not None:
 for i in range(length):
-w_name = space.getitem(w_fromlist, space.wrap(i))
+w_name = space.getitem(w_fromlist, space.newint(i))
 if try_getattr(space, w_mod, w_name) is None:
 return None
 return w_mod
 return first
 
 def _absolute_import(space, modulename, baselevel, w_fromlist, tentative):
-w = space.wrap
-
 if '/' in modulename or '\\' in modulename:
 raise oefmt(space.w_ImportError,
 

[pypy-commit] pypy space-newtext: parser

2016-11-09 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: space-newtext
Changeset: r88263:c5c3e2fb39a6
Date: 2016-11-08 15:08 +0100
http://bitbucket.org/pypy/pypy/changeset/c5c3e2fb39a6/

Log:parser

diff --git a/pypy/module/parser/pyparser.py b/pypy/module/parser/pyparser.py
--- a/pypy/module/parser/pyparser.py
+++ b/pypy/module/parser/pyparser.py
@@ -17,26 +17,26 @@
 def _build_app_tree(self, space, node, seq_maker, with_lineno, 
with_column):
 if node.num_children():
 seq_w = [None]*(node.num_children() + 1)
-seq_w[0] = space.wrap(node.type)
+seq_w[0] = space.newint(node.type)
 for i in range(1, node.num_children() + 1):
 seq_w[i] = self._build_app_tree(space, node.get_child(i - 1),
 seq_maker, with_lineno,
 with_column)
 else:
 seq_w = [None]*(2 + with_lineno + with_column)
-seq_w[0] = space.wrap(node.type)
-seq_w[1] = space.wrap(node.get_value())
+seq_w[0] = space.newint(node.type)
+seq_w[1] = space.newtext(node.get_value())
 if with_lineno:
-seq_w[2] = space.wrap(node.get_lineno())
+seq_w[2] = space.newint(node.get_lineno())
 if with_column:
-seq_w[3] = space.wrap(node.get_column())
+seq_w[3] = space.newint(node.get_column())
 return seq_maker(seq_w)
 
 def descr_issuite(self, space):
-return space.wrap(self.tree.type == pygram.syms.file_input)
+return space.newbool(self.tree.type == pygram.syms.file_input)
 
 def descr_isexpr(self, space):
-return space.wrap(self.tree.type == pygram.syms.eval_input)
+return space.newbool(self.tree.type == pygram.syms.eval_input)
 
 @unwrap_spec(line_info=bool, col_info=bool)
 def descr_totuple(self, space, line_info=False, col_info=False):
@@ -60,7 +60,7 @@
 except error.SyntaxError as e:
 raise OperationError(space.w_SyntaxError,
  e.wrap_info(space))
-return space.wrap(result)
+return result
 
 W_STType.typedef = TypeDef("parser.st",
 issuite=interp2app(W_STType.descr_issuite),
@@ -82,7 +82,7 @@
 except error.SyntaxError as e:
 raise OperationError(space.w_SyntaxError,
  e.wrap_info(space))
-return space.wrap(W_STType(tree, mode))
+return W_STType(tree, mode)
 
 
 @unwrap_spec(source=str)
@@ -105,12 +105,12 @@
 
 @unwrap_spec(w_st=W_STType)
 def st2tuple(space, w_st, __args__):
-return space.call_args(space.getattr(w_st, space.wrap("totuple")), 
__args__)
+return space.call_args(space.getattr(w_st, space.newtext("totuple")), 
__args__)
 
 @unwrap_spec(w_st=W_STType)
 def st2list(space, w_st, __args__):
-return space.call_args(space.getattr(w_st, space.wrap("tolist")), __args__)
+return space.call_args(space.getattr(w_st, space.newtext("tolist")), 
__args__)
 
 @unwrap_spec(w_st=W_STType)
 def compilest(space, w_st, __args__):
-return space.call_args(space.getattr(w_st, space.wrap("compile")), 
__args__)
+return space.call_args(space.getattr(w_st, space.newtext("compile")), 
__args__)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy space-newtext: micronumpy

2016-11-09 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: space-newtext
Changeset: r88259:613414c4df6c
Date: 2016-11-08 12:52 +0100
http://bitbucket.org/pypy/pypy/changeset/613414c4df6c/

Log:micronumpy

diff --git a/pypy/module/micronumpy/arrayops.py 
b/pypy/module/micronumpy/arrayops.py
--- a/pypy/module/micronumpy/arrayops.py
+++ b/pypy/module/micronumpy/arrayops.py
@@ -105,13 +105,13 @@
 raise oefmt(space.w_ValueError, "need at least one array to 
concatenate")
 args_w = [convert_to_array(space, w_arg) for w_arg in args_w]
 if w_axis is None:
-w_axis = space.wrap(0)
+w_axis = space.newint(0)
 if space.is_none(w_axis):
 args_w = [w_arg.reshape(space,
 space.newlist([w_arg.descr_get_size(space)]),
 w_arg.get_order())
   for w_arg in args_w]
-w_axis = space.wrap(0)
+w_axis = space.newint(0)
 dtype = args_w[0].get_dtype()
 shape = args_w[0].get_shape()[:]
 ndim = len(shape)
@@ -184,7 +184,7 @@
 
 
 def count_nonzero(space, w_obj):
-return space.wrap(loop.count_all_true(convert_to_array(space, w_obj)))
+return space.newint(loop.count_all_true(convert_to_array(space, w_obj)))
 
 
 def choose(space, w_arr, w_choices, w_out, w_mode):
diff --git a/pypy/module/micronumpy/base.py b/pypy/module/micronumpy/base.py
--- a/pypy/module/micronumpy/base.py
+++ b/pypy/module/micronumpy/base.py
@@ -136,7 +136,7 @@
 if w_val is not None:
 w_val = dtype.coerce(space, w_val)
 else:
-w_val = dtype.coerce(space, space.wrap(0))
+w_val = dtype.coerce(space, space.newint(0))
 return convert_to_array(space, w_val)
 
 @staticmethod
diff --git a/pypy/module/micronumpy/boxes.py b/pypy/module/micronumpy/boxes.py
--- a/pypy/module/micronumpy/boxes.py
+++ b/pypy/module/micronumpy/boxes.py
@@ -196,11 +196,11 @@
 
 def descr_str(self, space):
 tp = self.get_dtype(space).itemtype
-return space.wrap(tp.str_format(self, add_quotes=False))
+return space.newtext(tp.str_format(self, add_quotes=False))
 
 def descr_repr(self, space):
 tp = self.get_dtype(space).itemtype
-return space.wrap(tp.str_format(self, add_quotes=True))
+return space.newtext(tp.str_format(self, add_quotes=True))
 
 def descr_format(self, space, w_spec):
 return space.format(self.item(space), w_spec)
@@ -209,7 +209,7 @@
 return space.hash(self.item(space))
 
 def descr___array_priority__(self, space):
-return space.wrap(0.0)
+return space.newfloat(0.0)
 
 def descr_index(self, space):
 return space.index(self.item(space))
@@ -242,7 +242,7 @@
 return space.hex(self.descr_int(space))
 
 def descr_nonzero(self, space):
-return space.wrap(self.get_dtype(space).itemtype.bool(self))
+return space.newbool(self.get_dtype(space).itemtype.bool(self))
 
 # TODO: support all kwargs in ufuncs like numpy ufunc_object.c
 sig = None
@@ -385,16 +385,16 @@
 return self.get_dtype(space)
 
 def descr_get_size(self, space):
-return space.wrap(1)
+return space.newint(1)
 
 def descr_get_itemsize(self, space):
-return space.wrap(self.get_dtype(space).elsize)
+return space.newint(self.get_dtype(space).elsize)
 
 def descr_get_shape(self, space):
 return space.newtuple([])
 
 def descr_get_ndim(self, space):
-return space.wrap(0)
+return space.newint(0)
 
 def descr_copy(self, space):
 return self.convert_to(space, self.get_dtype(space))
@@ -412,18 +412,18 @@
 return self.get_dtype(space).itemtype.byteswap(self)
 
 def descr_tostring(self, space, __args__):
-w_meth = space.getattr(self.descr_ravel(space), space.wrap('tostring'))
+w_meth = space.getattr(self.descr_ravel(space), 
space.newtext('tostring'))
 return space.call_args(w_meth, __args__)
 
 def descr_reshape(self, space, __args__):
-w_meth = space.getattr(self.descr_ravel(space), space.wrap('reshape'))
+w_meth = space.getattr(self.descr_ravel(space), 
space.newtext('reshape'))
 w_res = space.call_args(w_meth, __args__)
 if isinstance(w_res, W_NDimArray) and len(w_res.get_shape()) == 0:
 return w_res.get_scalar_value()
 return w_res
 
 def descr_nd_nonzero(self, space, __args__):
-w_meth = space.getattr(self.descr_ravel(space), space.wrap('nonzero'))
+w_meth = space.getattr(self.descr_ravel(space), 
space.newtext('nonzero'))
 return space.call_args(w_meth, __args__)
 
 def descr_get_real(self, space):
@@ -579,7 +579,7 @@
 read_val = dtype.read(self.arr, self.ofs, ofs)
 if isinstance (read_val, W_StringBox):
 # StringType returns a str
-return space.wrap(dtype.itemtype.to_str(read_val))
+return space.newbytes(dtype.itemtype.to_str(r

[pypy-commit] pypy release-pypy2.7-5.x: mark some vector tests x86 only (test cases are written for x86 ISA assumptions)

2016-11-09 Thread plan_rich
Author: Richard Plangger 
Branch: release-pypy2.7-5.x
Changeset: r88264:aff251e54385
Date: 2016-11-08 09:52 +0100
http://bitbucket.org/pypy/pypy/changeset/aff251e54385/

Log:mark some vector tests x86 only (test cases are written for x86 ISA
assumptions)

diff --git a/pypy/module/micronumpy/test/test_zjit.py 
b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -418,9 +418,7 @@
 def test_sum_float_to_int16(self):
 result = self.run("sum_float_to_int16")
 assert result == sum(range(30))
-# one can argue that this is not desired,
-# but unpacking exactly hits savings = 0
-self.check_vectorized(1, 1)
+
 def define_sum_float_to_int32():
 return """
 a = |30|
@@ -429,7 +427,6 @@
 def test_sum_float_to_int32(self):
 result = self.run("sum_float_to_int32")
 assert result == sum(range(30))
-self.check_vectorized(1, 1)
 
 def define_sum_float_to_float32():
 return """
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_schedule.py 
b/rpython/jit/metainterp/optimizeopt/test/test_schedule.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_schedule.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_schedule.py
@@ -1,6 +1,7 @@
 import py
 import sys
 import pytest
+import platform
 
 from rpython.jit.metainterp.history import TargetToken, JitCellToken, TreeLoop
 from rpython.jit.metainterp.optimizeopt.util import equaloplists
@@ -125,6 +126,7 @@
 """, False)
 self.assert_equal(loop2, loop3)
 
+@py.test.mark.skipif("not platform.machine().startswith('x86')")
 def test_int_to_float(self):
 loop1 = self.parse_trace("""
 i10 = raw_load_i(p0, i0, descr=long)
@@ -227,6 +229,7 @@
 """, False, additional_args=['v10[2xi64]'])
 self.assert_equal(loop2, loop3)
 
+@py.test.mark.skipif("not platform.machine().startswith('x86')")
 def test_cast_float_to_int(self):
 loop1 = self.parse_trace("""
 f10 = raw_load_f(p0, i1, descr=double)
diff --git a/rpython/jit/metainterp/test/test_vector.py 
b/rpython/jit/metainterp/test/test_vector.py
--- a/rpython/jit/metainterp/test/test_vector.py
+++ b/rpython/jit/metainterp/test/test_vector.py
@@ -3,7 +3,7 @@
 import pytest
 import math
 import functools
-from hypothesis import given, note, strategies as st
+from hypothesis import given, note, strategies as st, settings
 from rpython.jit.metainterp.warmspot import ll_meta_interp, get_stats
 from rpython.jit.metainterp.test.support import LLJitMixin
 from rpython.jit.codewriter.policy import StopAtXPolicy
@@ -150,9 +150,7 @@
 i += size
 
 la = data.draw(st.lists(st.floats(), min_size=10, max_size=150))
-#la = [0.0, 0.0, 0.0, 0.0, 5e-324, 0.0, 0.0, 5e-324, 0.0, 0.0]
 l = len(la)
-#lb = [0.0] * l
 lb = data.draw(st.lists(st.floats(), min_size=l, max_size=l))
 
 rawstorage = RawStorage()
@@ -181,15 +179,14 @@
 vec_float_binary(lambda a,b: a-b, rffi.DOUBLE)
 test_vec_float_mul = \
 vec_float_binary(lambda a,b: a*b, rffi.DOUBLE)
-#test_vec_float_div = \
-#vec_float_binary(lambda a,b: a/b, rffi.DOUBLE)
 
 test_vec_float_cmp_eq = \
 vec_float_binary(lambda a,b: a == b, rffi.DOUBLE)
 test_vec_float_cmp_ne = \
 vec_float_binary(lambda a,b: a != b, rffi.DOUBLE)
 
-def _vector_simple_int(self, func, type, strat, data):
+def _vector_simple_int(self, func, type, la):
+oldfunc = func
 func = always_inline(func)
 
 size = rffi.sizeof(type)
@@ -204,9 +201,8 @@
 raw_storage_setitem(vc, i, rffi.cast(type,c))
 i += size
 
-la = data.draw(st.lists(strat, min_size=10, max_size=150))
 l = len(la)
-lb = data.draw(st.lists(strat, min_size=l, max_size=l))
+lb = list(reversed(la))[:]
 
 rawstorage = RawStorage()
 va = rawstorage.new(la, type)
@@ -216,7 +212,7 @@
 
 for i in range(l):
 c = raw_storage_getitem(type,vc,i*size)
-assert rffi.cast(type, func(la[i], lb[i])) == c
+assert rffi.cast(type, oldfunc(la[i], lb[i])) == c
 
 rawstorage.clear()
 
@@ -225,50 +221,52 @@
 bits = size*8
 assert 0 <= bits <= 64
 integers = st.integers(min_value=-2**(bits-1), max_value=2**(bits-1)-1)
-return pytest.mark.parametrize('func,type,strat', [
-(arith_func, type, integers)
-])(given(data=st.data())(test_func))
+@given(st.lists(integers, min_size=10, max_size=15))
+@settings(max_examples=20)
+def tf(self, la):
+return test_func(self, arith_func, type, la)
+return tf
 
 vec_int_arith = functools.partial(vec_int_arith, _vector_simple_int)
 
-test_vec_signed_add = \
+test_vec_simple_int_signed_add = \
 vec_int

[pypy-commit] pypy py3.5: add some simple fs en/decode tests

2016-11-09 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: py3.5
Changeset: r88266:c9b8dd4d8872
Date: 2016-11-09 14:17 +0100
http://bitbucket.org/pypy/pypy/changeset/c9b8dd4d8872/

Log:add some simple fs en/decode tests

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1068,9 +1068,6 @@
 from pypy.objspace.std.listobject import make_empty_list_with_size
 return make_empty_list_with_size(self, sizehint)
 
-def wrap_fsdecoded(self, x):
-return self.fsdecode(self.newbytes(x))
-
 @jit.unroll_safe
 def exception_match(self, w_exc_type, w_check_class):
 """Checks if the given exception type matches 'w_check_class'."""
@@ -1680,6 +1677,9 @@
 w_obj = self.fsdecode(w_obj)
 return self.unicode0_w(w_obj)
 
+def wrap_fsdecoded(self, x):
+return self.fsdecode(self.newbytes(x))
+
 def bool_w(self, w_obj):
 # Unwraps a bool, also accepting an int for compatibility.
 # For cases where you need to accept bools and ints and nothing
diff --git a/pypy/interpreter/test/test_fsencode.py 
b/pypy/interpreter/test/test_fsencode.py
--- a/pypy/interpreter/test/test_fsencode.py
+++ b/pypy/interpreter/test/test_fsencode.py
@@ -1,6 +1,7 @@
 import sys
+from pypy.interpreter.error import OperationError
 
-class BaseImportTest:
+class BaseFSEncodeTest:
 
 def setup_class(cls):
 space = cls.space
@@ -60,3 +61,24 @@
 
 if special_char:
 return special_char.decode(fsenc)
+
+class TestFSEncode(BaseFSEncodeTest):
+def test_fsencode_fsdecode(self):
+space = self.space
+strs = [u"/home/bar/baz", u"c:\\"]
+if self.special_char:
+strs.append(self.special_char)
+for st in strs:
+# check roundtrip
+w_st = space.newunicode(st)
+w_enc = space.fsencode(w_st)
+w_st2 = space.fsdecode(w_enc)
+assert space.eq_w(w_st, w_st2)
+assert space.fsdecode_w(w_enc) == st
+
+assert space.fsencode_w(w_enc) == space.bytes_w(w_enc)
+assert space.eq_w(space.wrap_fsdecoded(space.bytes_w(w_enc)), 
w_st2)
+
+def test_error(self):
+raises(OperationError, self.space.fsencode, 
self.space.newbytes(self.testfn_unencodable))
+
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: more uses of fs en/decoding

2016-11-09 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: py3.5
Changeset: r88269:54e6492211f6
Date: 2016-11-09 16:30 +0100
http://bitbucket.org/pypy/pypy/changeset/54e6492211f6/

Log:more uses of fs en/decoding

(no tests. I haven't actually found a way to test this on Linux)

diff --git a/pypy/module/_cffi_backend/cffi1_module.py 
b/pypy/module/_cffi_backend/cffi1_module.py
--- a/pypy/module/_cffi_backend/cffi1_module.py
+++ b/pypy/module/_cffi_backend/cffi1_module.py
@@ -42,7 +42,7 @@
 w_name = space.wrap(name)
 module = Module(space, w_name)
 if path is not None:
-module.setdictvalue(space, '__file__', space.wrap(path))
+module.setdictvalue(space, '__file__', space.wrap_fsdecoded(path))
 module.setdictvalue(space, 'ffi', space.wrap(ffi))
 module.setdictvalue(space, 'lib', space.wrap(lib))
 w_modules_dict = space.sys.get('modules')
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -1511,7 +1511,7 @@
 from pypy.module._cffi_backend import cffi1_module
 cffi1_module.load_cffi1_module(space, name, path, initptr)
 
-@unwrap_spec(path=str, name=str)
+@unwrap_spec(path='fsencode', name=str)
 def load_extension_module(space, path, name):
 # note: this is used both to load CPython-API-style C extension
 # modules (cpyext) and to load CFFI-style extension modules
diff --git a/pypy/module/cpyext/modsupport.py b/pypy/module/cpyext/modsupport.py
--- a/pypy/module/cpyext/modsupport.py
+++ b/pypy/module/cpyext/modsupport.py
@@ -47,7 +47,7 @@
 state.package_context = None, None
 
 if f_path is not None:
-dict_w = {'__file__': space.wrap(f_path)}
+dict_w = {'__file__': space.wrap_fsdecoded(f_path)}
 else:
 dict_w = {}
 convert_method_defs(space, dict_w, methods, None, w_mod, modname)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: misunderstood the use of testfn_unencodable, so this doesn't make sense

2016-11-09 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: py3.5
Changeset: r88267:ba1e8995a96f
Date: 2016-11-09 16:19 +0100
http://bitbucket.org/pypy/pypy/changeset/ba1e8995a96f/

Log:misunderstood the use of testfn_unencodable, so this doesn't make
sense

diff --git a/pypy/interpreter/test/test_fsencode.py 
b/pypy/interpreter/test/test_fsencode.py
--- a/pypy/interpreter/test/test_fsencode.py
+++ b/pypy/interpreter/test/test_fsencode.py
@@ -78,7 +78,3 @@
 
 assert space.fsencode_w(w_enc) == space.bytes_w(w_enc)
 assert space.eq_w(space.wrap_fsdecoded(space.bytes_w(w_enc)), 
w_st2)
-
-def test_error(self):
-raises(OperationError, self.space.fsencode, 
self.space.newbytes(self.testfn_unencodable))
-
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge

2016-11-09 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: py3.5
Changeset: r88270:ecf5ae8f6cbc
Date: 2016-11-09 16:32 +0100
http://bitbucket.org/pypy/pypy/changeset/ecf5ae8f6cbc/

Log:merge

diff --git a/lib-python/3/test/test_httpservers.py 
b/lib-python/3/test/test_httpservers.py
--- a/lib-python/3/test/test_httpservers.py
+++ b/lib-python/3/test/test_httpservers.py
@@ -254,7 +254,8 @@
 
 with support.captured_stderr() as err:
 self.con.request('GET', '/')
-self.con.getresponse()
+with self.con.getresponse():
+pass
 
 self.assertTrue(
 err.getvalue().endswith('"GET / HTTP/1.1" 200 -\n'))
@@ -265,7 +266,8 @@
 
 with support.captured_stderr() as err:
 self.con.request('ERROR', '/')
-self.con.getresponse()
+with self.con.getresponse():
+pass
 
 lines = err.getvalue().split('\n')
 self.assertTrue(lines[0].endswith('code 404, message File not found'))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: use fsencode in _ssl module.

2016-11-09 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: py3.5
Changeset: r88268:1eca675443fa
Date: 2016-11-09 16:22 +0100
http://bitbucket.org/pypy/pypy/changeset/1eca675443fa/

Log:use fsencode in _ssl module.

(the test is not actually good. it passes before the change too)

diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py
--- a/pypy/module/_ssl/interp_ssl.py
+++ b/pypy/module/_ssl/interp_ssl.py
@@ -1597,7 +1597,7 @@
 libssl_SSL_CTX_set_default_passwd_cb_userdata(
 self.ctx, None)
 
-@unwrap_spec(filepath=str)
+@unwrap_spec(filepath='fsencode')
 def load_dh_params_w(self, space, filepath):
 bio = libssl_BIO_new_file(filepath, "r")
 if not bio:
diff --git a/pypy/module/_ssl/test/test_ssl.py 
b/pypy/module/_ssl/test/test_ssl.py
--- a/pypy/module/_ssl/test/test_ssl.py
+++ b/pypy/module/_ssl/test/test_ssl.py
@@ -1,6 +1,8 @@
 from rpython.tool.udir import udir
 import os
 
+from pypy.interpreter.test.test_fsencode import BaseFSEncodeTest
+
 class AppTestSSL:
 spaceconfig = dict(usemodules=('_ssl', '_socket', 'select', 'struct',
'binascii', 'thread'))
@@ -341,10 +343,11 @@
 """)
 
 
-class AppTestContext:
+class AppTestContext(BaseFSEncodeTest):
 spaceconfig = dict(usemodules=('_ssl',))
 
 def setup_class(cls):
+BaseFSEncodeTest.setup_class.im_func(cls)
 tmpfile = udir / "tmpfile.pem"
 tmpfile.write(SSL_CERTIFICATE + SSL_PRIVATE_KEY)
 cls.w_keycert = cls.space.wrap(str(tmpfile))
@@ -366,8 +369,14 @@
 tmpfile = udir / "python.org.pem"
 tmpfile.write(SVN_PYTHON_ORG_ROOT_CERT)
 cls.w_python_org_cert = cls.space.wrap(str(tmpfile))
-cls.w_dh512 = cls.space.wrap(os.path.join(
-os.path.dirname(__file__), 'dh512.pem'))
+tmpfile = udir / cls.special_char
+fn = os.path.join(
+os.path.dirname(__file__), 'dh512.pem')
+with file(fn) as f:
+s = f.read()
+tmpfile.write(s)
+cls.w_dh512 = cls.space.wrap(fn)
+cls.w_dh512special = cls.space.wrap(str(tmpfile))
 
 def test_load_cert_chain(self):
 import _ssl, errno
@@ -443,6 +452,9 @@
 exc = raises(IOError, ctx.load_dh_params, "inexistent.pem")
 assert exc.value.errno == errno.ENOENT
 
+ctx = _ssl._SSLContext(_ssl.PROTOCOL_TLS)
+ctx.load_dh_params(self.dh512special)
+
 def test_set_ecdh_curve(self):
 import _ssl
 ctx = _ssl._SSLContext(_ssl.PROTOCOL_TLS)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: move file from imp/test to interpreter, as basis of more fsencode tests

2016-11-09 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: py3.5
Changeset: r88265:e61a88da0023
Date: 2016-11-09 13:35 +0100
http://bitbucket.org/pypy/pypy/changeset/e61a88da0023/

Log:move file from imp/test to interpreter, as basis of more fsencode
tests

diff --git a/pypy/module/imp/test/support.py 
b/pypy/interpreter/test/test_fsencode.py
rename from pypy/module/imp/test/support.py
rename to pypy/interpreter/test/test_fsencode.py
diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -4,7 +4,7 @@
 from pypy.interpreter import gateway
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.pycode import PyCode
-from pypy.module.imp.test.support import BaseImportTest
+from pypy.interpreter.test.test_fsencode import BaseFSEncodeTest
 from rpython.tool.udir import udir
 from rpython.rlib import streamio
 from pypy.tool.option import make_config
@@ -177,13 +177,13 @@
 """)
 
 
-class AppTestImport(BaseImportTest):
+class AppTestImport(BaseFSEncodeTest):
 spaceconfig = {
 "usemodules": ['_md5', 'time', 'struct', '_pypyjson'],
 }
 
 def setup_class(cls):
-BaseImportTest.setup_class.im_func(cls)
+BaseFSEncodeTest.setup_class.im_func(cls)
 cls.w_runappdirect = cls.space.wrap(conftest.option.runappdirect)
 cls.w_saved_modules = _setup(cls)
 #XXX Compile class
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Fix a warning for PyPy3

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r2808:0ecb431b2b94
Date: 2016-11-09 16:21 +0100
http://bitbucket.org/cffi/cffi/changeset/0ecb431b2b94/

Log:Fix a warning for PyPy3

diff --git a/cffi/_embedding.h b/cffi/_embedding.h
--- a/cffi/_embedding.h
+++ b/cffi/_embedding.h
@@ -358,7 +358,7 @@
 
 /**  PyPy-specific section  **/
 
-PyMODINIT_FUNC _CFFI_PYTHON_STARTUP_FUNC(const void *[]);   /* forward */
+void _CFFI_PYTHON_STARTUP_FUNC(const void *[]);   /* forward */
 
 static struct _cffi_pypy_init_s {
 const char *name;
diff --git a/cffi/recompiler.py b/cffi/recompiler.py
--- a/cffi/recompiler.py
+++ b/cffi/recompiler.py
@@ -392,7 +392,7 @@
 #
 # the init function
 prnt('#ifdef PYPY_VERSION')
-prnt('PyMODINIT_FUNC')
+prnt('void')
 prnt('_cffi_pypyinit_%s(const void *p[])' % (base_module_name,))
 prnt('{')
 if self._num_externpy:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: import cffi/0ecb431b2b94

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r88273:1cf0e7cfa5ef
Date: 2016-11-09 16:22 +0100
http://bitbucket.org/pypy/pypy/changeset/1cf0e7cfa5ef/

Log:import cffi/0ecb431b2b94

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
@@ -141,9 +141,9 @@
 #define _cffi_to_c_char  \
  ((int(*)(PyObject *))_cffi_exports[9])
 #define _cffi_from_c_pointer \
-((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[10])
+((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[10])
 #define _cffi_to_c_pointer   \
-((char *(*)(PyObject *, CTypeDescrObject *))_cffi_exports[11])
+((char *(*)(PyObject *, struct _cffi_ctypedescr *))_cffi_exports[11])
 #define _cffi_get_struct_layout  \
 not used any more
 #define _cffi_restore_errno  \
@@ -153,11 +153,11 @@
 #define _cffi_from_c_char\
 ((PyObject *(*)(char))_cffi_exports[15])
 #define _cffi_from_c_deref   \
-((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[16])
+((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[16])
 #define _cffi_to_c   \
-((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[17])
+((int(*)(char *, struct _cffi_ctypedescr *, PyObject *))_cffi_exports[17])
 #define _cffi_from_c_struct  \
-((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[18])
+((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[18])
 #define _cffi_to_c_wchar_t   \
 ((wchar_t(*)(PyObject *))_cffi_exports[19])
 #define _cffi_from_c_wchar_t \
@@ -167,21 +167,22 @@
 #define _cffi_to_c__Bool \
 ((_Bool(*)(PyObject *))_cffi_exports[22])
 #define _cffi_prepare_pointer_call_argument  \
-((Py_ssize_t(*)(CTypeDescrObject *, PyObject *, char **))_cffi_exports[23])
+((Py_ssize_t(*)(struct _cffi_ctypedescr *,   \
+PyObject *, char **))_cffi_exports[23])
 #define _cffi_convert_array_from_object  \
-((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[24])
+((int(*)(char *, struct _cffi_ctypedescr *, PyObject *))_cffi_exports[24])
 #define _CFFI_CPIDX  25
 #define _cffi_call_python\
 ((void(*)(struct _cffi_externpy_s *, char *))_cffi_exports[_CFFI_CPIDX])
 #define _CFFI_NUM_EXPORTS 26
 
-typedef struct _ctypedescr CTypeDescrObject;
+struct _cffi_ctypedescr;
 
 static void *_cffi_exports[_CFFI_NUM_EXPORTS];
 
 #define _cffi_type(index)   (   \
 assertuintptr_t)_cffi_types[index]) & 1) == 0), \
-(CTypeDescrObject *)_cffi_types[index])
+(struct _cffi_ctypedescr *)_cffi_types[index])
 
 static PyObject *_cffi_init(const char *module_name, Py_ssize_t version,
 const struct _cffi_type_context_s *ctx)
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
@@ -358,7 +358,7 @@
 
 /**  PyPy-specific section  **/
 
-PyMODINIT_FUNC _CFFI_PYTHON_STARTUP_FUNC(const void *[]);   /* forward */
+void _CFFI_PYTHON_STARTUP_FUNC(const void *[]);   /* forward */
 
 static struct _cffi_pypy_init_s {
 const char *name;
diff --git a/lib_pypy/cffi/recompiler.py b/lib_pypy/cffi/recompiler.py
--- a/lib_pypy/cffi/recompiler.py
+++ b/lib_pypy/cffi/recompiler.py
@@ -392,7 +392,7 @@
 #
 # the init function
 prnt('#ifdef PYPY_VERSION')
-prnt('PyMODINIT_FUNC')
+prnt('void')
 prnt('_cffi_pypyinit_%s(const void *p[])' % (base_module_name,))
 prnt('{')
 if self._num_externpy:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Move patch_sys() from _cffi_backend to pypy_setup_home() calling code

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r88271:440d820c878f
Date: 2016-11-09 14:58 +0100
http://bitbucket.org/pypy/pypy/changeset/440d820c878f/

Log:Move patch_sys() from _cffi_backend to pypy_setup_home() calling
code from app_main.py. This is mostly motivated by py3.5, where
setting up correctly 'sys.std*' is more involved.

diff --git a/pypy/goal/targetpypystandalone.py 
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -33,7 +33,12 @@
 if w_dict is not None: # for tests
 w_entry_point = space.getitem(w_dict, space.wrap('entry_point'))
 w_run_toplevel = space.getitem(w_dict, space.wrap('run_toplevel'))
+w_initstdio = space.getitem(w_dict, space.wrap('initstdio'))
 withjit = space.config.objspace.usemodules.pypyjit
+else:
+w_initstdio = space.appexec([], """():
+return lambda unbuffered: None
+""")
 
 def entry_point(argv):
 if withjit:
@@ -103,18 +108,23 @@
   " not found in %s or in any parent directory" % home1)
 return rffi.cast(rffi.INT, 1)
 space.startup()
-space.appexec([w_path], """(path):
-import sys
-sys.path[:] = path
-""")
-# import site
+must_leave = space.threadlocals.try_enter_thread(space)
 try:
-space.setattr(space.getbuiltinmodule('sys'),
-  space.wrap('executable'),
-  space.wrap(home))
-import_ = space.getattr(space.getbuiltinmodule('__builtin__'),
-space.wrap('__import__'))
-space.call_function(import_, space.wrap('site'))
+# initialize sys.{path,executable,stdin,stdout,stderr}
+# (in unbuffered mode, to avoid troubles) and import site
+space.appexec([w_path, space.wrap(home), w_initstdio],
+r"""(path, home, initstdio):
+import sys
+sys.path[:] = path
+sys.executable = home
+initstdio(unbuffered=True)
+try:
+import site
+except Exception as e:
+sys.stderr.write("'import site' failed:\n")
+import traceback
+traceback.print_exc()
+""")
 return rffi.cast(rffi.INT, 0)
 except OperationError as e:
 if verbose:
@@ -122,6 +132,9 @@
 debug(" operror-type: " + e.w_type.getname(space))
 debug(" operror-value: " + 
space.str_w(space.str(e.get_w_value(space
 return rffi.cast(rffi.INT, -1)
+finally:
+if must_leave:
+space.threadlocals.leave_thread(space)
 
 @entrypoint_highlevel('main', [rffi.CCHARP], c_name='pypy_execute_source')
 def pypy_execute_source(ll_source):
diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -275,6 +275,10 @@
 def set_fully_buffered_io():
 sys.stdout = sys.__stdout__ = fdopen(1, 'w')
 
+def initstdio(unbuffered=False):
+if unbuffered:
+set_unbuffered_io()
+
 # 
 # Main entry point
 
diff --git a/pypy/interpreter/test/test_targetpypy.py 
b/pypy/interpreter/test/test_targetpypy.py
--- a/pypy/interpreter/test/test_targetpypy.py
+++ b/pypy/interpreter/test/test_targetpypy.py
@@ -20,7 +20,7 @@
 space.wrap('modules')),
 space.wrap('xyz')))
 assert x == 3
-lls = rffi.str2charp("sys")
+lls = rffi.str2charp("sys   # should give a NameError")
 execute_source(lls)
 lltype.free(lls, flavor='raw')
 # did not crash - the same globals
diff --git a/pypy/module/_cffi_backend/__init__.py 
b/pypy/module/_cffi_backend/__init__.py
--- a/pypy/module/_cffi_backend/__init__.py
+++ b/pypy/module/_cffi_backend/__init__.py
@@ -71,7 +71,6 @@
 def startup(self, space):
 from pypy.module._cffi_backend import embedding
 embedding.glob.space = space
-embedding.glob.patched_sys = False
 
 
 def get_dict_rtld_constants():
diff --git a/pypy/module/_cffi_backend/embedding.py 
b/pypy/module/_cffi_backend/embedding.py
--- a/pypy/module/_cffi_backend/embedding.py
+++ b/pypy/module/_cffi_backend/embedding.py
@@ -45,25 +45,6 @@
 pass
 glob = Global()
 
-def patch_sys(space):
-# Annoying: CPython would just use the C-level std{in,out,err} as
-# configured by the main application, for example in binary mode
-# on Windows or with buffering turned off.  We can't easily do the
-# same.  Instead, go for the safest bet (but possibly bad for
-# performance) and open sys.std{in,out,err} unbuffered.  On
-# Windows I guess binary mode is a bet

[pypy-commit] pypy default: merge heads

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r88275:9d3789ff54e1
Date: 2016-11-09 16:49 +0100
http://bitbucket.org/pypy/pypy/changeset/9d3789ff54e1/

Log:merge heads

diff --git a/pypy/tool/release/repackage.sh b/pypy/tool/release/repackage.sh
--- a/pypy/tool/release/repackage.sh
+++ b/pypy/tool/release/repackage.sh
@@ -1,7 +1,7 @@
 # Edit these appropriately before running this script
 maj=5
-min=4
-rev=1
+min=6
+rev=0
 branchname=release-$maj.x  # ==OR== release-$maj.$min.x
 tagname=release-pypy2.7-v$maj.$min.$rev  # ==OR== release-$maj.$min
 
diff --git a/rpython/jit/backend/zarch/instructions.py 
b/rpython/jit/backend/zarch/instructions.py
--- a/rpython/jit/backend/zarch/instructions.py
+++ b/rpython/jit/backend/zarch/instructions.py
@@ -76,7 +76,6 @@
 'CLGRJ':   ('rie_b',  ['\xEC','\x65']),
 # compare and swap
 'CSG': ('rsy_a', ['\xEB','\x30']),
-
 }
 
 logic_mnemonic_codes = {
@@ -340,7 +339,7 @@
 'VLVG':  ('vrs_b', ['\xE7','\x22']),
 'VLGV':  ('vrs_c', ['\xE7','\x21']),
 
-# '': ('', ['','']),
+'VSEG':  ('vrr_a', ['\xE7','\x5F'], 'v,v,m'),
 }
 
 all_mnemonic_codes.update(arith_mnemonic_codes)
diff --git a/rpython/jit/backend/zarch/vector_ext.py 
b/rpython/jit/backend/zarch/vector_ext.py
--- a/rpython/jit/backend/zarch/vector_ext.py
+++ b/rpython/jit/backend/zarch/vector_ext.py
@@ -139,6 +139,8 @@
 self.mc.VLVG(resloc, r.SCRATCH, l.addr(0), 
l.itemsize_to_mask(nsize))
 self.mc.VLGV(r.SCRATCH, loc0, l.addr(1), l.itemsize_to_mask(osize))
 self.mc.VLVG(resloc, r.SCRATCH, l.addr(1), 
l.itemsize_to_mask(nsize))
+if nsize == 8:
+self.mc.VSEG(resloc, resloc, l.itemsize_to_mask(osize))
 
 def emit_vec_float_abs(self, op, arglocs, regalloc):
 resloc, argloc, sizeloc = arglocs
diff --git a/rpython/jit/metainterp/optimizeopt/schedule.py 
b/rpython/jit/metainterp/optimizeopt/schedule.py
--- a/rpython/jit/metainterp/optimizeopt/schedule.py
+++ b/rpython/jit/metainterp/optimizeopt/schedule.py
@@ -14,6 +14,7 @@
 from rpython.jit.metainterp.jitexc import NotAVectorizeableLoop, 
NotAProfitableLoop
 from rpython.rtyper.lltypesystem.lloperation import llop
 from rpython.rtyper.lltypesystem import lltype
+from rpython.rlib.debug import debug_print
 
 
 def forwarded_vecinfo(op):
@@ -315,11 +316,8 @@
 
 def failnbail_transformation(msg):
 msg = '%s\n' % msg
-if we_are_translated():
-llop.debug_print(lltype.Void, msg)
-else:
-import pdb; pdb.set_trace()
-raise NotImplementedError(msg)
+debug_print(msg)
+raise NotAVectorizeableLoop
 
 def turn_into_vector(state, pack):
 """ Turn a pack into a vector instruction """
diff --git a/rpython/jit/metainterp/test/test_vector.py 
b/rpython/jit/metainterp/test/test_vector.py
--- a/rpython/jit/metainterp/test/test_vector.py
+++ b/rpython/jit/metainterp/test/test_vector.py
@@ -860,6 +860,37 @@
 free_raw_storage(vb)
 free_raw_storage(vc)
 
+def test_float_int32_casts(self):
+myjitdriver = JitDriver(greens = [], reds = 'auto', vectorize=True)
+def f(bytecount, va, vb, vc):
+i = 0
+j = 0
+while j < bytecount:
+myjitdriver.jit_merge_point()
+a = raw_storage_getitem(rffi.DOUBLE,va,j)
+b = raw_storage_getitem(rffi.INT,vb,i)
+c = a+rffi.cast(rffi.DOUBLE,b)
+raw_storage_setitem(vc, j, c)
+i += 4
+j += 8
+
+count = 32
+va = alloc_raw_storage(8*count, zero=True)
+vb = alloc_raw_storage(4*count, zero=True)
+for i,v in enumerate([1.0,2.0,3.0,4.0]*(count/4)):
+raw_storage_setitem(va, i*8, rffi.cast(rffi.DOUBLE,v))
+for i,v in enumerate([-1,-2,-3,-4]*(count/4)):
+raw_storage_setitem(vb, i*4, rffi.cast(rffi.INT,v))
+vc = alloc_raw_storage(8*count, zero=True)
+self.meta_interp(f, [8*count, va, vb, vc], vec=True)
+
+for i in range(count):
+assert raw_storage_getitem(rffi.DOUBLE,vc,i*8) == 0.0
+
+free_raw_storage(va)
+free_raw_storage(vb)
+free_raw_storage(vc)
+
 
 class TestLLtype(LLJitMixin, VectorizeTests):
 # skip some tests on this backend
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: hg merge default

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r88272:5980a1419dc2
Date: 2016-11-09 15:04 +0100
http://bitbucket.org/pypy/pypy/changeset/5980a1419dc2/

Log:hg merge default

diff --git a/pypy/goal/targetpypystandalone.py 
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -34,7 +34,12 @@
 if w_dict is not None: # for tests
 w_entry_point = space.getitem(w_dict, space.wrap('entry_point'))
 w_run_toplevel = space.getitem(w_dict, space.wrap('run_toplevel'))
+w_initstdio = space.getitem(w_dict, space.wrap('initstdio'))
 withjit = space.config.objspace.usemodules.pypyjit
+else:
+w_initstdio = space.appexec([], """():
+return lambda unbuffered: None
+""")
 
 def entry_point(argv):
 if withjit:
@@ -110,18 +115,23 @@
   " not found in %s or in any parent directory" % home1)
 return rffi.cast(rffi.INT, 1)
 space.startup()
-space.appexec([w_path], """(path):
-import sys
-sys.path[:] = path
-""")
-# import site
+must_leave = space.threadlocals.try_enter_thread(space)
 try:
-space.setattr(space.getbuiltinmodule('sys'),
-  space.wrap('executable'),
-  space.wrap(home))
-import_ = space.getattr(space.getbuiltinmodule('builtins'),
-space.wrap('__import__'))
-space.call_function(import_, space.wrap('site'))
+# initialize sys.{path,executable,stdin,stdout,stderr}
+# (in unbuffered mode, to avoid troubles) and import site
+space.appexec([w_path, space.wrap(home), w_initstdio],
+r"""(path, home, initstdio):
+import sys
+sys.path[:] = path
+sys.executable = home
+initstdio(unbuffered=True)
+try:
+import site
+except Exception as e:
+sys.stderr.write("'import site' failed:\n")
+import traceback
+traceback.print_exc()
+""")
 return rffi.cast(rffi.INT, 0)
 except OperationError as e:
 if verbose:
@@ -129,6 +139,9 @@
 debug(" operror-type: " + 
e.w_type.getname(space).encode('utf-8'))
 debug(" operror-value: " + 
space.str_w(space.str(e.get_w_value(space
 return rffi.cast(rffi.INT, -1)
+finally:
+if must_leave:
+space.threadlocals.leave_thread(space)
 
 @entrypoint_highlevel('main', [rffi.CCHARP], c_name='pypy_execute_source')
 def pypy_execute_source(ll_source):
diff --git a/pypy/interpreter/test/test_targetpypy.py 
b/pypy/interpreter/test/test_targetpypy.py
--- a/pypy/interpreter/test/test_targetpypy.py
+++ b/pypy/interpreter/test/test_targetpypy.py
@@ -20,7 +20,7 @@
 space.wrap('modules')),
 space.wrap('xyz')))
 assert x == 3
-lls = rffi.str2charp("sys")
+lls = rffi.str2charp("sys   # should give a NameError")
 execute_source(lls)
 lltype.free(lls, flavor='raw')
 # did not crash - the same globals
diff --git a/pypy/module/_cffi_backend/__init__.py 
b/pypy/module/_cffi_backend/__init__.py
--- a/pypy/module/_cffi_backend/__init__.py
+++ b/pypy/module/_cffi_backend/__init__.py
@@ -71,7 +71,6 @@
 def startup(self, space):
 from pypy.module._cffi_backend import embedding
 embedding.glob.space = space
-embedding.glob.patched_sys = False
 
 
 def get_dict_rtld_constants():
diff --git a/pypy/module/_cffi_backend/embedding.py 
b/pypy/module/_cffi_backend/embedding.py
--- a/pypy/module/_cffi_backend/embedding.py
+++ b/pypy/module/_cffi_backend/embedding.py
@@ -45,25 +45,6 @@
 pass
 glob = Global()
 
-def patch_sys(space):
-# Annoying: CPython would just use the C-level std{in,out,err} as
-# configured by the main application, for example in binary mode
-# on Windows or with buffering turned off.  We can't easily do the
-# same.  Instead, go for the safest bet (but possibly bad for
-# performance) and open sys.std{in,out,err} unbuffered.  On
-# Windows I guess binary mode is a better default choice.
-#
-# XXX if needed, we could add support for a flag passed to
-# pypy_init_embedded_cffi_module().
-if not glob.patched_sys:
-space.appexec([], """():
-import os, sys
-sys.stdin  = sys.__stdin__  = os.fdopen(0, 'rb', 0)
-sys.stdout = sys.__stdout__ = os.fdopen(1, 'wb', 0)
-sys.stderr = sys.__stderr__ = os.fdopen(2, 'wb', 0)
-""")
-glob.patched_sys = True
-
 
 def pypy_init_embedded_cffi_module(version, init_struct):
 # called from __init__.py
@@ -76,7 +57,6 @

[pypy-commit] pypy py3.5: merge heads

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r88276:007445aad81a
Date: 2016-11-09 16:50 +0100
http://bitbucket.org/pypy/pypy/changeset/007445aad81a/

Log:merge heads

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1068,9 +1068,6 @@
 from pypy.objspace.std.listobject import make_empty_list_with_size
 return make_empty_list_with_size(self, sizehint)
 
-def wrap_fsdecoded(self, x):
-return self.fsdecode(self.newbytes(x))
-
 @jit.unroll_safe
 def exception_match(self, w_exc_type, w_check_class):
 """Checks if the given exception type matches 'w_check_class'."""
@@ -1680,6 +1677,9 @@
 w_obj = self.fsdecode(w_obj)
 return self.unicode0_w(w_obj)
 
+def wrap_fsdecoded(self, x):
+return self.fsdecode(self.newbytes(x))
+
 def bool_w(self, w_obj):
 # Unwraps a bool, also accepting an int for compatibility.
 # For cases where you need to accept bools and ints and nothing
diff --git a/pypy/interpreter/test/test_fsencode.py 
b/pypy/interpreter/test/test_fsencode.py
new file mode 100644
--- /dev/null
+++ b/pypy/interpreter/test/test_fsencode.py
@@ -0,0 +1,80 @@
+import sys
+from pypy.interpreter.error import OperationError
+
+class BaseFSEncodeTest:
+
+def setup_class(cls):
+space = cls.space
+cls.testfn_unencodable = get_unencodable()
+cls.w_testfn_unencodable = space.wrap(cls.testfn_unencodable)
+cls.special_char = get_special_char()
+cls.w_special_char = space.wrap(cls.special_char)
+
+def get_unencodable():
+"""Copy of the stdlib's support.TESTFN_UNENCODABLE:
+
+A filename (py3k str type) that should *not* be able to be encoded
+by the filesystem encoding (in strict mode). It can be None if we
+cannot generate such filename.
+"""
+testfn_unencodable = None
+testfn = u'test_tmp'
+
+if sys.platform == 'win32':
+testfn_unencodable = testfn + u"-\u5171\u0141\u2661\u0363\uDC80"
+elif sys.platform != 'darwin':
+try:
+'\xff'.decode(sys.getfilesystemencoding())
+except UnicodeDecodeError:
+testfn_unencodable = testfn + u'-\udcff'
+return testfn_unencodable
+
+def get_special_char():
+"""Copy of the stdlib's test_imp.test_issue5604 special_char:
+
+A non-ascii filename (py3k str type) that *should* be able to be
+encoded by the filesystem encoding (in strict mode). It can be None
+if we cannot generate such filename.
+"""
+fsenc = sys.getfilesystemencoding()
+# covers utf-8 and Windows ANSI code pages one non-space symbol from
+# every page (http://en.wikipedia.org/wiki/Code_page)
+known_locales = {
+'utf-8' : b'\xc3\xa4',
+'cp1250' : b'\x8C',
+'cp1251' : b'\xc0',
+'cp1252' : b'\xc0',
+'cp1253' : b'\xc1',
+'cp1254' : b'\xc0',
+'cp1255' : b'\xe0',
+'cp1256' : b'\xe0',
+'cp1257' : b'\xc0',
+'cp1258' : b'\xc0',
+}
+
+if sys.platform == 'darwin':
+# Mac OS X uses the Normal Form D decomposition
+# http://developer.apple.com/mac/library/qa/qa2001/qa1173.html
+special_char = b'a\xcc\x88'
+else:
+special_char = known_locales.get(fsenc)
+
+if special_char:
+return special_char.decode(fsenc)
+
+class TestFSEncode(BaseFSEncodeTest):
+def test_fsencode_fsdecode(self):
+space = self.space
+strs = [u"/home/bar/baz", u"c:\\"]
+if self.special_char:
+strs.append(self.special_char)
+for st in strs:
+# check roundtrip
+w_st = space.newunicode(st)
+w_enc = space.fsencode(w_st)
+w_st2 = space.fsdecode(w_enc)
+assert space.eq_w(w_st, w_st2)
+assert space.fsdecode_w(w_enc) == st
+
+assert space.fsencode_w(w_enc) == space.bytes_w(w_enc)
+assert space.eq_w(space.wrap_fsdecoded(space.bytes_w(w_enc)), 
w_st2)
diff --git a/pypy/module/_cffi_backend/cffi1_module.py 
b/pypy/module/_cffi_backend/cffi1_module.py
--- a/pypy/module/_cffi_backend/cffi1_module.py
+++ b/pypy/module/_cffi_backend/cffi1_module.py
@@ -42,7 +42,7 @@
 w_name = space.wrap(name)
 module = Module(space, w_name)
 if path is not None:
-module.setdictvalue(space, '__file__', space.wrap(path))
+module.setdictvalue(space, '__file__', space.wrap_fsdecoded(path))
 module.setdictvalue(space, 'ffi', space.wrap(ffi))
 module.setdictvalue(space, 'lib', space.wrap(lib))
 w_modules_dict = space.sys.get('modules')
diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py
--- a/pypy/module/_ssl/interp_ssl.py
+++ b/pypy/module/_ssl/interp_ssl.py
@@ -1597,7 +1597,7 @@
 libssl_SSL_CTX_set_default_passwd_cb_userdata(
 self.ctx, None)
 
-@unwrap_spec(filepath=

[pypy-commit] pypy py3.5: hg merge default

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r88274:43cb58034ee2
Date: 2016-11-09 16:22 +0100
http://bitbucket.org/pypy/pypy/changeset/43cb58034ee2/

Log:hg merge default

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
@@ -141,9 +141,9 @@
 #define _cffi_to_c_char  \
  ((int(*)(PyObject *))_cffi_exports[9])
 #define _cffi_from_c_pointer \
-((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[10])
+((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[10])
 #define _cffi_to_c_pointer   \
-((char *(*)(PyObject *, CTypeDescrObject *))_cffi_exports[11])
+((char *(*)(PyObject *, struct _cffi_ctypedescr *))_cffi_exports[11])
 #define _cffi_get_struct_layout  \
 not used any more
 #define _cffi_restore_errno  \
@@ -153,11 +153,11 @@
 #define _cffi_from_c_char\
 ((PyObject *(*)(char))_cffi_exports[15])
 #define _cffi_from_c_deref   \
-((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[16])
+((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[16])
 #define _cffi_to_c   \
-((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[17])
+((int(*)(char *, struct _cffi_ctypedescr *, PyObject *))_cffi_exports[17])
 #define _cffi_from_c_struct  \
-((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[18])
+((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[18])
 #define _cffi_to_c_wchar_t   \
 ((wchar_t(*)(PyObject *))_cffi_exports[19])
 #define _cffi_from_c_wchar_t \
@@ -167,21 +167,22 @@
 #define _cffi_to_c__Bool \
 ((_Bool(*)(PyObject *))_cffi_exports[22])
 #define _cffi_prepare_pointer_call_argument  \
-((Py_ssize_t(*)(CTypeDescrObject *, PyObject *, char **))_cffi_exports[23])
+((Py_ssize_t(*)(struct _cffi_ctypedescr *,   \
+PyObject *, char **))_cffi_exports[23])
 #define _cffi_convert_array_from_object  \
-((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[24])
+((int(*)(char *, struct _cffi_ctypedescr *, PyObject *))_cffi_exports[24])
 #define _CFFI_CPIDX  25
 #define _cffi_call_python\
 ((void(*)(struct _cffi_externpy_s *, char *))_cffi_exports[_CFFI_CPIDX])
 #define _CFFI_NUM_EXPORTS 26
 
-typedef struct _ctypedescr CTypeDescrObject;
+struct _cffi_ctypedescr;
 
 static void *_cffi_exports[_CFFI_NUM_EXPORTS];
 
 #define _cffi_type(index)   (   \
 assertuintptr_t)_cffi_types[index]) & 1) == 0), \
-(CTypeDescrObject *)_cffi_types[index])
+(struct _cffi_ctypedescr *)_cffi_types[index])
 
 static PyObject *_cffi_init(const char *module_name, Py_ssize_t version,
 const struct _cffi_type_context_s *ctx)
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
@@ -358,7 +358,7 @@
 
 /**  PyPy-specific section  **/
 
-PyMODINIT_FUNC _CFFI_PYTHON_STARTUP_FUNC(const void *[]);   /* forward */
+void _CFFI_PYTHON_STARTUP_FUNC(const void *[]);   /* forward */
 
 static struct _cffi_pypy_init_s {
 const char *name;
diff --git a/lib_pypy/cffi/recompiler.py b/lib_pypy/cffi/recompiler.py
--- a/lib_pypy/cffi/recompiler.py
+++ b/lib_pypy/cffi/recompiler.py
@@ -392,7 +392,7 @@
 #
 # the init function
 prnt('#ifdef PYPY_VERSION')
-prnt('PyMODINIT_FUNC')
+prnt('void')
 prnt('_cffi_pypyinit_%s(const void *p[])' % (base_module_name,))
 prnt('{')
 if self._num_externpy:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-pypy3.5-5.x: open new release branch for pypy3.5-5.x

2016-11-09 Thread plan_rich
Author: Richard Plangger 
Branch: release-pypy3.5-5.x
Changeset: r88277:b35e13efd43f
Date: 2016-11-09 17:02 +0100
http://bitbucket.org/pypy/pypy/changeset/b35e13efd43f/

Log:open new release branch for pypy3.5-5.x

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-pypy3.5-5.x: merge current head (py3.5) into release branch

2016-11-09 Thread plan_rich
Author: Richard Plangger 
Branch: release-pypy3.5-5.x
Changeset: r88278:33d015479c3c
Date: 2016-11-09 17:04 +0100
http://bitbucket.org/pypy/pypy/changeset/33d015479c3c/

Log:merge current head (py3.5) into release branch

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
@@ -141,9 +141,9 @@
 #define _cffi_to_c_char  \
  ((int(*)(PyObject *))_cffi_exports[9])
 #define _cffi_from_c_pointer \
-((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[10])
+((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[10])
 #define _cffi_to_c_pointer   \
-((char *(*)(PyObject *, CTypeDescrObject *))_cffi_exports[11])
+((char *(*)(PyObject *, struct _cffi_ctypedescr *))_cffi_exports[11])
 #define _cffi_get_struct_layout  \
 not used any more
 #define _cffi_restore_errno  \
@@ -153,11 +153,11 @@
 #define _cffi_from_c_char\
 ((PyObject *(*)(char))_cffi_exports[15])
 #define _cffi_from_c_deref   \
-((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[16])
+((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[16])
 #define _cffi_to_c   \
-((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[17])
+((int(*)(char *, struct _cffi_ctypedescr *, PyObject *))_cffi_exports[17])
 #define _cffi_from_c_struct  \
-((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[18])
+((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[18])
 #define _cffi_to_c_wchar_t   \
 ((wchar_t(*)(PyObject *))_cffi_exports[19])
 #define _cffi_from_c_wchar_t \
@@ -167,21 +167,22 @@
 #define _cffi_to_c__Bool \
 ((_Bool(*)(PyObject *))_cffi_exports[22])
 #define _cffi_prepare_pointer_call_argument  \
-((Py_ssize_t(*)(CTypeDescrObject *, PyObject *, char **))_cffi_exports[23])
+((Py_ssize_t(*)(struct _cffi_ctypedescr *,   \
+PyObject *, char **))_cffi_exports[23])
 #define _cffi_convert_array_from_object  \
-((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[24])
+((int(*)(char *, struct _cffi_ctypedescr *, PyObject *))_cffi_exports[24])
 #define _CFFI_CPIDX  25
 #define _cffi_call_python\
 ((void(*)(struct _cffi_externpy_s *, char *))_cffi_exports[_CFFI_CPIDX])
 #define _CFFI_NUM_EXPORTS 26
 
-typedef struct _ctypedescr CTypeDescrObject;
+struct _cffi_ctypedescr;
 
 static void *_cffi_exports[_CFFI_NUM_EXPORTS];
 
 #define _cffi_type(index)   (   \
 assertuintptr_t)_cffi_types[index]) & 1) == 0), \
-(CTypeDescrObject *)_cffi_types[index])
+(struct _cffi_ctypedescr *)_cffi_types[index])
 
 static PyObject *_cffi_init(const char *module_name, Py_ssize_t version,
 const struct _cffi_type_context_s *ctx)
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
@@ -358,7 +358,7 @@
 
 /**  PyPy-specific section  **/
 
-PyMODINIT_FUNC _CFFI_PYTHON_STARTUP_FUNC(const void *[]);   /* forward */
+void _CFFI_PYTHON_STARTUP_FUNC(const void *[]);   /* forward */
 
 static struct _cffi_pypy_init_s {
 const char *name;
diff --git a/lib_pypy/cffi/recompiler.py b/lib_pypy/cffi/recompiler.py
--- a/lib_pypy/cffi/recompiler.py
+++ b/lib_pypy/cffi/recompiler.py
@@ -392,7 +392,7 @@
 #
 # the init function
 prnt('#ifdef PYPY_VERSION')
-prnt('PyMODINIT_FUNC')
+prnt('void')
 prnt('_cffi_pypyinit_%s(const void *p[])' % (base_module_name,))
 prnt('{')
 if self._num_externpy:
diff --git a/pypy/goal/targetpypystandalone.py 
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -34,7 +34,12 @@
 if w_dict is not None: # for tests
 w_entry_point = space.getitem(w_dict, space.wrap('entry_point'))
 w_run_toplevel = space.getitem(w_dict, space.wrap('run_toplevel'))
+w_initstdio = space.getitem(w_dict, space.wrap('initstdio'))
 withjit = space.config.objspace.usemodules.pypyjit
+else:
+w_initstdio = space.appexec([], """():
+return lambda unbuffered: None
+""")
 
 def entry_point(argv):
 if 

[pypy-commit] extradoc extradoc: updates

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: extradoc
Changeset: r5745:dac018501316
Date: 2016-11-09 17:18 +0100
http://bitbucket.org/pypy/extradoc/changeset/dac018501316/

Log:updates

diff --git a/planning/py3.5/cpython-crashers.rst 
b/planning/py3.5/cpython-crashers.rst
--- a/planning/py3.5/cpython-crashers.rst
+++ b/planning/py3.5/cpython-crashers.rst
@@ -96,4 +96,5 @@
  
 * hash({}.values()) works (but hash({}.keys()) correctly gives
   TypeError).  That's a bit confusing and, as far as I can tell, always
-  pointless.
+  pointless.  Also, related: d.keys()==d.keys() but
+  d.values()!=d.values().
diff --git a/planning/py3.5/milestone-1-progress.rst 
b/planning/py3.5/milestone-1-progress.rst
--- a/planning/py3.5/milestone-1-progress.rst
+++ b/planning/py3.5/milestone-1-progress.rst
@@ -5,7 +5,7 @@
 In-progress ("Lock" section)
 
 
-nothing
+* bytes % args, bytearray % args (arigo)
 
 
 Misc stuff not formally in any milestone
@@ -69,7 +69,7 @@
 * The new os.scandir() function (POSIX-DONE, missing Win32)
 
 * Newly created file descriptors are non-inheritable (PEP 446) 
-  (POSIX-DONE, missing Win32)
+  (DONE)
 
 * The marshal format has been made more compact and efficient
   (DONE, maybe a small optimization left---TYPE_*ASCII*---that
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Fix for %s on bytes, otherwise it already works

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r88280:fd7154e68fb8
Date: 2016-11-09 17:44 +0100
http://bitbucket.org/pypy/pypy/changeset/fd7154e68fb8/

Log:Fix for %s on bytes, otherwise it already works

diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -422,20 +422,18 @@
 return space.str_w(w_result)
 
 def fmt_s(self, w_value):
+if not do_unicode:
+# on bytes, %s is equivalent to %b
+self.fmt_b(w_value)
+return
 space = self.space
-got_unicode = space.isinstance_w(w_value,
- space.w_unicode)
-if not do_unicode:
-if got_unicode:
-raise NeedUnicodeFormattingError
-s = self.string_formatting(w_value)
+got_unicode = space.isinstance_w(w_value, space.w_unicode)
+if not got_unicode:
+w_value = space.call_function(space.w_unicode, w_value)
 else:
-if not got_unicode:
-w_value = space.call_function(space.w_unicode, w_value)
-else:
-from pypy.objspace.std.unicodeobject import 
unicode_from_object
-w_value = unicode_from_object(space, w_value)
-s = space.unicode_w(w_value)
+from pypy.objspace.std.unicodeobject import unicode_from_object
+w_value = unicode_from_object(space, w_value)
+s = space.unicode_w(w_value)
 self.std_wp(s)
 
 def fmt_r(self, w_value):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Exhaustive tests for bytes '%' formatting (pep461)

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r88279:fbf931ce560d
Date: 2016-11-09 17:41 +0100
http://bitbucket.org/pypy/pypy/changeset/fbf931ce560d/

Log:Exhaustive tests for bytes '%' formatting (pep461)

diff --git a/pypy/objspace/std/test/test_stringformat.py 
b/pypy/objspace/std/test/test_stringformat.py
--- a/pypy/objspace/std/test/test_stringformat.py
+++ b/pypy/objspace/std/test/test_stringformat.py
@@ -333,9 +333,102 @@
 assert "<%r>" % "\xe9" == "<'\xe9'>"
 assert "<%a>" % "\xe9" == "<'\\xe9'>"
 
+
+class AppTestBytes:
+
 def test_ascii_bytes(self):
 assert b"<%a>" % b"test" == b""
 assert b"<%a>" % b"\t\x80" == b""
 assert repr(b"\xe9") == "b'\\xe9'"
+assert b"<%a>" % b"\xe9" == b""
+assert b"<%a>" % "foo" == b"<'foo'>"
+assert b"<%a>" % "\u1234" == b"<'\\u1234'>"
+
+def test_r_compat_bytes(self):
+assert b"<%r>" % b"test" == b""
+assert b"<%r>" % b"\t\x80" == b""
+assert repr(b"\xe9") == "b'\\xe9'"
 assert b"<%r>" % b"\xe9" == b""
-assert b"<%a>" % b"\xe9" == b""
+assert b"<%r>" % "foo" == b"<'foo'>"
+assert b"<%r>" % "\u1234" == b"<'\\u1234'>"
+
+def test_numeric_bytes(self):
+assert b"<%4x>" % 10 == b"<   a>"
+assert b"<%#4x>" % 10 == b"< 0xa>"
+assert b"<%04X>" % 10 == b"<000A>"
+
+def test_char_bytes(self):
+assert b"<%c>" % 48 == b"<0>"
+assert b"<%c>" % b"?" == b""
+raises(TypeError, 'b"<%c>" % "?"')
+
+def test_bytes_bytes(self):
+assert b"<%b>" % b"123" == b"<123>"
+class Foo:
+def __bytes__(self):
+return b"123"
+assert b"<%b>" % Foo() == b"<123>"
+raises(TypeError, 'b"<%b>" % 42')
+raises(TypeError, 'b"<%b>" % "?"')
+
+def test_s_compat_bytes(self):
+assert b"<%s>" % b"123" == b"<123>"
+class Foo:
+def __bytes__(self):
+return b"123"
+assert b"<%s>" % Foo() == b"<123>"
+raises(TypeError, 'b"<%s>" % 42')
+raises(TypeError, 'b"<%s>" % "?"')
+
+
+class AppTestBytearray:
+
+def test_ascii_bytes(self):
+assert bytearray(b"<%a>") % b"test" == bytearray(b"")
+assert bytearray(b"<%a>") % b"\t\x80" == bytearray(b"")
+assert repr(b"\xe9") == "b'\\xe9'"
+assert bytearray(b"<%a>") % b"\xe9" == bytearray(b"")
+assert bytearray(b"<%a>") % "foo" == bytearray(b"<'foo'>")
+assert bytearray(b"<%a>") % "\u1234" == bytearray(b"<'\\u1234'>")
+
+def test_bytearray_not_modified(self):
+b1 = bytearray(b"<%a>")
+b2 = b1 % b"test"
+assert b1 == bytearray(b"<%a>")
+assert b2 == bytearray(b"")
+
+def test_r_compat_bytes(self):
+assert bytearray(b"<%r>") % b"test" == bytearray(b"")
+assert bytearray(b"<%r>") % b"\t\x80" == bytearray(b"")
+assert repr(b"\xe9") == "b'\\xe9'"
+assert bytearray(b"<%r>") % b"\xe9" == bytearray(b"")
+assert bytearray(b"<%r>") % "foo" == bytearray(b"<'foo'>")
+assert bytearray(b"<%r>") % "\u1234" == bytearray(b"<'\\u1234'>")
+
+def test_numeric_bytes(self):
+assert bytearray(b"<%4x>") % 10 == bytearray(b"<   a>")
+assert bytearray(b"<%#4x>") % 10 == bytearray(b"< 0xa>")
+assert bytearray(b"<%04X>") % 10 == bytearray(b"<000A>")
+
+def test_char_bytes(self):
+assert bytearray(b"<%c>") % 48 == bytearray(b"<0>")
+assert bytearray(b"<%c>") % b"?" == bytearray(b"")
+raises(TypeError, 'bytearray(b"<%c>") % "?"')
+
+def test_bytes_bytes(self):
+assert bytearray(b"<%b>") % b"123" == bytearray(b"<123>")
+class Foo:
+def __bytes__(self):
+return b"123"
+assert bytearray(b"<%b>") % Foo() == bytearray(b"<123>")
+raises(TypeError, 'bytearray(b"<%b>") % 42')
+raises(TypeError, 'bytearray(b"<%b>") % "?"')
+
+def test_s_compat_bytes(self):
+assert bytearray(b"<%s>") % b"123" == bytearray(b"<123>")
+class Foo:
+def __bytes__(self):
+return b"123"
+assert bytearray(b"<%s>") % Foo() == bytearray(b"<123>")
+raises(TypeError, 'bytearray(b"<%s>") % 42')
+raises(TypeError, 'bytearray(b"<%s>") % "?"')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Tweak the tests until they pass -A

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r88281:6c7cc24525c5
Date: 2016-11-09 17:51 +0100
http://bitbucket.org/pypy/pypy/changeset/6c7cc24525c5/

Log:Tweak the tests until they pass -A

diff --git a/pypy/objspace/std/test/test_stringformat.py 
b/pypy/objspace/std/test/test_stringformat.py
--- a/pypy/objspace/std/test/test_stringformat.py
+++ b/pypy/objspace/std/test/test_stringformat.py
@@ -80,7 +80,7 @@
 def test_format_float(self):
 f = 23.456
 assert '23' == '%d' % f
-assert '17' == '%x' % f
+raises(TypeError, "'%x' % f")
 assert '23.456' == '%s' % f
 # for 'r' use a float that has an exact decimal rep:
 g = 23.125
@@ -175,29 +175,31 @@
 raises(TypeError, '%c'.__mod__, ("",))
 raises(TypeError, '%c'.__mod__, (['c'],))
 
-def test___int__(self):
+def test___int__index__(self):
 class MyInt(object):
 def __init__(self, x):
 self.x = x
 def __int__(self):
 return self.x
-x = MyInt(65)
-assert '%c' % x == 'A'
+x = MyInt(33)
+raises(TypeError, "'%c' % x")
+MyInt.__index__ = lambda self: self.x * 2
+assert '%c' % x == 'B'
 
-def test_int_fails(self):
-class IntFails(object):
-def __int__(self):
+def test_index_fails(self):
+class IndexFails(object):
+def __index__(self):
 raise Exception
 
-exc = raises(TypeError, "%x".__mod__, IntFails())
-expected = "%x format: a number is required, not IntFails"
+exc = raises(TypeError, "%x".__mod__, IndexFails())
+expected = "%x format: an integer is required, not IndexFails"
 assert str(exc.value) == expected
 
 def test_formatting_huge_precision(self):
 prec = 2**31
 format_string = "%.{}f".format(prec)
 exc = raises(ValueError, "format_string % 2.34")
-assert str(exc.value) == 'prec too big'
+assert str(exc.value) == 'precision too big'
 raises(OverflowError, lambda: u'%.*f' % (prec, 1. / 7))
 
 def test_formatting_huge_width(self):
@@ -317,7 +319,7 @@
 prec = 2**31
 format_string = u"%.{}f".format(prec)
 exc = raises(ValueError, "format_string % 2.34")
-assert str(exc.value) == 'prec too big'
+assert str(exc.value) == 'precision too big'
 raises(OverflowError, lambda: u'%.*f' % (prec, 1. / 7))
 
 def test_formatting_huge_width(self):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Small tweaks until the tests pass on pypy too

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r88282:254669bd5f21
Date: 2016-11-09 18:10 +0100
http://bitbucket.org/pypy/pypy/changeset/254669bd5f21/

Log:Small tweaks until the tests pass on pypy too

diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -213,7 +213,7 @@
 
 if self.peekchr() == '.':
 self.forward()
-self.prec = self.peel_num('prec', INT_MAX)
+self.prec = self.peel_num('precision', INT_MAX)
 if self.prec < 0:
 self.prec = 0# this can happen:  '%.*f' % (-5, 3)
 else:
@@ -259,7 +259,7 @@
 w_value = self.nextinputvalue()
 if name == 'width':
 return space.int_w(w_value)
-elif name == 'prec':
+elif name == 'precision':
 return space.c_int_w(w_value)
 else:
 assert False
@@ -460,18 +460,12 @@
 def fmt_c(self, w_value):
 self.prec = -1 # just because
 space = self.space
-if space.isinstance_w(w_value, space.w_str):
-s = space.str_w(w_value)
-if len(s) != 1:
-raise oefmt(space.w_TypeError, "%c requires int or char")
-self.std_wp(s)
-elif space.isinstance_w(w_value, space.w_unicode):
-if not do_unicode:
-raise NeedUnicodeFormattingError
-ustr = space.unicode_w(w_value)
-if len(ustr) != 1:
-raise oefmt(space.w_TypeError, "%c requires int or 
unichar")
-self.std_wp(ustr)
+try:
+w_value = space.index(w_value)
+except OperationError as e:
+if e.async(space):
+raise
+# otherwise, eats all exceptions, like CPython
 else:
 n = space.int_w(w_value)
 if do_unicode:
@@ -488,6 +482,23 @@
 raise oefmt(space.w_OverflowError,
 "character code not in range(256)")
 self.std_wp(s)
+return
+if space.isinstance_w(w_value, space.w_str):
+s = space.str_w(w_value)
+if len(s) == 1:
+self.std_wp(s)
+return
+elif space.isinstance_w(w_value, space.w_unicode):
+if not do_unicode:
+raise NeedUnicodeFormattingError
+ustr = space.unicode_w(w_value)
+if len(ustr) == 1:
+self.std_wp(ustr)
+return
+if do_unicode:
+raise oefmt(space.w_TypeError, "%c requires int or char")
+else:
+raise oefmt(space.w_TypeError, "%c requires int or single 
byte")
 
 def fmt_b(self, w_value):
 space = self.space
@@ -581,18 +592,22 @@
 # make sure that w_value is a wrapped integer
 return space.int(w_value)
 
+def maybe_index(space, w_value):
+return space.index(w_value)
+
 def maybe_float(space, w_value):
 # make sure that w_value is a wrapped float
 return space.float(w_value)
 
-def format_num_helper_generator(fmt, digits):
+def format_num_helper_generator(fmt, digits, decoder=maybe_int,
+expect_text="a number"):
 def format_num_helper(space, w_value):
 try:
-w_value = maybe_int(space, w_value)
+w_value = decoder(space, w_value)
 except OperationError:
 raise oefmt(space.w_TypeError,
-"%s format: a number is required, not %T",
-fmt, w_value)
+"%s format: %s is required, not %T",
+fmt, expect_text, w_value)
 try:
 value = space.int_w(w_value)
 return fmt % (value,)
@@ -605,5 +620,7 @@
   'base%d_num_helper' % len(digits))
 
 int_num_helper = format_num_helper_generator('%d', '0123456789')
-oct_num_helper = format_num_helper_generator('%o', '01234567')
-hex_num_helper = format_num_helper_generator('%x', '0123456789abcdef')
+oct_num_helper = format_num_helper_generator('%o', '01234567',
+ decoder=maybe_index, expect_text="an integer")
+hex_num_helper = format_num_helper_generator('%x', '0123456789abcdef',
+ decoder=maybe_index, expect_text="an integer")
diff --git a/pypy/objspace/std/test/test_stringformat.py 
b/pypy/objspace/std/test/test_stringformat.py
--- a/pypy/objspace/std/test/test_stringformat.py
+++ b/pypy/objspace/std/test/test_stringformat.py
@@ -78,10 +78,14 @@
 raises(TypeError, '%d'.__mod__, s)
 
 def test_format_float(self):
-f = 23.456

[pypy-commit] extradoc extradoc: PEP 461 Done

2016-11-09 Thread arigo
Author: Armin Rigo 
Branch: extradoc
Changeset: r5746:a5c3f0331c0e
Date: 2016-11-09 18:11 +0100
http://bitbucket.org/pypy/extradoc/changeset/a5c3f0331c0e/

Log:PEP 461 Done

diff --git a/planning/py3.5/milestone-1-progress.rst 
b/planning/py3.5/milestone-1-progress.rst
--- a/planning/py3.5/milestone-1-progress.rst
+++ b/planning/py3.5/milestone-1-progress.rst
@@ -5,7 +5,7 @@
 In-progress ("Lock" section)
 
 
-* bytes % args, bytearray % args (arigo)
+(empty)
 
 
 Misc stuff not formally in any milestone
@@ -57,7 +57,7 @@
 
 * PEP 448, additional unpacking generalizations.
 
-* bytes % args, bytearray % args: PEP 461
+* bytes % args, bytearray % args: PEP 461 (DONE)
 
 * New bytes.hex(), bytearray.hex() and memoryview.hex() methods. (DONE)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Disable SSL part of the test for now (times out)

2016-11-09 Thread rlamy
Author: Ronan Lamy 
Branch: py3.5
Changeset: r88283:d267f0decb98
Date: 2016-11-09 18:16 +
http://bitbucket.org/pypy/pypy/changeset/d267f0decb98/

Log:Disable SSL part of the test for now (times out)

diff --git a/lib-python/3/test/test_logging.py 
b/lib-python/3/test/test_logging.py
--- a/lib-python/3/test/test_logging.py
+++ b/lib-python/3/test/test_logging.py
@@ -1665,7 +1665,7 @@
 logger = logging.getLogger("http")
 root_logger = self.root_logger
 root_logger.removeHandler(self.root_logger.handlers[0])
-for secure in (False, True):
+for secure in (False,):  # XXX: disable SSL tests until it works
 addr = ('localhost', 0)
 if secure:
 try:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: add paragraph to release notes (vecopt)

2016-11-09 Thread plan_rich
Author: Richard Plangger 
Branch: 
Changeset: r88284:16700fced491
Date: 2016-11-10 08:54 +0100
http://bitbucket.org/pypy/pypy/changeset/16700fced491/

Log:add paragraph to release notes (vecopt)

diff --git a/pypy/doc/release-pypy2.7-v5.6.0.rst 
b/pypy/doc/release-pypy2.7-v5.6.0.rst
--- a/pypy/doc/release-pypy2.7-v5.6.0.rst
+++ b/pypy/doc/release-pypy2.7-v5.6.0.rst
@@ -11,7 +11,10 @@
 
 Work proceeds at a good pace on the PyPy3.5
 version due to a grant_ from the Mozilla Foundation, and some of those
-changes have been backported to PyPy2.7 where relevant
+changes have been backported to PyPy2.7 where relevant.
+
+The PowerPC and s390x backend have been enhanced_ with the capability use SIMD 
instructions
+ for micronumpy loops.
 
 We changed ``timeit`` to now report average +- standard deviation, which is
 better than the misleading minimum value reported in CPython.
@@ -45,6 +48,7 @@
 .. _`RPython`: https://rpython.readthedocs.org
 .. _`modules`: 
http://doc.pypy.org/en/latest/project-ideas.html#make-more-python-modules-pypy-friendly
 .. _`help`: http://doc.pypy.org/en/latest/project-ideas.html
+.. _`enhanced`: 
https://morepypy.blogspot.co.at/2016/11/vectorization-extended-powerpc-and-s390x.html
 
 What is PyPy?
 =
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit