[pypy-commit] pypy gc_no_cleanup_nursery: more fixes

2014-09-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: gc_no_cleanup_nursery
Changeset: r73624:ef9f7e3dc9fa
Date: 2014-09-21 09:07 +0200
http://bitbucket.org/pypy/pypy/changeset/ef9f7e3dc9fa/

Log:more fixes

diff --git a/rpython/jit/backend/llsupport/llmodel.py 
b/rpython/jit/backend/llsupport/llmodel.py
--- a/rpython/jit/backend/llsupport/llmodel.py
+++ b/rpython/jit/backend/llsupport/llmodel.py
@@ -14,6 +14,7 @@
 get_call_descr, get_interiorfield_descr,
 FieldDescr, ArrayDescr, CallDescr, InteriorFieldDescr,
 FLAG_POINTER, FLAG_FLOAT)
+from rpython.jit.backend.llsupport.memcpy import memset_fn
 from rpython.jit.backend.llsupport.asmmemmgr import AsmMemoryManager
 from rpython.rlib.unroll import unrolling_iterable
 
@@ -596,8 +597,8 @@
 arraysize = self.bh_arraylen_gc(ref, arraydescr)
 totalsize = size * arraysize
 adr = rffi.cast(lltype.Signed, ref) + ofs
-self.gc_ll_descr.memset_ptr(adr, rffi.cast(rffi.INT, 0),
-rffi.cast(rffi.SIZE_T, totalsize))
+memset_fn(rffi.cast(llmemory.Address, adr), rffi.cast(rffi.INT, 0),
+  rffi.cast(rffi.SIZE_T, totalsize))
 
 def bh_new_with_vtable(self, vtable, sizedescr):
 res = self.gc_ll_descr.gc_malloc(sizedescr)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy gc_no_cleanup_nursery: fix rpython

2014-09-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: gc_no_cleanup_nursery
Changeset: r73623:95eb1ca371e7
Date: 2014-09-21 08:53 +0200
http://bitbucket.org/pypy/pypy/changeset/95eb1ca371e7/

Log:fix rpython

diff --git a/rpython/jit/backend/llsupport/rewrite.py 
b/rpython/jit/backend/llsupport/rewrite.py
--- a/rpython/jit/backend/llsupport/rewrite.py
+++ b/rpython/jit/backend/llsupport/rewrite.py
@@ -137,7 +137,7 @@
 d[ofs] = None
 
 def consider_setfield_gc(self, op):
-offset = op.getdescr().offset
+offset = self.cpu.unpack_fielddescr(op.getdescr())
 try:
 del self.delayed_zero_setfields[op.getarg(0)][offset]
 except KeyError:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy gc-incminimark-pinning: Merge default into gc-incminimark-pinning

2014-09-21 Thread groggi
Author: Gregor Wegberg 
Branch: gc-incminimark-pinning
Changeset: r73626:1bc63cf2b16c
Date: 2014-09-21 10:08 +0200
http://bitbucket.org/pypy/pypy/changeset/1bc63cf2b16c/

Log:Merge default into gc-incminimark-pinning

diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py
--- a/lib_pypy/_curses.py
+++ b/lib_pypy/_curses.py
@@ -286,6 +286,13 @@
 
 
 lib = ffi.verify("""
+#ifdef __APPLE__
+/* the following define is necessary for OS X 10.6+; without it, the
+   Apple-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python
+   can't get at the WINDOW flags field. */
+#define NCURSES_OPAQUE 0
+#endif
+
 #include 
 #include 
 #include 
diff --git a/pypy/doc/release-2.4.0.rst b/pypy/doc/release-2.4.0.rst
--- a/pypy/doc/release-2.4.0.rst
+++ b/pypy/doc/release-2.4.0.rst
@@ -5,7 +5,7 @@
 We're pleased to announce PyPy 2.4, which contains significant performance
 enhancements and bug fixes. 
 
-You can already download the PyPy 2.4-beta1 pre-release here:
+You can download the PyPy 2.4.0 release here:
 
 http://pypy.org/download.html
 
@@ -63,6 +63,8 @@
 
 PyPy now uses Python 2.7.8 standard library.
 
+We fixed a memory leak in IO in the sandbox_ code
+
 We welcomed more than 12 new contributors, and conducted two Google
 Summer of Code projects, as well as other student projects not
 directly related to Summer of Code.
@@ -105,6 +107,7 @@
 
 .. _`whats-new`: http://doc.pypy.org/en/latest/whatsnew-2.3.1.html
 .. _resolved: https://bitbucket.org/pypy/pypy/issues?status=resolved
+.. _sandbox: http://doc.pypy.org/en/latest/sandbox.html   
 
 We have further improvements on the way: rpython file handling,
 numpy linalg compatibility, as well
diff --git a/pypy/module/test_lib_pypy/cffi_tests/test_zdistutils.py 
b/pypy/module/test_lib_pypy/cffi_tests/test_zdistutils.py
--- a/pypy/module/test_lib_pypy/cffi_tests/test_zdistutils.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/test_zdistutils.py
@@ -16,6 +16,10 @@
 if distutils.ccompiler.get_default_compiler() == 'msvc':
 self.lib_m = 'msvcrt'
 
+def teardown_class(self):
+if udir.isdir():
+udir.remove()
+
 def test_locate_engine_class(self):
 cls = _locate_engine_class(FFI(), self.generic)
 if self.generic:
diff --git a/pypy/module/test_lib_pypy/cffi_tests/test_zintegration.py 
b/pypy/module/test_lib_pypy/cffi_tests/test_zintegration.py
--- a/pypy/module/test_lib_pypy/cffi_tests/test_zintegration.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/test_zintegration.py
@@ -73,50 +73,55 @@
 assert not os.path.exists(str(SNIPPET_DIR.join(dirname, 'lextab.py')))
 assert not os.path.exists(str(SNIPPET_DIR.join(dirname, 'yacctab.py')))
 
-def test_infrastructure():
-run_setup_and_program('infrastructure', '''
-import snip_infrastructure
-assert snip_infrastructure.func() == 42
-''')
+class TestZIntegration(object):
+def teardown_class(self):
+if udir.isdir():
+udir.remove()
 
-def test_distutils_module():
-run_setup_and_program("distutils_module", '''
-import snip_basic_verify
-p = snip_basic_verify.C.getpwuid(0)
-assert snip_basic_verify.ffi.string(p.pw_name) == b"root"
-''')
+def test_infrastructure(self):
+run_setup_and_program('infrastructure', '''
+import snip_infrastructure
+assert snip_infrastructure.func() == 42
+''')
 
-def test_distutils_package_1():
-run_setup_and_program("distutils_package_1", '''
-import snip_basic_verify1
-p = snip_basic_verify1.C.getpwuid(0)
-assert snip_basic_verify1.ffi.string(p.pw_name) == b"root"
-''')
+def test_distutils_module(self):
+run_setup_and_program("distutils_module", '''
+import snip_basic_verify
+p = snip_basic_verify.C.getpwuid(0)
+assert snip_basic_verify.ffi.string(p.pw_name) == b"root"
+''')
 
-def test_distutils_package_2():
-run_setup_and_program("distutils_package_2", '''
-import snip_basic_verify2
-p = snip_basic_verify2.C.getpwuid(0)
-assert snip_basic_verify2.ffi.string(p.pw_name) == b"root"
-''')
+def test_distutils_package_1(self):
+run_setup_and_program("distutils_package_1", '''
+import snip_basic_verify1
+p = snip_basic_verify1.C.getpwuid(0)
+assert snip_basic_verify1.ffi.string(p.pw_name) == b"root"
+''')
 
-def test_setuptools_module():
-run_setup_and_program("setuptools_module", '''
-import snip_setuptools_verify
-p = snip_setuptools_verify.C.getpwuid(0)
-assert snip_setuptools_verify.ffi.string(p.pw_name) == b"root"
-''')
+def test_distutils_package_2(self):
+run_setup_and_program("distutils_package_2", '''
+import snip_basic_verify2
+p = snip_basic_verify2.C.getpwuid(0)
+assert snip_basic_verify2.ffi.string(p.pw_name) == b"root"
+''')
 
-def test_setuptools_package_1():
-run_setup_and_program("setuptools_package_1", '''
-import snip_setu

[pypy-commit] pypy gc-incminimark-pinning: Merge default into gc-incminimark-pinning

2014-09-21 Thread groggi
Author: Gregor Wegberg 
Branch: gc-incminimark-pinning
Changeset: r73625:55c211d937b2
Date: 2014-09-21 10:08 +0200
http://bitbucket.org/pypy/pypy/changeset/55c211d937b2/

Log:Merge default into gc-incminimark-pinning

diff too long, truncating to 2000 out of 5185 lines

diff --git a/_pytest/README-BEFORE-UPDATING b/_pytest/README-BEFORE-UPDATING
new file mode 100644
--- /dev/null
+++ b/_pytest/README-BEFORE-UPDATING
@@ -0,0 +1,17 @@
+This is PyPy's code of the pytest lib.  We don't expect to upgrade it
+very often, but once we do:
+
+WARNING!
+
+WE HAVE MADE A FEW TWEAKS HERE!
+
+Please be sure that you don't just copy the newer version from
+upstream without checking the few changes that we did.  This
+can be done like this:
+
+cd 
+hg log . -v | less
+
+then search for all " _pytest/" in that list to know which are the
+relevant checkins.  (Look for the checkins that only edit one
+or two files in this directory.)
diff --git a/_pytest/resultlog.py b/_pytest/resultlog.py
--- a/_pytest/resultlog.py
+++ b/_pytest/resultlog.py
@@ -53,16 +53,24 @@
 self.config = config
 self.logfile = logfile # preferably line buffered
 
-def write_log_entry(self, testpath, lettercode, longrepr):
-py.builtin.print_("%s %s" % (lettercode, testpath), file=self.logfile)
+def write_log_entry(self, testpath, lettercode, longrepr, sections=None):
+_safeprint("%s %s" % (lettercode, testpath), file=self.logfile)
 for line in longrepr.splitlines():
-py.builtin.print_(" %s" % line, file=self.logfile)
+_safeprint(" %s" % line, file=self.logfile)
+if sections is not None and (
+lettercode in ('E', 'F')):# to limit the size of logs
+for title, content in sections:
+_safeprint(" -- %s --" % (title,),
+   file=self.logfile)
+for line in content.splitlines():
+_safeprint(" %s" % line, file=self.logfile)
 
 def log_outcome(self, report, lettercode, longrepr):
 testpath = getattr(report, 'nodeid', None)
 if testpath is None:
 testpath = report.fspath
-self.write_log_entry(testpath, lettercode, longrepr)
+self.write_log_entry(testpath, lettercode, longrepr,
+ getattr(report, 'sections', None))
 
 def pytest_runtest_logreport(self, report):
 if report.when != "call" and report.passed:
@@ -98,3 +106,8 @@
 if path is None:
 path = "cwd:%s" % py.path.local()
 self.write_log_entry(path, '!', str(excrepr))
+
+def _safeprint(s, file):
+if isinstance(s, unicode):
+s = s.encode('utf-8')
+py.builtin.print_(s, file=file)
diff --git a/lib-python/2.7/test/test_mmap.py b/lib-python/2.7/test/test_mmap.py
--- a/lib-python/2.7/test/test_mmap.py
+++ b/lib-python/2.7/test/test_mmap.py
@@ -179,25 +179,27 @@
 import sys
 f = open(TESTFN, "r+b")
 try:
-m = mmap.mmap(f.fileno(), mapsize+1)
-except ValueError:
-# we do not expect a ValueError on Windows
-# CAUTION:  This also changes the size of the file on disk, and
-# later tests assume that the length hasn't changed.  We need to
-# repair that.
+try:
+m = mmap.mmap(f.fileno(), mapsize+1)
+except ValueError:
+# we do not expect a ValueError on Windows
+# CAUTION:  This also changes the size of the file on disk, and
+# later tests assume that the length hasn't changed.  We need 
to
+# repair that.
+if sys.platform.startswith('win'):
+self.fail("Opening mmap with size+1 should work on 
Windows.")
+else:
+# we expect a ValueError on Unix, but not on Windows
+if not sys.platform.startswith('win'):
+self.fail("Opening mmap with size+1 should raise 
ValueError.")
+m.close()
+finally:
+f.close()
 if sys.platform.startswith('win'):
-self.fail("Opening mmap with size+1 should work on Windows.")
-else:
-# we expect a ValueError on Unix, but not on Windows
-if not sys.platform.startswith('win'):
-self.fail("Opening mmap with size+1 should raise ValueError.")
-m.close()
-f.close()
-if sys.platform.startswith('win'):
-# Repair damage from the resizing test.
-f = open(TESTFN, 'r+b')
-f.truncate(mapsize)
-f.close()
+# Repair damage from the resizing test.
+f = open(TESTFN, 'r+b')
+f.truncate(mapsize)
+f.close()
 
 # Opening mmap with access=ACCESS_WRITE
 f = open(TESTFN, "r+b")
diff --git a/py/README-BEFORE-UPDATING b/py/README-

[pypy-commit] pypy default: a big oops

2014-09-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r73627:7255c146c5f2
Date: 2014-09-21 10:09 +0200
http://bitbucket.org/pypy/pypy/changeset/7255c146c5f2/

Log:a big oops

diff --git a/rpython/tool/jitlogparser/parser.py 
b/rpython/tool/jitlogparser/parser.py
--- a/rpython/tool/jitlogparser/parser.py
+++ b/rpython/tool/jitlogparser/parser.py
@@ -406,9 +406,9 @@
 loops = []
 cat = extract_category(log, 'jit-log-opt')
 if not cat:
-extract_category(log, 'jit-log-rewritten')
+cat = extract_category(log, 'jit-log-rewritten')
 if not cat:
-extract_category(log, 'jit-log-noopt')
+cat = extract_category(log, 'jit-log-noopt')
 for entry in cat:
 parser = ParserCls(entry, None, {}, 'lltype', None,
nonstrict=True)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy gc_no_cleanup_nursery: small improvements

2014-09-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: gc_no_cleanup_nursery
Changeset: r73629:4739b87c13c1
Date: 2014-09-21 10:17 +0200
http://bitbucket.org/pypy/pypy/changeset/4739b87c13c1/

Log:small improvements

diff --git a/rpython/jit/backend/llsupport/rewrite.py 
b/rpython/jit/backend/llsupport/rewrite.py
--- a/rpython/jit/backend/llsupport/rewrite.py
+++ b/rpython/jit/backend/llsupport/rewrite.py
@@ -46,6 +46,7 @@
 self.known_lengths = {}
 self.write_barrier_applied = {}
 self.delayed_zero_setfields = {}
+self.delayed_zero_setarrayitems = {}
 
 def rewrite(self, operations):
 # we can only remember one malloc since the next malloc can possibly
@@ -135,6 +136,7 @@
 self.delayed_zero_setfields[result] = d
 for ofs in descr.offsets_of_gcfields:
 d[ofs] = None
+self.delayed_zero_setfields.clear()
 
 def consider_setfield_gc(self, op):
 offset = self.cpu.unpack_fielddescr(op.getdescr())
diff --git a/rpython/tool/jitlogparser/parser.py 
b/rpython/tool/jitlogparser/parser.py
--- a/rpython/tool/jitlogparser/parser.py
+++ b/rpython/tool/jitlogparser/parser.py
@@ -406,9 +406,9 @@
 loops = []
 cat = extract_category(log, 'jit-log-opt')
 if not cat:
-extract_category(log, 'jit-log-rewritten')
+cat = extract_category(log, 'jit-log-rewritten')
 if not cat:
-extract_category(log, 'jit-log-noopt')
+cat = extract_category(log, 'jit-log-noopt')
 for entry in cat:
 parser = ParserCls(entry, None, {}, 'lltype', None,
nonstrict=True)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge

2014-09-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r73628:b6c3792d707a
Date: 2014-09-21 10:09 +0200
http://bitbucket.org/pypy/pypy/changeset/b6c3792d707a/

Log:merge

diff --git a/rpython/rtyper/lltypesystem/lltype.py 
b/rpython/rtyper/lltypesystem/lltype.py
--- a/rpython/rtyper/lltypesystem/lltype.py
+++ b/rpython/rtyper/lltypesystem/lltype.py
@@ -1,16 +1,17 @@
-from types import NoneType, MethodType
 import weakref
+from types import MethodType, NoneType
+
+from rpython.annotator.bookkeeper import analyzer_for, immutablevalue
 from rpython.annotator.model import (
-SomeInteger, SomeBool, SomeObject, AnnotatorError)
+AnnotatorError, SomeBool, SomeInteger, SomeObject)
+from rpython.rlib.objectmodel import Symbolic
 from rpython.rlib.rarithmetic import (
-r_int, r_uint, intmask, r_singlefloat, r_ulonglong, r_longlong,
-r_longfloat, r_longlonglong, base_int, normalizedinttype, longlongmask,
-longlonglongmask, maxint, is_valid_int, is_emulated_long)
-from rpython.rlib.objectmodel import Symbolic
+base_int, intmask, is_emulated_long, is_valid_int, longlonglongmask,
+longlongmask, maxint, normalizedinttype, r_int, r_longfloat, r_longlong,
+r_longlonglong, r_singlefloat, r_uint, r_ulonglong)
+from rpython.rtyper.extregistry import ExtRegistryEntry
+from rpython.tool import leakfinder
 from rpython.tool.identity_dict import identity_dict
-from rpython.tool import leakfinder
-from rpython.annotator.bookkeeper import analyzer_for, immutablevalue
-from rpython.rtyper.extregistry import ExtRegistryEntry
 
 class State(object):
 pass
@@ -313,14 +314,12 @@
 except KeyError:
 return ContainerType.__getattr__(self, name)
 
-
 def _nofield(self, name):
 raise AttributeError('struct %s has no field %r' % (self._name,
  name))
 
 def _names_without_voids(self):
-names_without_voids = [name for name in self._names if 
self._flds[name] is not Void]
-return names_without_voids
+return [name for name in self._names if self._flds[name] is not Void]
 
 def _str_fields_without_voids(self):
 return ', '.join(['%s: %s' % (name, self._flds[name])
@@ -576,8 +575,10 @@
 _gckind = 'raw'
 
 def __init__(self, tag, hints={}):
-""" if hints['render_structure'] is set, the type is internal and not 
considered
-to come from somewhere else (it should be rendered as a structure) 
"""
+"""If hints['render_structure'] is set, the type is internal and
+not considered to come from somewhere else (it should be
+rendered as a structure)
+"""
 self.tag = tag
 self.__name__ = tag
 self.hints = frozendict(hints)
@@ -675,7 +676,8 @@
 
 _numbertypes = {int: Number("Signed", int, intmask)}
 _numbertypes[r_int] = _numbertypes[int]
-_numbertypes[r_longlonglong] = Number("SignedLongLongLong", r_longlonglong, 
longlonglongmask)
+_numbertypes[r_longlonglong] = Number("SignedLongLongLong", r_longlonglong,
+  longlonglongmask)
 if r_longlong is not r_int:
 _numbertypes[r_longlong] = Number("SignedLongLong", r_longlong,
   longlongmask)
@@ -702,8 +704,8 @@
 UnsignedLongLong = build_number("UnsignedLongLong", r_ulonglong)
 
 Float   = Primitive("Float",   0.0)  # C type 'double'
-SingleFloat = Primitive("SingleFloat", r_singlefloat(0.0))   # C type 'float'
-LongFloat   = Primitive("LongFloat",   r_longfloat(0.0)) # C type 'long 
double'
+SingleFloat = Primitive("SingleFloat", r_singlefloat(0.0))   # 'float'
+LongFloat   = Primitive("LongFloat",   r_longfloat(0.0)) # 'long double'
 r_singlefloat._TYPE = SingleFloat
 
 Char = Primitive("Char", '\x00')
@@ -876,9 +878,11 @@
 
 @analyzer_for(cast_primitive)
 def ann_cast_primitive(T, s_v):
-from rpython.rtyper.llannotation import annotation_to_lltype, 
ll_to_annotation
+from rpython.rtyper.llannotation import (
+annotation_to_lltype, ll_to_annotation)
 assert T.is_constant()
-return ll_to_annotation(cast_primitive(T.const, 
annotation_to_lltype(s_v)._defl()))
+return ll_to_annotation(cast_primitive(T.const,
+   annotation_to_lltype(s_v)._defl()))
 
 
 def _cast_whatever(TGT, value):
@@ -905,7 +909,8 @@
 elif TGT == llmemory.Address and isinstance(ORIG, Ptr):
 return llmemory.cast_ptr_to_adr(value)
 elif TGT == Signed and isinstance(ORIG, Ptr) and ORIG.TO._gckind == 'raw':
-return llmemory.cast_adr_to_int(llmemory.cast_ptr_to_adr(value), 
'symbolic')
+return llmemory.cast_adr_to_int(llmemory.cast_ptr_to_adr(value),
+'symbolic')
 raise TypeError("don't know how to cast from %r to %r" % (ORIG, TGT))
 
 
@@ -1176,8 +1181,8 @@
 except DelayedPointer:
 return True# assume it's not a delayed nul

[pypy-commit] pypy default: merge

2014-09-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r73630:d020fd66e8e2
Date: 2014-09-21 10:18 +0200
http://bitbucket.org/pypy/pypy/changeset/d020fd66e8e2/

Log:merge

diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py
--- a/lib_pypy/_curses.py
+++ b/lib_pypy/_curses.py
@@ -286,6 +286,13 @@
 
 
 lib = ffi.verify("""
+#ifdef __APPLE__
+/* the following define is necessary for OS X 10.6+; without it, the
+   Apple-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python
+   can't get at the WINDOW flags field. */
+#define NCURSES_OPAQUE 0
+#endif
+
 #include 
 #include 
 #include 
diff --git a/pypy/doc/release-2.4.0.rst b/pypy/doc/release-2.4.0.rst
--- a/pypy/doc/release-2.4.0.rst
+++ b/pypy/doc/release-2.4.0.rst
@@ -5,7 +5,7 @@
 We're pleased to announce PyPy 2.4, which contains significant performance
 enhancements and bug fixes. 
 
-You can already download the PyPy 2.4-beta1 pre-release here:
+You can download the PyPy 2.4.0 release here:
 
 http://pypy.org/download.html
 
@@ -63,6 +63,8 @@
 
 PyPy now uses Python 2.7.8 standard library.
 
+We fixed a memory leak in IO in the sandbox_ code
+
 We welcomed more than 12 new contributors, and conducted two Google
 Summer of Code projects, as well as other student projects not
 directly related to Summer of Code.
@@ -105,6 +107,7 @@
 
 .. _`whats-new`: http://doc.pypy.org/en/latest/whatsnew-2.3.1.html
 .. _resolved: https://bitbucket.org/pypy/pypy/issues?status=resolved
+.. _sandbox: http://doc.pypy.org/en/latest/sandbox.html   
 
 We have further improvements on the way: rpython file handling,
 numpy linalg compatibility, as well
diff --git a/pypy/module/test_lib_pypy/cffi_tests/test_zdistutils.py 
b/pypy/module/test_lib_pypy/cffi_tests/test_zdistutils.py
--- a/pypy/module/test_lib_pypy/cffi_tests/test_zdistutils.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/test_zdistutils.py
@@ -16,6 +16,10 @@
 if distutils.ccompiler.get_default_compiler() == 'msvc':
 self.lib_m = 'msvcrt'
 
+def teardown_class(self):
+if udir.isdir():
+udir.remove()
+
 def test_locate_engine_class(self):
 cls = _locate_engine_class(FFI(), self.generic)
 if self.generic:
diff --git a/pypy/module/test_lib_pypy/cffi_tests/test_zintegration.py 
b/pypy/module/test_lib_pypy/cffi_tests/test_zintegration.py
--- a/pypy/module/test_lib_pypy/cffi_tests/test_zintegration.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/test_zintegration.py
@@ -73,50 +73,55 @@
 assert not os.path.exists(str(SNIPPET_DIR.join(dirname, 'lextab.py')))
 assert not os.path.exists(str(SNIPPET_DIR.join(dirname, 'yacctab.py')))
 
-def test_infrastructure():
-run_setup_and_program('infrastructure', '''
-import snip_infrastructure
-assert snip_infrastructure.func() == 42
-''')
+class TestZIntegration(object):
+def teardown_class(self):
+if udir.isdir():
+udir.remove()
 
-def test_distutils_module():
-run_setup_and_program("distutils_module", '''
-import snip_basic_verify
-p = snip_basic_verify.C.getpwuid(0)
-assert snip_basic_verify.ffi.string(p.pw_name) == b"root"
-''')
+def test_infrastructure(self):
+run_setup_and_program('infrastructure', '''
+import snip_infrastructure
+assert snip_infrastructure.func() == 42
+''')
 
-def test_distutils_package_1():
-run_setup_and_program("distutils_package_1", '''
-import snip_basic_verify1
-p = snip_basic_verify1.C.getpwuid(0)
-assert snip_basic_verify1.ffi.string(p.pw_name) == b"root"
-''')
+def test_distutils_module(self):
+run_setup_and_program("distutils_module", '''
+import snip_basic_verify
+p = snip_basic_verify.C.getpwuid(0)
+assert snip_basic_verify.ffi.string(p.pw_name) == b"root"
+''')
 
-def test_distutils_package_2():
-run_setup_and_program("distutils_package_2", '''
-import snip_basic_verify2
-p = snip_basic_verify2.C.getpwuid(0)
-assert snip_basic_verify2.ffi.string(p.pw_name) == b"root"
-''')
+def test_distutils_package_1(self):
+run_setup_and_program("distutils_package_1", '''
+import snip_basic_verify1
+p = snip_basic_verify1.C.getpwuid(0)
+assert snip_basic_verify1.ffi.string(p.pw_name) == b"root"
+''')
 
-def test_setuptools_module():
-run_setup_and_program("setuptools_module", '''
-import snip_setuptools_verify
-p = snip_setuptools_verify.C.getpwuid(0)
-assert snip_setuptools_verify.ffi.string(p.pw_name) == b"root"
-''')
+def test_distutils_package_2(self):
+run_setup_and_program("distutils_package_2", '''
+import snip_basic_verify2
+p = snip_basic_verify2.C.getpwuid(0)
+assert snip_basic_verify2.ffi.string(p.pw_name) == b"root"
+''')
 
-def test_setuptools_package_1():
-run_setup_and_program("setuptools_package_1", '''
-import snip_setuptools_verify1
-p = snip_setuptools_verify1.C.getp

[pypy-commit] pypy gc_no_cleanup_nursery: optimize away the trivial case

2014-09-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: gc_no_cleanup_nursery
Changeset: r73631:539491bcd60f
Date: 2014-09-21 10:31 +0200
http://bitbucket.org/pypy/pypy/changeset/539491bcd60f/

Log:optimize away the trivial case

diff --git a/rpython/jit/backend/llsupport/rewrite.py 
b/rpython/jit/backend/llsupport/rewrite.py
--- a/rpython/jit/backend/llsupport/rewrite.py
+++ b/rpython/jit/backend/llsupport/rewrite.py
@@ -212,6 +212,8 @@
 o = ResOperation(rop.ARRAYLEN_GC, [v_arr], v_length,
  descr=arraydescr)
 self.newops.append(o)
+elif isinstance(v_length, ConstInt) and v_length.getint() == 0:
+return
 o = ResOperation(rop.ZERO_ARRAY, [v_arr, ConstInt(0), v_length], None,
  descr=arraydescr)
 self.newops.append(o)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy gc_no_cleanup_nursery: one more missing setfield for the asmgcc case

2014-09-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: gc_no_cleanup_nursery
Changeset: r73632:9189598fd962
Date: 2014-09-21 11:16 +0200
http://bitbucket.org/pypy/pypy/changeset/9189598fd962/

Log:one more missing setfield for the asmgcc case

diff --git a/rpython/jit/backend/llsupport/rewrite.py 
b/rpython/jit/backend/llsupport/rewrite.py
--- a/rpython/jit/backend/llsupport/rewrite.py
+++ b/rpython/jit/backend/llsupport/rewrite.py
@@ -241,6 +241,9 @@
length_box,
descr=descrs.jfi_frame_depth)
 self.newops.append(op1)
+op2 = ResOperation(rop.SETFIELD_GC, [frame, ConstInt(0)],
+   None, descr=descrs.jf_extra_stack_depth)
+self.newops.append(op2)
 self.gen_initialize_len(frame, length_box,
 descrs.arraydescr.lendescr)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy gc_no_cleanup_nursery: fixes

2014-09-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: gc_no_cleanup_nursery
Changeset: r73633:86b8d1f0b17d
Date: 2014-09-21 13:05 +0200
http://bitbucket.org/pypy/pypy/changeset/86b8d1f0b17d/

Log:fixes

diff --git a/rpython/jit/backend/llsupport/rewrite.py 
b/rpython/jit/backend/llsupport/rewrite.py
--- a/rpython/jit/backend/llsupport/rewrite.py
+++ b/rpython/jit/backend/llsupport/rewrite.py
@@ -62,6 +62,8 @@
 if op.is_malloc():
 self.handle_malloc_operation(op)
 continue
+if op.is_guard():
+self.emit_pending_zeros()
 elif op.getopnum() == rop.CLEAR_ARRAY_CONTENTS:
 self.handle_clear_array_contents(op.getdescr(), op.getarg(0))
 continue
@@ -136,7 +138,6 @@
 self.delayed_zero_setfields[result] = d
 for ofs in descr.offsets_of_gcfields:
 d[ofs] = None
-self.delayed_zero_setfields.clear()
 
 def consider_setfield_gc(self, op):
 offset = self.cpu.unpack_fielddescr(op.getdescr())
@@ -298,6 +299,7 @@
 for ofs in d.iterkeys():
 op = ResOperation(rop.ZERO_PTR_FIELD, [v, ConstInt(ofs)], None)
 self.newops.append(op)
+self.delayed_zero_setfields.clear()
 
 def _gen_call_malloc_gc(self, args, v_result, descr):
 """Generate a CALL_MALLOC_GC with the given args."""
diff --git a/rpython/jit/backend/llsupport/test/test_rewrite.py 
b/rpython/jit/backend/llsupport/test/test_rewrite.py
--- a/rpython/jit/backend/llsupport/test/test_rewrite.py
+++ b/rpython/jit/backend/llsupport/test/test_rewrite.py
@@ -122,6 +122,9 @@
 def unpack_arraydescr_size(self, d):
 return 0, d.itemsize, 0
 
+def unpack_fielddescr(self, d):
+return d.offset
+
 def arraydescrof(self, ARRAY):
 try:
 return self._cache[ARRAY]
diff --git a/rpython/jit/codewriter/heaptracker.py 
b/rpython/jit/codewriter/heaptracker.py
--- a/rpython/jit/codewriter/heaptracker.py
+++ b/rpython/jit/codewriter/heaptracker.py
@@ -140,6 +140,4 @@
 res.append(offset)
 elif isinstance(FIELD, lltype.Struct):
 offsets_of_gcfields(gccache, FIELD, res)
-if not gccache.translate_support_code:
-res.sort()
 return res
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy gc_no_cleanup_nursery: fix the test

2014-09-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: gc_no_cleanup_nursery
Changeset: r73634:3b1a1ae57720
Date: 2014-09-21 13:07 +0200
http://bitbucket.org/pypy/pypy/changeset/3b1a1ae57720/

Log:fix the test

diff --git a/rpython/jit/backend/llsupport/test/test_rewrite.py 
b/rpython/jit/backend/llsupport/test/test_rewrite.py
--- a/rpython/jit/backend/llsupport/test/test_rewrite.py
+++ b/rpython/jit/backend/llsupport/test/test_rewrite.py
@@ -82,6 +82,7 @@
 jfi_frame_depth = framedescrs.jfi_frame_depth
 jfi_frame_size = framedescrs.jfi_frame_size
 jf_frame_info = framedescrs.jf_frame_info
+jf_extra_stack_depth = framedescrs.jf_extra_stack_depth
 signedframedescr = self.cpu.signedframedescr
 floatframedescr = self.cpu.floatframedescr
 casmdescr.compiled_loop_token = clt
@@ -810,6 +811,7 @@
 p1 = call_malloc_nursery_varsize_frame(i1)
 setfield_gc(p1, 0, descr=tiddescr)
 i2 = getfield_gc(ConstClass(frame_info), descr=jfi_frame_depth)
+setfield_gc(p1, 0, descr=jf_extra_stack_depth)
 setfield_gc(p1, i2, descr=framelendescr)
 setfield_gc(p1, ConstClass(frame_info), descr=jf_frame_info)
 setarrayitem_gc(p1, 0, i0, descr=signedframedescr)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy gc_no_cleanup_nursery: extra fields that we zero by hand

2014-09-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: gc_no_cleanup_nursery
Changeset: r73635:255d60019595
Date: 2014-09-21 13:49 +0200
http://bitbucket.org/pypy/pypy/changeset/255d60019595/

Log:extra fields that we zero by hand

diff --git a/rpython/jit/backend/llsupport/gc.py 
b/rpython/jit/backend/llsupport/gc.py
--- a/rpython/jit/backend/llsupport/gc.py
+++ b/rpython/jit/backend/llsupport/gc.py
@@ -120,7 +120,8 @@
 descrs = JitFrameDescrs()
 descrs.arraydescr = cpu.arraydescrof(jitframe.JITFRAME)
 for name in ['jf_descr', 'jf_guard_exc', 'jf_force_descr',
- 'jf_frame_info', 'jf_gcmap', 'jf_extra_stack_depth']:
+ 'jf_frame_info', 'jf_gcmap', 'jf_extra_stack_depth',
+ 'jf_savedata', 'jf_forward']:
 setattr(descrs, name, cpu.fielddescrof(jitframe.JITFRAME, name))
 descrs.jfi_frame_size = cpu.fielddescrof(jitframe.JITFRAMEINFO,
   'jfi_frame_size')
diff --git a/rpython/jit/backend/llsupport/rewrite.py 
b/rpython/jit/backend/llsupport/rewrite.py
--- a/rpython/jit/backend/llsupport/rewrite.py
+++ b/rpython/jit/backend/llsupport/rewrite.py
@@ -215,7 +215,7 @@
 self.newops.append(o)
 elif isinstance(v_length, ConstInt) and v_length.getint() == 0:
 return
-o = ResOperation(rop.ZERO_ARRAY, [v_arr, ConstInt(0), v_length], None,
+o = ResOperation(rop.ZERO_ARRAY, [v_arr, self.c_zero, v_length], None,
  descr=arraydescr)
 self.newops.append(o)
 
@@ -238,13 +238,21 @@
 self.gen_malloc_nursery_varsize_frame(size_box, frame)
 self.gen_initialize_tid(frame, descrs.arraydescr.tid)
 length_box = history.BoxInt()
-op1 = ResOperation(rop.GETFIELD_GC, [history.ConstInt(frame_info)],
-   length_box,
-   descr=descrs.jfi_frame_depth)
-self.newops.append(op1)
-op2 = ResOperation(rop.SETFIELD_GC, [frame, ConstInt(0)],
-   None, descr=descrs.jf_extra_stack_depth)
-self.newops.append(op2)
+# we need to explicitely zero all the gc fields, because
+# of the unusal malloc pattern
+extra_ops = [
+ResOperation(rop.GETFIELD_GC, [history.ConstInt(frame_info)],
+ length_box, descr=descrs.jfi_frame_depth),
+ResOperation(rop.SETFIELD_GC, [frame, self.c_zero],
+ None, descr=descrs.jf_extra_stack_depth),
+ResOperation(rop.SETFIELD_GC, [frame, self.c_zero],
+ None, descr=descrs.jf_savedata),
+ResOperation(rop.SETFIELD_GC, [frame, self.c_zero],
+ None, descr=descrs.jf_guard_exc),
+ResOperation(rop.SETFIELD_GC, [frame, self.c_zero],
+ None, descr=descrs.jf_forward),
+]
+self.newops += extra_ops
 self.gen_initialize_len(frame, length_box,
 descrs.arraydescr.lendescr)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy.org extradoc: reword download link text

2014-09-21 Thread mattip
Author: mattip 
Branch: extradoc
Changeset: r538:d4a4df1e1753
Date: 2014-09-21 17:11 +0300
http://bitbucket.org/pypy/pypy.org/changeset/d4a4df1e1753/

Log:reword download link text

diff --git a/index.html b/index.html
--- a/index.html
+++ b/index.html
@@ -63,7 +63,7 @@
 As well as other features.
 
 
-Download and try out the PyPy or PyPy3 release 
2.4.0
+Download and try out PyPy
 Want to know more? A good place to start is our detailed http://speed.pypy.org/";>speed and
 compatibility reports!
 
diff --git a/source/index.txt b/source/index.txt
--- a/source/index.txt
+++ b/source/index.txt
@@ -26,7 +26,7 @@
 
 .. class:: download
 
-`Download and try out the PyPy or PyPy3 release 2.4.0`__
+`Download and try out PyPy`__
 
 .. __: download.html
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.3: merge py3k

2014-09-21 Thread pjenvey
Author: Philip Jenvey 
Branch: py3.3
Changeset: r73638:de00ce0a7596
Date: 2014-09-21 16:20 -0700
http://bitbucket.org/pypy/pypy/changeset/de00ce0a7596/

Log:merge py3k

diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py
--- a/pypy/module/posix/__init__.py
+++ b/pypy/module/posix/__init__.py
@@ -171,7 +171,8 @@
 if os.name == 'nt':
 interpleveldefs.update({
 '_getfileinformation': 'interp_posix._getfileinformation',
-'_getfinalpathname': 'interp_posix._getfinalpathname',
+# XXX: currently broken
+#'_getfinalpathname': 'interp_posix._getfinalpathname',
 })
 if hasattr(os, 'chroot'):
 interpleveldefs['chroot'] = 'interp_posix.chroot'
diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py
--- a/pypy/tool/release/package.py
+++ b/pypy/tool/release/package.py
@@ -307,7 +307,13 @@
 argparse = imp.load_source('argparse', 'lib-python/2.7/argparse.py')
 if sys.platform == 'win32':
 pypy_exe = 'pypy3.exe'
-license_base = os.path.join(basedir, r'..\..\..\local') # as on 
buildbot YMMV
+for p in [os.path.join(basedir, r'..\..\..\local'), #buildbot
+os.path.join(basedir, r'..\local')]: # pypy/doc/windows.rst
+if os.path.exists(p): 
+license_base = p
+break
+else:
+license_base = 'unkown'
 else:
 pypy_exe = 'pypy3'
 license_base = '/usr/share/doc'
@@ -380,5 +386,21 @@
 
 if __name__ == '__main__':
 import sys
+if sys.platform == 'win32':
+# Try to avoid opeing a dialog box if one of the 
+# subprocesses causes a system error
+import ctypes
+winapi = ctypes.windll.kernel32
+SetErrorMode = winapi.SetErrorMode
+SetErrorMode.argtypes=[ctypes.c_int]
+
+SEM_FAILCRITICALERRORS = 1
+SEM_NOGPFAULTERRORBOX  = 2
+SEM_NOOPENFILEERRORBOX = 0x8000
+flags = SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | 
SEM_NOOPENFILEERRORBOX
+#Since there is no GetErrorMode, do a double Set
+old_mode = SetErrorMode(flags)
+SetErrorMode(old_mode | flags)
+
 retval, _ = package(*sys.argv[1:])
 sys.exit(retval)
diff --git a/pypy/tool/release/test/test_package.py 
b/pypy/tool/release/test/test_package.py
--- a/pypy/tool/release/test/test_package.py
+++ b/pypy/tool/release/test/test_package.py
@@ -115,15 +115,21 @@
 check(pypy,  0755)
 
 def test_generate_license():
-from os.path import dirname, abspath, join
+from os.path import dirname, abspath, join, exists
 class Options(object):
 pass
 options = Options()
 basedir = dirname(dirname(dirname(dirname(dirname(abspath(__file__))
 options.no_tk = False
 if sys.platform == 'win32':
- # as on buildbot YMMV
-options.license_base = join(basedir, r'..\..\..\local')
+for p in [join(basedir, r'..\..\..\local'), #buildbot
+  join(basedir, r'..\local')]: # pypy/doc/windows.rst
+if exists(p): 
+license_base = p
+break
+else:
+license_base = 'unkown'
+options.license_base = license_base
 else:
 options.license_base = '/usr/share/doc'
 license = package.generate_license(py.path.local(basedir), options)
diff --git a/rpython/translator/driver.py b/rpython/translator/driver.py
--- a/rpython/translator/driver.py
+++ b/rpython/translator/driver.py
@@ -476,11 +476,12 @@
 shutil_copy(str(soname), str(newsoname))
 self.log.info("copied: %s" % (newsoname,))
 if sys.platform == 'win32':
-# copy the import library as well
-libname = soname.new(ext='lib')
-newlibname = newexename.new(basename=soname.basename)
-shutil.copyfile(str(libname), 
str(newlibname.new(ext='lib')))
-self.log.info("copied: %s" % (newlibname,))
+ext_to_copy = ['lib', 'pdb']
+for ext in ext_to_copy:
+name = soname.new(ext=ext)
+newname = newexename.new(basename=soname.basename)
+shutil.copyfile(str(name), str(newname.new(ext=ext)))
+self.log.info("copied: %s" % (newname,))
 self.c_entryp = newexename
 self.log.info('usession directory: %s' % (udir,))
 self.log.info("created: %s" % (self.c_entryp,))
diff --git a/rpython/translator/platform/windows.py 
b/rpython/translator/platform/windows.py
--- a/rpython/translator/platform/windows.py
+++ b/rpython/translator/platform/windows.py
@@ -410,7 +410,7 @@
'int main(int argc, char* argv[]) '
'{ return $(PYPY_MAIN_FUNCTION)(argc, argv); } > $@')
 m.rule('$(DEFAULT_TARGET)', ['$(TARGET)', 'main.obj'],

[pypy-commit] pypy py3k: _getfinalpathname is broken, disable for now

2014-09-21 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r73637:7011366e6fbf
Date: 2014-09-21 16:20 -0700
http://bitbucket.org/pypy/pypy/changeset/7011366e6fbf/

Log:_getfinalpathname is broken, disable for now

diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py
--- a/pypy/module/posix/__init__.py
+++ b/pypy/module/posix/__init__.py
@@ -167,7 +167,8 @@
 if os.name == 'nt':
 interpleveldefs.update({
 '_getfileinformation': 'interp_posix._getfileinformation',
-'_getfinalpathname': 'interp_posix._getfinalpathname',
+# XXX: currently broken
+#'_getfinalpathname': 'interp_posix._getfinalpathname',
 })
 if hasattr(os, 'chroot'):
 interpleveldefs['chroot'] = 'interp_posix.chroot'
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.3: merge py3k

2014-09-21 Thread pjenvey
Author: Philip Jenvey 
Branch: py3.3
Changeset: r73636:ac2759ae7eb6
Date: 2014-09-18 21:14 -0700
http://bitbucket.org/pypy/pypy/changeset/ac2759ae7eb6/

Log:merge py3k

diff --git a/pypy/doc/windows.rst b/pypy/doc/windows.rst
--- a/pypy/doc/windows.rst
+++ b/pypy/doc/windows.rst
@@ -85,10 +85,13 @@
 
 Abridged method (for -Ojit builds using Visual Studio 2008)
 ~~~
-Download the versions of all the external packages
-from 
+Download the versions of all the external packages from 
+https://bitbucket.org/pypy/pypy/downloads/local_2.4.zip
+(for 2.4 release and later) or
 https://bitbucket.org/pypy/pypy/downloads/local.zip
-Then expand it into the base directory (base_dir) and modify your environment 
to reflect this::
+(for pre-2.4 versions)
+Then expand it into the base directory (base_dir) and modify your environment
+to reflect this::
 
 set PATH=\bin;\tcltk\bin;%PATH%
 set INCLUDE=\include;\tcltk\include;%INCLUDE%
diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -46,6 +46,7 @@
 def cpython_code_signature(code):
 "([list-of-arg-names], vararg-name-or-None, kwarg-name-or-None)."
 argcount = code.co_argcount
+varnames = code.co_varnames
 if we_are_translated():
 kwonlyargcount = code.co_kwonlyargcount
 else:
@@ -53,16 +54,18 @@
 kwonlyargcount = getattr(code, 'co_kwonlyargcount', 0)
 assert argcount >= 0 # annotator hint
 assert kwonlyargcount >= 0
-argnames = list(code.co_varnames[:argcount])
-kwonlyargs = list(code.co_varnames[argcount:argcount + kwonlyargcount])
+argnames = list(varnames[:argcount])
+if argcount < len(varnames):
+kwonlyargs = list(varnames[argcount:argcount + kwonlyargcount])
+else:
+kwonlyargs = None
 if code.co_flags & CO_VARARGS:
-varargname = code.co_varnames[argcount]
+varargname = varnames[argcount]
 argcount += 1
 else:
 varargname = None
 if code.co_flags & CO_VARKEYWORDS:
 kwargname = code.co_varnames[argcount + kwonlyargcount]
-argcount += 1
 else:
 kwargname = None
 return Signature(argnames, varargname, kwargname, kwonlyargs)
diff --git a/pypy/interpreter/pyparser/parsestring.py 
b/pypy/interpreter/pyparser/parsestring.py
--- a/pypy/interpreter/pyparser/parsestring.py
+++ b/pypy/interpreter/pyparser/parsestring.py
@@ -82,12 +82,6 @@
 v = PyString_DecodeEscape(space, substr, 'strict', encoding)
 return space.wrapbytes(v)
 
-def hexbyte(val):
-result = "%x" % val
-if len(result) == 1:
-result = "0" + result
-return result
-
 def decode_unicode_utf8(space, s, ps, q):
 # The Python 2.7 version, producing UTF-32 escapes
 # String is utf8-encoded, but 'unicode_escape' expects
@@ -107,15 +101,14 @@
 # instead.
 lis.append("u005c")
 if ord(s[ps]) & 0x80: # XXX inefficient
-w, ps = decode_utf8(space, s, ps, end, "utf-32-be")
-rn = len(w)
-assert rn % 4 == 0
-for i in range(0, rn, 4):
-lis.append('\\U')
-lis.append(hexbyte(ord(w[i])))
-lis.append(hexbyte(ord(w[i+1])))
-lis.append(hexbyte(ord(w[i+2])))
-lis.append(hexbyte(ord(w[i+3])))
+w, ps = decode_utf8(space, s, ps, end)
+for c in w:
+# The equivalent of %08x, which is not supported by RPython.
+# 7 zeroes are enough for the unicode range, and the
+# result still fits in 32-bit.
+hexa = hex(ord(c) + 0x1000)
+lis.append('\\U0')
+lis.append(hexa[3:])  # Skip 0x and the leading 1
 else:
 lis.append(s[ps])
 ps += 1
@@ -135,7 +128,7 @@
 # note that the C code has a label here.
 # the logic is the same.
 if recode_encoding and ord(s[ps]) & 0x80:
-w, ps = decode_utf8(space, s, ps, end, recode_encoding)
+w, ps = decode_utf8_recode(space, s, ps, end, recode_encoding)
 # Append bytes to output buffer.
 builder.append(w)
 else:
@@ -222,14 +215,18 @@
 ch >= 'A' and ch <= 'F')
 
 
-def decode_utf8(space, s, ps, end, encoding):
+def decode_utf8(space, s, ps, end):
 assert ps >= 0
 pt = ps
 # while (s < end && *s != '\\') s++; */ /* inefficient for u".."
 while ps < end and ord(s[ps]) & 0x80:
 ps += 1
-w_u = space.wrap(unicodehelper.decode_utf8(space, s[pt:ps]))
-w_v = unicodehelper.encode(space, w_u, encoding)
+u = unicodehelper.decode_utf8(space, s[pt:ps])
+return u, ps
+
+def decode_utf8_recode(space, s, ps, end, recode_encoding):
+u, ps = decode_utf8(space, s, ps, end)
+w_v = unicodehelper.encode(space, 

[pypy-commit] pypy py3.3: issue832: linux sys.platform now always "linux"

2014-09-21 Thread pjenvey
Author: Philip Jenvey 
Branch: py3.3
Changeset: r73639:31223ffc5ac1
Date: 2014-09-21 16:22 -0700
http://bitbucket.org/pypy/pypy/changeset/31223ffc5ac1/

Log:issue832: linux sys.platform now always "linux"

diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -23,7 +23,7 @@
 '__name__'  : '(space.wrap("sys"))',
 '__doc__'   : '(space.wrap("PyPy sys module"))',
 
-'platform'  : 'space.wrap(sys.platform)',
+'platform'  : 'space.wrap(system.PLATFORM)',
 'maxsize'   : 'space.wrap(sys.maxint)',
 'byteorder' : 'space.wrap(sys.byteorder)',
 'maxunicode': 'space.wrap(vm.MAXUNICODE)',
diff --git a/pypy/module/sys/system.py b/pypy/module/sys/system.py
--- a/pypy/module/sys/system.py
+++ b/pypy/module/sys/system.py
@@ -1,4 +1,6 @@
 """Information about the current system."""
+import sys
+
 from pypy.objspace.std.complexobject import HASH_IMAG
 from pypy.objspace.std.floatobject import HASH_INF, HASH_NAN
 from pypy.objspace.std.intobject import HASH_MODULUS
@@ -6,6 +8,7 @@
 from rpython.rlib import rbigint, rfloat
 from rpython.rtyper.lltypesystem import lltype, rffi
 
+PLATFORM = 'linux' if sys.platform.startswith('linux') else sys.platform
 
 app = gateway.applevel("""
 "NOT_RPYTHON"
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.3: sys.platform linux2 -> linux

2014-09-21 Thread pjenvey
Author: Philip Jenvey 
Branch: py3.3
Changeset: r73640:57188ff5ab4e
Date: 2014-09-21 16:31 -0700
http://bitbucket.org/pypy/pypy/changeset/57188ff5ab4e/

Log:sys.platform linux2 -> linux

diff --git a/lib_pypy/ctypes_support.py b/lib_pypy/ctypes_support.py
--- a/lib_pypy/ctypes_support.py
+++ b/lib_pypy/ctypes_support.py
@@ -22,7 +22,7 @@
 def _where_is_errno():
 return standard_c_lib._errno()
 
-elif sys.platform in ('linux2', 'freebsd6'):
+elif sys.platform in ('linux', 'freebsd6'):
 standard_c_lib.__errno_location.restype = ctypes.POINTER(ctypes.c_int)
 standard_c_lib.__errno_location.argtypes = None
 def _where_is_errno():
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-2.4.x: Fix curses on OS X -- copy this logic from cpython

2014-09-21 Thread alex_gaynor
Author: Alex Gaynor 
Branch: release-2.4.x
Changeset: r73641:c6ad44ecf5d8
Date: 2014-09-20 14:16 -0700
http://bitbucket.org/pypy/pypy/changeset/c6ad44ecf5d8/

Log:Fix curses on OS X -- copy this logic from cpython

diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py
--- a/lib_pypy/_curses.py
+++ b/lib_pypy/_curses.py
@@ -286,6 +286,13 @@
 
 
 lib = ffi.verify("""
+#ifdef __APPLE__
+/* the following define is necessary for OS X 10.6+; without it, the
+   Apple-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python
+   can't get at the WINDOW flags field. */
+#define NCURSES_OPAQUE 0
+#endif
+
 #include 
 #include 
 #include 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: First step to fixing the sanbox: implement os.access

2014-09-21 Thread stefanor
Author: Stefano Rivera 
Branch: 
Changeset: r73642:1599b45fa4e1
Date: 2014-09-21 23:52 -0700
http://bitbucket.org/pypy/pypy/changeset/1599b45fa4e1/

Log:First step to fixing the sanbox: implement os.access

pypy now (since b97c7d6f7fd8) checks for executability, when
searching for its own executable on startup. This requires
os.access.

diff --git a/rpython/translator/sandbox/sandlib.py 
b/rpython/translator/sandbox/sandlib.py
--- a/rpython/translator/sandbox/sandlib.py
+++ b/rpython/translator/sandbox/sandlib.py
@@ -459,6 +459,15 @@
 
 do_ll_os__ll_os_lstat = do_ll_os__ll_os_stat
 
+def do_ll_os__ll_os_access(self, vpathname, mode):
+try:
+node = self.get_node(vpathname)
+except OSError, e:
+if e.errno == errno.ENOENT:
+return False
+raise
+return node.access(mode)
+
 def do_ll_os__ll_os_isatty(self, fd):
 return self.virtual_console_isatty and fd in (0, 1, 2)
 
diff --git a/rpython/translator/sandbox/test/test_vfs.py 
b/rpython/translator/sandbox/test/test_vfs.py
--- a/rpython/translator/sandbox/test/test_vfs.py
+++ b/rpython/translator/sandbox/test/test_vfs.py
@@ -33,6 +33,8 @@
 py.test.raises(OSError, d.join, 'bar')
 st = d.stat()
 assert stat.S_ISDIR(st.st_mode)
+assert d.access(os.R_OK | os.X_OK)
+assert not d.access(os.W_OK)
 
 def test_file():
 f = File('hello world')
@@ -46,6 +48,8 @@
 st = f.stat()
 assert stat.S_ISREG(st.st_mode)
 assert st.st_size == 11
+assert f.access(os.R_OK)
+assert not f.access(os.W_OK)
 
 def test_realdir_realfile():
 for show_dotfiles in [False, True]:
@@ -78,6 +82,7 @@
 
 f = v_test_vfs.join('symlink2')
 assert stat.S_ISREG(f.stat().st_mode)
+assert f.access(os.R_OK)
 assert f.open().read() == 'secret'
 else:
 py.test.raises(OSError, v_test_vfs.join, 'symlink1')
diff --git a/rpython/translator/sandbox/vfs.py 
b/rpython/translator/sandbox/vfs.py
--- a/rpython/translator/sandbox/vfs.py
+++ b/rpython/translator/sandbox/vfs.py
@@ -37,6 +37,15 @@
 (st_mode, st_ino, st_dev, st_nlink, st_uid, st_gid,
  st_size, st_atime, st_mtime, st_ctime))
 
+def access(self, mode):
+s = self.stat()
+e_mode = s.st_mode & stat.S_IRWXO
+if UID == s.st_uid:
+e_mode |= (s.st_mode & stat.S_IRWXU) >> 6
+if GID == s.st_gid:
+e_mode |= (s.st_mode & stat.S_IRWXG) >> 3
+return (e_mode & mode) == mode
+
 def keys(self):
 raise OSError(errno.ENOTDIR, self)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix the sandbox

2014-09-21 Thread stefanor
Author: Stefano Rivera 
Branch: 
Changeset: r73643:17fcf0cc640d
Date: 2014-09-21 23:54 -0700
http://bitbucket.org/pypy/pypy/changeset/17fcf0cc640d/

Log:Fix the sandbox

pypy now (since b97c7d6f7fd8) checks for executability, when
searching for its own executable on startup.

Abuse "kind" to maintain extra mode bits, so we can store the
executable state in our vfs.

diff --git a/pypy/sandbox/pypy_interact.py b/pypy/sandbox/pypy_interact.py
--- a/pypy/sandbox/pypy_interact.py
+++ b/pypy/sandbox/pypy_interact.py
@@ -55,7 +55,7 @@
 
 return Dir({
 'bin': Dir({
-'pypy-c': RealFile(self.executable),
+'pypy-c': RealFile(self.executable, mode=0111),
 'lib-python': RealDir(os.path.join(libroot, 'lib-python'),
   exclude=exclude), 
 'lib_pypy': RealDir(os.path.join(libroot, 'lib_pypy'),
diff --git a/rpython/translator/sandbox/vfs.py 
b/rpython/translator/sandbox/vfs.py
--- a/rpython/translator/sandbox/vfs.py
+++ b/rpython/translator/sandbox/vfs.py
@@ -22,7 +22,7 @@
 st_size = self.getsize()
 st_mode = self.kind
 st_mode |= stat.S_IWUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH
-if self.kind == stat.S_IFDIR:
+if stat.S_ISDIR(self.kind):
 st_mode |= stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
 if self.read_only:
 st_uid = 0   # read-only files are virtually owned by root
@@ -123,8 +123,9 @@
 return cStringIO.StringIO(self.data)
 
 class RealFile(File):
-def __init__(self, path):
+def __init__(self, path, mode=0):
 self.path = path
+self.kind |= mode
 def __repr__(self):
 return '' % (self.path,)
 def getsize(self):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit