[pypy-commit] pypy stdlib-2.7.9: Translation fix

2015-02-10 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: stdlib-2.7.9
Changeset: r75795:5ffa2d51f624
Date: 2015-02-10 09:29 +0100
http://bitbucket.org/pypy/pypy/changeset/5ffa2d51f624/

Log:Translation fix

diff --git a/pypy/module/_ssl/interp_win32.py b/pypy/module/_ssl/interp_win32.py
--- a/pypy/module/_ssl/interp_win32.py
+++ b/pypy/module/_ssl/interp_win32.py
@@ -48,8 +48,9 @@
 CertFreeCertificateContext = external(
 'CertFreeCertificateContext', [PCCERT_CONTEXT], rwin32.BOOL)
 CertGetEnhancedKeyUsage = external(
-'CertGetEnhancedKeyUsage', [PCCERT_CONTEXT, rwin32.DWORD,
-PCERT_ENHKEY_USAGE, rwin32.LPDWORD], rffi.BOOL)
+'CertGetEnhancedKeyUsage',
+[PCCERT_CONTEXT, rwin32.DWORD, PCERT_ENHKEY_USAGE, rwin32.LPDWORD],
+rwin32.BOOL)
 CertEnumCertificatesInStore = external(
 'CertEnumCertificatesInStore',
 [rffi.HANDLE, PCCERT_CONTEXT], PCCERT_CONTEXT)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy vmprof: - Fix rbisect to match the expectations of asmmmemmgr.

2015-02-10 Thread arigo
Author: Armin Rigo 
Branch: vmprof
Changeset: r75797:700eed63ab38
Date: 2015-02-10 13:44 +0100
http://bitbucket.org/pypy/pypy/changeset/700eed63ab38/

Log:- Fix rbisect to match the expectations of asmmmemmgr.

- Fix asmmemmgr to not kill a random jit_codemap entry every time
free() is called on a block that does not contain code.

diff --git a/rpython/jit/backend/llsupport/asmmemmgr.py 
b/rpython/jit/backend/llsupport/asmmemmgr.py
--- a/rpython/jit/backend/llsupport/asmmemmgr.py
+++ b/rpython/jit/backend/llsupport/asmmemmgr.py
@@ -62,9 +62,12 @@
 self.jit_frame_depth_map = (self.jit_frame_depth_map[:jit_adr_start] +
 self.jit_frame_depth_map[jit_adr_stop:])
 # fix up codemap
-codemap_adr = bisect_tuple(self.jit_codemap, start)
-self.jit_codemap = (self.jit_codemap[:codemap_adr] +
-self.jit_codemap[codemap_adr + 1:])
+# (there should only be zero or one codemap entry in that range,
+# but still we use a range to distinguish between zero and one)
+codemap_adr_start = bisect_tuple(self.jit_codemap, start)
+codemap_adr_stop = bisect_tuple(self.jit_codemap, stop)
+self.jit_codemap = (self.jit_codemap[:codemap_adr_start] +
+self.jit_codemap[codemap_adr_stop:])
 
 def open_malloc(self, minsize):
 """Allocate at least minsize bytes.  Returns (start, stop)."""
diff --git a/rpython/rlib/rbisect.py b/rpython/rlib/rbisect.py
--- a/rpython/rlib/rbisect.py
+++ b/rpython/rlib/rbisect.py
@@ -1,10 +1,12 @@
 
 def bisect(a, x):
+"""Return the index in the sorted list 'a' of 'x'.  If 'x' is not in 'a',
+return the index where it can be inserted."""
 lo = 0
 hi = len(a)
 while lo < hi:
 mid = (lo+hi)//2
-if x < a[mid]: hi = mid
+if x <= a[mid]: hi = mid
 else: lo = mid+1
 return lo
 
@@ -14,6 +16,6 @@
 hi = len(a)
 while lo < hi:
 mid = (lo+hi)//2
-if x < a[mid][0]: hi = mid
+if x <= a[mid][0]: hi = mid
 else: lo = mid+1
 return lo
diff --git a/rpython/rlib/test/test_rbisect.py 
b/rpython/rlib/test/test_rbisect.py
--- a/rpython/rlib/test/test_rbisect.py
+++ b/rpython/rlib/test/test_rbisect.py
@@ -5,42 +5,42 @@
 cases = [
 ([], 1, 0),
 ([1], 0, 0),
-([1], 1, 1),
+([1], 1, 0),
 ([1], 2, 1),
 ([1, 1], 0, 0),
-([1, 1], 1, 2),
+([1, 1], 1, 0),
 ([1, 1], 2, 2),
 ([1, 1, 1], 0, 0),
-([1, 1, 1], 1, 3),
+([1, 1, 1], 1, 0),
 ([1, 1, 1], 2, 3),
 ([1, 1, 1, 1], 0, 0),
-([1, 1, 1, 1], 1, 4),
+([1, 1, 1, 1], 1, 0),
 ([1, 1, 1, 1], 2, 4),
 ([1, 2], 0, 0),
-([1, 2], 1, 1),
+([1, 2], 1, 0),
 ([1, 2], 1.5, 1),
-([1, 2], 2, 2),
+([1, 2], 2, 1),
 ([1, 2], 3, 2),
 ([1, 1, 2, 2], 0, 0),
-([1, 1, 2, 2], 1, 2),
+([1, 1, 2, 2], 1, 0),
 ([1, 1, 2, 2], 1.5, 2),
-([1, 1, 2, 2], 2, 4),
+([1, 1, 2, 2], 2, 2),
 ([1, 1, 2, 2], 3, 4),
 ([1, 2, 3], 0, 0),
-([1, 2, 3], 1, 1),
+([1, 2, 3], 1, 0),
 ([1, 2, 3], 1.5, 1),
-([1, 2, 3], 2, 2),
+([1, 2, 3], 2, 1),
 ([1, 2, 3], 2.5, 2),
-([1, 2, 3], 3, 3),
+([1, 2, 3], 3, 2),
 ([1, 2, 3], 4, 3),
 ([1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 0, 0),
-([1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1, 1),
+([1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1, 0),
 ([1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 1.5, 1),
-([1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2, 3),
+([1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2, 1),
 ([1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 2.5, 3),
-([1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3, 6),
+([1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3, 3),
 ([1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 3.5, 6),
-([1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 4, 10),
+([1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 4, 6),
 ([1, 2, 2, 3, 3, 3, 4, 4, 4, 4], 5, 10),
 ]
 for lst, elem, exp in cases:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stmgc-c7: Marginally better

2015-02-10 Thread arigo
Author: Armin Rigo 
Branch: stmgc-c7
Changeset: r75796:3324de0ff750
Date: 2015-02-10 11:27 +0100
http://bitbucket.org/pypy/pypy/changeset/3324de0ff750/

Log:Marginally better

diff --git a/rpython/rlib/rstm.py b/rpython/rlib/rstm.py
--- a/rpython/rlib/rstm.py
+++ b/rpython/rlib/rstm.py
@@ -74,7 +74,7 @@
 llop.stm_become_globally_unique_transaction(lltype.Void)
 
 def partial_commit_and_resume_other_threads():
-pass# for now
+hint_commit_soon()# for now
 
 @specialize.arg(0)
 def should_break_transaction(keep):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy vmprof: fix the tests

2015-02-10 Thread fijal
Author: Maciej Fijalkowski 
Branch: vmprof
Changeset: r75798:7af23468be1c
Date: 2015-02-10 14:51 +0200
http://bitbucket.org/pypy/pypy/changeset/7af23468be1c/

Log:fix the tests

diff --git a/rpython/jit/backend/llsupport/codemap.py 
b/rpython/jit/backend/llsupport/codemap.py
--- a/rpython/jit/backend/llsupport/codemap.py
+++ b/rpython/jit/backend/llsupport/codemap.py
@@ -21,10 +21,10 @@
 def stack_depth_at_loc(loc):
 _memmngr = asmmemmgr._memmngr
 
-pos = bisect(_memmngr.jit_addr_map, loc)
+pos = bisect(_memmngr.jit_addr_map, loc + 1)
 if pos == 0 or pos == len(_memmngr.jit_addr_map):
 return -1
-return _memmngr.jit_frame_depth_map[pos-1]
+return _memmngr.jit_frame_depth_map[pos - 1]
 
 @jit_entrypoint([], lltype.Signed, c_name='pypy_jit_start_addr')
 def jit_start_addr():
@@ -76,7 +76,8 @@
 
 def unpack_traceback(addr):
 codemap_pos = find_codemap_at_addr(addr)
-assert codemap_pos >= 0
+if codemap_pos == -1:
+return [] # no codemap for that position
 storage = lltype.malloc(rffi.CArray(lltype.Signed), 1, flavor='raw')
 storage[0] = 0
 res = []
diff --git a/rpython/jit/backend/llsupport/test/test_asmmemmgr.py 
b/rpython/jit/backend/llsupport/test/test_asmmemmgr.py
--- a/rpython/jit/backend/llsupport/test/test_asmmemmgr.py
+++ b/rpython/jit/backend/llsupport/test/test_asmmemmgr.py
@@ -3,6 +3,7 @@
 from rpython.jit.backend.llsupport.asmmemmgr import MachineDataBlockWrapper
 from rpython.jit.backend.llsupport.asmmemmgr import BlockBuilderMixin
 from rpython.jit.backend.llsupport import asmmemmgr
+from rpython.jit.backend.llsupport.codemap import stack_depth_at_loc
 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.rlib import debug
 
@@ -271,9 +272,9 @@
 mgr.register_frame_depth_map(30, [0, 5, 10], [4, 5, 6])
 mgr.register_frame_depth_map(0, [0, 5, 10], [7, 8, 9])
 asmmemmgr._memmngr = mgr
-assert asmmemmgr.stack_depth_at_loc(13) == 1
-assert asmmemmgr.stack_depth_at_loc(-3) == -1
-assert asmmemmgr.stack_depth_at_loc(41) == -1
-assert asmmemmgr.stack_depth_at_loc(5) == 8
-assert asmmemmgr.stack_depth_at_loc(17) == 2
-assert asmmemmgr.stack_depth_at_loc(38) == 5
+assert stack_depth_at_loc(13) == 1
+assert stack_depth_at_loc(-3) == -1
+assert stack_depth_at_loc(41) == -1
+assert stack_depth_at_loc(5) == 8
+assert stack_depth_at_loc(17) == 2
+assert stack_depth_at_loc(38) == 5
diff --git a/rpython/jit/backend/llsupport/test/test_gc.py 
b/rpython/jit/backend/llsupport/test/test_gc.py
--- a/rpython/jit/backend/llsupport/test/test_gc.py
+++ b/rpython/jit/backend/llsupport/test/test_gc.py
@@ -197,14 +197,6 @@
 assert is_valid_int(wbdescr.jit_wb_if_flag_byteofs)
 assert is_valid_int(wbdescr.jit_wb_if_flag_singlebyte)
 
-def test_get_rid_of_debug_merge_point(self):
-operations = [
-ResOperation(rop.DEBUG_MERGE_POINT, ['dummy', 2], None),
-]
-gc_ll_descr = self.gc_ll_descr
-operations = gc_ll_descr.rewrite_assembler(None, operations, [])
-assert len(operations) == 0
-
 def test_record_constptrs(self):
 class MyFakeCPU(object):
 def cast_adr_to_int(self, adr):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy vmprof: Tweaks, including one which is a fix for find_codemap_at_addr() I think

2015-02-10 Thread arigo
Author: Armin Rigo 
Branch: vmprof
Changeset: r75799:9d2347008c52
Date: 2015-02-10 14:38 +0100
http://bitbucket.org/pypy/pypy/changeset/9d2347008c52/

Log:Tweaks, including one which is a fix for find_codemap_at_addr() I
think

diff --git a/rpython/jit/backend/llsupport/asmmemmgr.py 
b/rpython/jit/backend/llsupport/asmmemmgr.py
--- a/rpython/jit/backend/llsupport/asmmemmgr.py
+++ b/rpython/jit/backend/llsupport/asmmemmgr.py
@@ -5,7 +5,7 @@
 from rpython.rlib.debug import debug_start, debug_print, debug_stop
 from rpython.rlib.debug import have_debug_prints
 from rpython.rtyper.lltypesystem import lltype, rffi
-from rpython.rlib.rbisect import bisect, bisect_tuple
+from rpython.rlib.rbisect import bisect_left, bisect_left_tuple
 
 _memmngr = None # global reference so we can use @entrypoint :/
 
@@ -55,19 +55,16 @@
 self.total_mallocs -= r_uint(stop - start)
 self._add_free_block(start, stop)
 # fix up jit_addr_map
-jit_adr_start = bisect(self.jit_addr_map, start)
-jit_adr_stop = bisect(self.jit_addr_map, stop)
-self.jit_addr_map = (self.jit_addr_map[:jit_adr_start] +
- self.jit_addr_map[jit_adr_stop:])
-self.jit_frame_depth_map = (self.jit_frame_depth_map[:jit_adr_start] +
-self.jit_frame_depth_map[jit_adr_stop:])
+jit_adr_start = bisect_left(self.jit_addr_map, start)
+jit_adr_stop = bisect_left(self.jit_addr_map, stop)
+del self.jit_addr_map[jit_adr_start:jit_adr_stop]
+del self.jit_frame_depth_map[jit_adr_start:jit_adr_stop]
 # fix up codemap
 # (there should only be zero or one codemap entry in that range,
 # but still we use a range to distinguish between zero and one)
-codemap_adr_start = bisect_tuple(self.jit_codemap, start)
-codemap_adr_stop = bisect_tuple(self.jit_codemap, stop)
-self.jit_codemap = (self.jit_codemap[:codemap_adr_start] +
-self.jit_codemap[codemap_adr_stop:])
+codemap_adr_start = bisect_left_tuple(self.jit_codemap, start)
+codemap_adr_stop = bisect_left_tuple(self.jit_codemap, stop)
+del self.jit_codemap[codemap_adr_start:codemap_adr_stop]
 
 def open_malloc(self, minsize):
 """Allocate at least minsize bytes.  Returns (start, stop)."""
@@ -183,7 +180,7 @@
 self.jit_addr_map += [0] * len(frame_positions)
 self.jit_frame_depth_map += [0] * len(frame_positions)
 else:
-start = bisect(self.jit_addr_map, rawstart)
+start = bisect_left(self.jit_addr_map, rawstart)
 self.jit_addr_map = (self.jit_addr_map[:start] +
  [0] * len(frame_positions) +
  self.jit_addr_map[start:])
@@ -196,12 +193,8 @@
 
 def register_codemap(self, codemap):
 start = codemap[0]
-pos = bisect_tuple(self.jit_codemap, start)
-if pos == len(self.jit_codemap): # common case
-self.jit_codemap.append(codemap)
-else:
-self.jit_codemap = (self.jit_codemap[:pos] + [codemap] +
-self.jit_codemap[pos:])
+pos = bisect_left_tuple(self.jit_codemap, start)
+self.jit_codemap.insert(pos, codemap)
 
 def _delete(self):
 "NOT_RPYTHON"
diff --git a/rpython/jit/backend/llsupport/codemap.py 
b/rpython/jit/backend/llsupport/codemap.py
--- a/rpython/jit/backend/llsupport/codemap.py
+++ b/rpython/jit/backend/llsupport/codemap.py
@@ -12,7 +12,7 @@
 from rpython.rlib import rgc
 from rpython.rlib.entrypoint import jit_entrypoint
 from rpython.jit.backend.llsupport import asmmemmgr
-from rpython.rlib.rbisect import bisect, bisect_tuple
+from rpython.rlib.rbisect import bisect_right, bisect_right_tuple
 from rpython.rtyper.lltypesystem import lltype, rffi
 
 @jit_entrypoint([lltype.Signed], lltype.Signed,
@@ -21,7 +21,7 @@
 def stack_depth_at_loc(loc):
 _memmngr = asmmemmgr._memmngr
 
-pos = bisect(_memmngr.jit_addr_map, loc + 1)
+pos = bisect_right(_memmngr.jit_addr_map, loc)
 if pos == 0 or pos == len(_memmngr.jit_addr_map):
 return -1
 return _memmngr.jit_frame_depth_map[pos - 1]
@@ -43,9 +43,7 @@
 def find_codemap_at_addr(addr):
 _memmngr = asmmemmgr._memmngr
 
-res = bisect_tuple(_memmngr.jit_codemap, addr) - 1
-if res == len(_memmngr.jit_codemap):
-return -1
+res = bisect_right_tuple(_memmngr.jit_codemap, addr) - 1
 return res
 
 @jit_entrypoint([lltype.Signed, lltype.Signed,
diff --git a/rpython/rlib/rbisect.py b/rpython/rlib/rbisect.py
--- a/rpython/rlib/rbisect.py
+++ b/rpython/rlib/rbisect.py
@@ -1,21 +1,39 @@
 
-def bisect(a, x):
+def bisect_left(a, x):
 """Return the index in the sorted list 'a' of 'x'.  If 'x' is not in 'a',
 return the index where it can be inserted."""
 lo = 0
 hi = len(a)
 while lo < hi:
 mid = (lo+hi)//2
- 

[pypy-commit] pypy stdlib-2.7.9: Translation fix

2015-02-10 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: stdlib-2.7.9
Changeset: r75800:315890b5116a
Date: 2015-02-10 15:03 +0100
http://bitbucket.org/pypy/pypy/changeset/315890b5116a/

Log:Translation fix

diff --git a/pypy/module/_ssl/interp_win32.py b/pypy/module/_ssl/interp_win32.py
--- a/pypy/module/_ssl/interp_win32.py
+++ b/pypy/module/_ssl/interp_win32.py
@@ -53,10 +53,10 @@
 rwin32.BOOL)
 CertEnumCertificatesInStore = external(
 'CertEnumCertificatesInStore',
-[rffi.HANDLE, PCCERT_CONTEXT], PCCERT_CONTEXT)
+[rwin32.HANDLE, PCCERT_CONTEXT], PCCERT_CONTEXT)
 CertEnumCRLsInStore = external(
 'CertEnumCRLsInStore',
-[rffi.HANDLE, PCCRLT_CONTEXT], PCCRL_CONTEXT)
+[rwin32.HANDLE, PCCRLT_CONTEXT], PCCRL_CONTEXT)
 
 def w_certEncodingType(space, encodingType):
 if encodingType == X509_ASN_ENCODING:
@@ -75,7 +75,7 @@
 raise wrap_windowserror(WindowsError(last_error))
 
 size = rffi.widen(size_ptr[0])
-with rffi.scoped_alloc(rffi.CHARP, size) as buf:
+with rffi.scoped_alloc(rffi.CCHARP.TO, size) as buf:
 usage = rffi.cast(PCERT_ENHKEY_USAGE, buf)
 # Now get the actual enhanced usage property
 if not CertGetEnhancedKeyUsage(pCertCtx, flags, usage, size_ptr):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stdlib-2.7.9: fix typo

2015-02-10 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: stdlib-2.7.9
Changeset: r75801:268a268ecf64
Date: 2015-02-10 15:22 +0100
http://bitbucket.org/pypy/pypy/changeset/268a268ecf64/

Log:fix typo

diff --git a/pypy/module/_ssl/interp_win32.py b/pypy/module/_ssl/interp_win32.py
--- a/pypy/module/_ssl/interp_win32.py
+++ b/pypy/module/_ssl/interp_win32.py
@@ -56,7 +56,7 @@
 [rwin32.HANDLE, PCCERT_CONTEXT], PCCERT_CONTEXT)
 CertEnumCRLsInStore = external(
 'CertEnumCRLsInStore',
-[rwin32.HANDLE, PCCRLT_CONTEXT], PCCRL_CONTEXT)
+[rwin32.HANDLE, PCCRL_CONTEXT], PCCRL_CONTEXT)
 
 def w_certEncodingType(space, encodingType):
 if encodingType == X509_ASN_ENCODING:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy framestate: Fix Return.nomoreblocks()

2015-02-10 Thread rlamy
Author: Ronan Lamy 
Branch: framestate
Changeset: r75802:80fb13c783c8
Date: 2015-02-08 19:48 +
http://bitbucket.org/pypy/pypy/changeset/80fb13c783c8/

Log:Fix Return.nomoreblocks()

diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -1040,6 +1040,7 @@
 w_result = self.w_value
 link = Link([w_result], ctx.graph.returnblock)
 ctx.recorder.crnt_block.closeblock(link)
+raise StopFlowing
 
 @property
 def args(self):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy framestate: find the actual target of break statements during analyze_signals() phase

2015-02-10 Thread rlamy
Author: Ronan Lamy 
Branch: framestate
Changeset: r75805:c984486d36dc
Date: 2015-02-10 06:39 +
http://bitbucket.org/pypy/pypy/changeset/c984486d36dc/

Log:find the actual target of break statements during analyze_signals()
phase

diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -146,7 +146,6 @@
 if self.offset in self.pending_blocks:
 next_block = self.pending_blocks[self.offset]
 if not self.curr_block.operations:
-import pdb; pdb.set_trace
 self.blocks.pop()
 self.enter_next_block(next_block)
 elif self.needs_new_block:
@@ -222,6 +221,12 @@
 for exit in block._exits:
 exit.set_blockstack(self.blockstack)
 
+def unroll(self, signal):
+while self.blockstack:
+block = self.blockstack.pop()
+if isinstance(signal, block.handles):
+return block
+
 def check_graph(self):
 for b in self.blocks:
 if not b._exits:
@@ -527,6 +532,15 @@
 
 @bc_reader.register_opcode
 class BREAK_LOOP(BCInstruction):
+def bc_flow(self, reader):
+reader.curr_block.operations.append(self)
+reader.end_block()
+
+def do_signals(self, reader):
+from rpython.flowspace.flowcontext import Break
+frameblock = reader.unroll(Break())
+reader.curr_block.set_exits([frameblock.handler])
+
 def eval(self, ctx):
 from rpython.flowspace.flowcontext import Break
 return ctx.unroll(Break())
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy framestate: Directly call ctx.unroll() in some cases

2015-02-10 Thread rlamy
Author: Ronan Lamy 
Branch: framestate
Changeset: r75804:f4c41b6cf812
Date: 2015-02-10 01:17 +
http://bitbucket.org/pypy/pypy/changeset/f4c41b6cf812/

Log:Directly call ctx.unroll() in some cases

diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -529,7 +529,7 @@
 class BREAK_LOOP(BCInstruction):
 def eval(self, ctx):
 from rpython.flowspace.flowcontext import Break
-raise Break
+return ctx.unroll(Break())
 
 @bc_reader.register_opcode
 class CONTINUE_LOOP(BCInstruction):
@@ -539,7 +539,7 @@
 
 def eval(self, ctx):
 from rpython.flowspace.flowcontext import Continue
-raise Continue(self.target)
+return ctx.unroll(Continue(self.target))
 
 class SetupInstruction(BCInstruction):
 def bc_flow(self, reader):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy framestate: Start new bc_blocks after instructions that modify the blockstack

2015-02-10 Thread rlamy
Author: Ronan Lamy 
Branch: framestate
Changeset: r75803:591f5aefe17b
Date: 2015-02-09 16:33 +
http://bitbucket.org/pypy/pypy/changeset/591f5aefe17b/

Log:Start new bc_blocks after instructions that modify the blockstack

diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -545,6 +545,7 @@
 def bc_flow(self, reader):
 reader.curr_block.operations.append(self)
 self.target = reader.get_block_at(self.arg)
+reader.end_block()
 
 def do_signals(self, reader):
 reader.blockstack.append(self.make_block(-1))
@@ -593,6 +594,10 @@
 
 @bc_reader.register_opcode
 class POP_BLOCK(BCInstruction):
+def bc_flow(self, reader):
+reader.curr_block.operations.append(self)
+reader.end_block()
+
 def do_signals(self, reader):
 reader.blockstack.pop()
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stdlib-2.7.9: add missing function

2015-02-10 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: stdlib-2.7.9
Changeset: r75806:0ab846ce79d9
Date: 2015-02-10 19:15 +0100
http://bitbucket.org/pypy/pypy/changeset/0ab846ce79d9/

Log:add missing function

diff --git a/pypy/module/_ssl/interp_win32.py b/pypy/module/_ssl/interp_win32.py
--- a/pypy/module/_ssl/interp_win32.py
+++ b/pypy/module/_ssl/interp_win32.py
@@ -45,8 +45,6 @@
 'CertOpenSystemStoreA', [rffi.VOIDP, rffi.CCHARP], rwin32.HANDLE)
 CertCloseStore = external(
 'CertCloseStore', [rwin32.HANDLE, rwin32.DWORD], rwin32.BOOL)
-CertFreeCertificateContext = external(
-'CertFreeCertificateContext', [PCCERT_CONTEXT], rwin32.BOOL)
 CertGetEnhancedKeyUsage = external(
 'CertGetEnhancedKeyUsage',
 [PCCERT_CONTEXT, rwin32.DWORD, PCERT_ENHKEY_USAGE, rwin32.LPDWORD],
@@ -54,9 +52,13 @@
 CertEnumCertificatesInStore = external(
 'CertEnumCertificatesInStore',
 [rwin32.HANDLE, PCCERT_CONTEXT], PCCERT_CONTEXT)
+CertFreeCertificateContext = external(
+'CertFreeCertificateContext', [PCCERT_CONTEXT], rwin32.BOOL)
 CertEnumCRLsInStore = external(
 'CertEnumCRLsInStore',
 [rwin32.HANDLE, PCCRL_CONTEXT], PCCRL_CONTEXT)
+CertFreeCRLContext = external(
+'CertFreeCRLContext', [PCCRL_CONTEXT], rwin32.BOOL)
 
 def w_certEncodingType(space, encodingType):
 if encodingType == X509_ASN_ENCODING:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Document the result of "is" on NaNs.

2015-02-10 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r75807:112c34045210
Date: 2015-02-10 19:18 +0100
http://bitbucket.org/pypy/pypy/changeset/112c34045210/

Log:Document the result of "is" on NaNs.

diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -300,6 +300,18 @@
 Notably missing from the list above are ``str`` and ``unicode``.  If your
 code relies on comparing strings with ``is``, then it might break in PyPy.
 
+Note that for floats there "``is``" only one object per "bit pattern"
+of the float.  So ``float('nan') is float('nan')`` is true on PyPy,
+but not on CPython because they are two objects; but ``0.0 is -0.0``
+is always False, as the bit patterns are different.  As usual,
+``float('nan') == float('nan')`` is always False.  When used in
+containers (as list items or in sets for example), the exact rule of
+equality used is "``if x is y or x == y``" (on both CPython and PyPy);
+as a consequence, because all ``nans`` are identical in PyPy, you
+cannot have several of them in a set, unlike in CPython.  (Issue `#1974`__)
+
+.. __: 
https://bitbucket.org/pypy/pypy/issue/1974/different-behaviour-for-collections-of
+
 
 Miscellaneous
 -
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Issue #1975: copy and adapt the audioop module from the py3.3 branch.

2015-02-10 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: 
Changeset: r75808:4e83debd33c2
Date: 2015-02-10 19:24 +0100
http://bitbucket.org/pypy/pypy/changeset/4e83debd33c2/

Log:Issue #1975: copy and adapt the audioop module from the py3.3
branch.

diff --git a/lib-python/2.7/test/test_audioop.py 
b/lib-python/2.7/test/test_audioop.py
--- a/lib-python/2.7/test/test_audioop.py
+++ b/lib-python/2.7/test/test_audioop.py
@@ -2,7 +2,7 @@
 import sys
 import unittest
 import struct
-from test.test_support import run_unittest, impl_detail
+from test.test_support import run_unittest
 
 
 formats = {
@@ -183,7 +183,6 @@
 self.assertEqual(audioop.lin2lin(datas[4], 4, 2),
 packs[2](0, 0x1234, 0x4567, -0x4568, 0x7fff, -0x8000, -1))
 
-@impl_detail(pypy=False)
 def test_adpcm2lin(self):
 self.assertEqual(audioop.adpcm2lin(b'\x07\x7f\x7f', 1, None),
  (b'\x00\x00\x00\xff\x00\xff', (-179, 40)))
@@ -198,7 +197,6 @@
 self.assertEqual(audioop.adpcm2lin(b'\0' * 5, w, None),
  (b'\0' * w * 10, (0, 0)))
 
-@impl_detail(pypy=False)
 def test_lin2adpcm(self):
 self.assertEqual(audioop.lin2adpcm(datas[1], 1, None),
  (b'\x07\x7f\x7f', (-221, 39)))
@@ -212,7 +210,6 @@
 self.assertEqual(audioop.lin2adpcm(b'\0' * w * 10, w, None),
  (b'\0' * 5, (0, 0)))
 
-@impl_detail(pypy=False)
 def test_lin2alaw(self):
 self.assertEqual(audioop.lin2alaw(datas[1], 1),
  b'\xd5\x87\xa4\x24\xaa\x2a\x5a')
@@ -221,7 +218,6 @@
 self.assertEqual(audioop.lin2alaw(datas[4], 4),
  b'\xd5\x87\xa4\x24\xaa\x2a\x55')
 
-@impl_detail(pypy=False)
 def test_alaw2lin(self):
 encoded = b'\x00\x03\x24\x2a\x51\x54\x55\x58\x6b\x71\x7f'\
   b'\x80\x83\xa4\xaa\xd1\xd4\xd5\xd8\xeb\xf1\xff'
@@ -236,7 +232,6 @@
 decoded = audioop.alaw2lin(encoded, w)
 self.assertEqual(audioop.lin2alaw(decoded, w), encoded)
 
-@impl_detail(pypy=False)
 def test_lin2ulaw(self):
 self.assertEqual(audioop.lin2ulaw(datas[1], 1),
  b'\xff\xad\x8e\x0e\x80\x00\x67')
@@ -245,7 +240,6 @@
 self.assertEqual(audioop.lin2ulaw(datas[4], 4),
  b'\xff\xad\x8e\x0e\x80\x00\x7e')
 
-@impl_detail(pypy=False)
 def test_ulaw2lin(self):
 encoded = b'\x00\x0e\x28\x3f\x57\x6a\x76\x7c\x7e\x7f'\
   b'\x80\x8e\xa8\xbf\xd7\xea\xf6\xfc\xfe\xff'
@@ -360,7 +354,6 @@
 self.assertRaises(audioop.error,
 audioop.findmax, ''.join( chr(x) for x in xrange(256)), -2392392)
 
-@impl_detail(pypy=False)
 def test_issue7673(self):
 state = None
 for data, size in INVALID_DATA:
@@ -385,7 +378,6 @@
 self.assertRaises(audioop.error, audioop.lin2alaw, data, size)
 self.assertRaises(audioop.error, audioop.lin2adpcm, data, size, 
state)
 
-@impl_detail(pypy=False)
 def test_wrongsize(self):
 data = b'abcdefgh'
 state = None
diff --git a/lib_pypy/audioop.py b/lib_pypy/audioop.py
--- a/lib_pypy/audioop.py
+++ b/lib_pypy/audioop.py
@@ -1,12 +1,11 @@
-from __future__ import division
 import __builtin__ as builtins
 import math
 import struct
 from fractions import gcd
-from ctypes import create_string_buffer
+from cffi import FFI
 
 
-_buffer = buffer
+_buffer = memoryview
 
 
 class error(Exception):
@@ -149,7 +148,7 @@
 def _sum2(cp1, cp2, length):
 size = 2
 return sum(getsample(cp1, size, i) * getsample(cp2, size, i)
-   for i in range(length))
+   for i in range(length)) + 0.0
 
 
 def findfit(cp1, cp2):
@@ -328,13 +327,14 @@
 _check_params(len(cp), size)
 clip = _get_clipfn(size)
 
-result = create_string_buffer(len(cp))
+rv = ffi.new("unsigned char[]", len(cp))
+result = ffi.buffer(rv)
 
 for i, sample in enumerate(_get_samples(cp, size)):
 sample = clip(int(sample * factor))
 _put_sample(result, size, i, sample)
 
-return result.raw
+return result[:]
 
 
 def tomono(cp, size, fac1, fac2):
@@ -343,7 +343,8 @@
 
 sample_count = _sample_count(cp, size)
 
-result = create_string_buffer(len(cp) // 2)
+rv = ffi.new("unsigned char[]", len(cp) // 2)
+result = ffi.buffer(rv)
 
 for i in range(0, sample_count, 2):
 l_sample = getsample(cp, size, i)
@@ -354,7 +355,7 @@
 
 _put_sample(result, size, i // 2, sample)
 
-return result.raw
+return result[:]
 
 
 def tostereo(cp, size, fac1, fac2):
@@ -362,7 +363,8 @@
 
 sample_count = _sample_count(cp, size)
 
-result = create_string_buffer(len(cp) * 2)
+rv = ffi.new("unsigned char[]", len(cp) * 2)
+result = ffi.buffer(rv)
 clip = _get_clipfn(size)
 
 for i in range(sample_count):
@@ -374,7 +376,7 @@
 _put_sample(result, size, i * 2, l_sample)
 _put_sam

[pypy-commit] pypy default: force compilation of ffi library in audioop.py

2015-02-10 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: 
Changeset: r75809:91ccdfc264d5
Date: 2015-02-10 19:32 +0100
http://bitbucket.org/pypy/pypy/changeset/91ccdfc264d5/

Log:force compilation of ffi library in audioop.py

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
@@ -108,7 +108,7 @@
 '''
 
 def create_cffi_import_libraries(pypy_c, options):
-modules = ['_sqlite3']
+modules = ['_sqlite3', 'audioop']
 subprocess.check_call([str(pypy_c), '-c', 'import _sqlite3'])
 if not sys.platform == 'win32':
 modules += ['_curses', 'syslog', 'gdbm', '_sqlite3']
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: The float-list strategy needs to be slightly more careful about NaNs

2015-02-10 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r75810:690f33fb3b3e
Date: 2015-02-10 19:27 +0100
http://bitbucket.org/pypy/pypy/changeset/690f33fb3b3e/

Log:The float-list strategy needs to be slightly more careful about NaNs

diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -1670,6 +1670,25 @@
 def getitems_float(self, w_list):
 return self.unerase(w_list.lstorage)
 
+def _safe_find(self, w_list, obj, start, stop):
+from rpython.rlib.rfloat import isnan
+from rpython.rlib.longlong2float import float2longlong
+#
+l = self.unerase(w_list.lstorage)
+stop = min(stop, len(l))
+if not isnan(obj):
+for i in range(start, stop):
+val = l[i]
+if val == obj:
+return i
+else:
+search = float2longlong(obj)
+for i in range(start, stop):
+val = l[i]
+if float2longlong(val) == search:
+return i
+raise ValueError
+
 
 class BytesListStrategy(ListStrategy):
 import_from_mixin(AbstractUnwrappedStrategy)
diff --git a/pypy/objspace/std/test/test_listobject.py 
b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -1565,6 +1565,18 @@
 assert l[::11] == [-sys.maxint, item11]
 assert item11 in l[::11]
 
+def test_bug_list_of_nans(self):
+N = float('nan')
+L1 = [N, 'foo']   # general object strategy
+assert N in L1
+assert L1.index(N) == 0
+assert L1 == [N, 'foo']
+# our float list strategy needs to consider NaNs are equal!
+L2 = [N, 0.0] # float strategy
+assert N in L2
+assert L2.index(N) == 0
+assert L2 == [N, -0.0]
+
 
 class AppTestListObjectWithRangeList(AppTestListObject):
 """Run the list object tests with range lists enabled. Tests should go in
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge heads

2015-02-10 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r75812:937407e63958
Date: 2015-02-10 19:37 +0100
http://bitbucket.org/pypy/pypy/changeset/937407e63958/

Log:merge heads

diff --git a/lib-python/2.7/test/test_audioop.py 
b/lib-python/2.7/test/test_audioop.py
--- a/lib-python/2.7/test/test_audioop.py
+++ b/lib-python/2.7/test/test_audioop.py
@@ -2,7 +2,7 @@
 import sys
 import unittest
 import struct
-from test.test_support import run_unittest, impl_detail
+from test.test_support import run_unittest
 
 
 formats = {
@@ -183,7 +183,6 @@
 self.assertEqual(audioop.lin2lin(datas[4], 4, 2),
 packs[2](0, 0x1234, 0x4567, -0x4568, 0x7fff, -0x8000, -1))
 
-@impl_detail(pypy=False)
 def test_adpcm2lin(self):
 self.assertEqual(audioop.adpcm2lin(b'\x07\x7f\x7f', 1, None),
  (b'\x00\x00\x00\xff\x00\xff', (-179, 40)))
@@ -198,7 +197,6 @@
 self.assertEqual(audioop.adpcm2lin(b'\0' * 5, w, None),
  (b'\0' * w * 10, (0, 0)))
 
-@impl_detail(pypy=False)
 def test_lin2adpcm(self):
 self.assertEqual(audioop.lin2adpcm(datas[1], 1, None),
  (b'\x07\x7f\x7f', (-221, 39)))
@@ -212,7 +210,6 @@
 self.assertEqual(audioop.lin2adpcm(b'\0' * w * 10, w, None),
  (b'\0' * 5, (0, 0)))
 
-@impl_detail(pypy=False)
 def test_lin2alaw(self):
 self.assertEqual(audioop.lin2alaw(datas[1], 1),
  b'\xd5\x87\xa4\x24\xaa\x2a\x5a')
@@ -221,7 +218,6 @@
 self.assertEqual(audioop.lin2alaw(datas[4], 4),
  b'\xd5\x87\xa4\x24\xaa\x2a\x55')
 
-@impl_detail(pypy=False)
 def test_alaw2lin(self):
 encoded = b'\x00\x03\x24\x2a\x51\x54\x55\x58\x6b\x71\x7f'\
   b'\x80\x83\xa4\xaa\xd1\xd4\xd5\xd8\xeb\xf1\xff'
@@ -236,7 +232,6 @@
 decoded = audioop.alaw2lin(encoded, w)
 self.assertEqual(audioop.lin2alaw(decoded, w), encoded)
 
-@impl_detail(pypy=False)
 def test_lin2ulaw(self):
 self.assertEqual(audioop.lin2ulaw(datas[1], 1),
  b'\xff\xad\x8e\x0e\x80\x00\x67')
@@ -245,7 +240,6 @@
 self.assertEqual(audioop.lin2ulaw(datas[4], 4),
  b'\xff\xad\x8e\x0e\x80\x00\x7e')
 
-@impl_detail(pypy=False)
 def test_ulaw2lin(self):
 encoded = b'\x00\x0e\x28\x3f\x57\x6a\x76\x7c\x7e\x7f'\
   b'\x80\x8e\xa8\xbf\xd7\xea\xf6\xfc\xfe\xff'
@@ -360,7 +354,6 @@
 self.assertRaises(audioop.error,
 audioop.findmax, ''.join( chr(x) for x in xrange(256)), -2392392)
 
-@impl_detail(pypy=False)
 def test_issue7673(self):
 state = None
 for data, size in INVALID_DATA:
@@ -385,7 +378,6 @@
 self.assertRaises(audioop.error, audioop.lin2alaw, data, size)
 self.assertRaises(audioop.error, audioop.lin2adpcm, data, size, 
state)
 
-@impl_detail(pypy=False)
 def test_wrongsize(self):
 data = b'abcdefgh'
 state = None
diff --git a/lib_pypy/audioop.py b/lib_pypy/audioop.py
--- a/lib_pypy/audioop.py
+++ b/lib_pypy/audioop.py
@@ -1,12 +1,11 @@
-from __future__ import division
 import __builtin__ as builtins
 import math
 import struct
 from fractions import gcd
-from ctypes import create_string_buffer
+from cffi import FFI
 
 
-_buffer = buffer
+_buffer = memoryview
 
 
 class error(Exception):
@@ -149,7 +148,7 @@
 def _sum2(cp1, cp2, length):
 size = 2
 return sum(getsample(cp1, size, i) * getsample(cp2, size, i)
-   for i in range(length))
+   for i in range(length)) + 0.0
 
 
 def findfit(cp1, cp2):
@@ -328,13 +327,14 @@
 _check_params(len(cp), size)
 clip = _get_clipfn(size)
 
-result = create_string_buffer(len(cp))
+rv = ffi.new("unsigned char[]", len(cp))
+result = ffi.buffer(rv)
 
 for i, sample in enumerate(_get_samples(cp, size)):
 sample = clip(int(sample * factor))
 _put_sample(result, size, i, sample)
 
-return result.raw
+return result[:]
 
 
 def tomono(cp, size, fac1, fac2):
@@ -343,7 +343,8 @@
 
 sample_count = _sample_count(cp, size)
 
-result = create_string_buffer(len(cp) // 2)
+rv = ffi.new("unsigned char[]", len(cp) // 2)
+result = ffi.buffer(rv)
 
 for i in range(0, sample_count, 2):
 l_sample = getsample(cp, size, i)
@@ -354,7 +355,7 @@
 
 _put_sample(result, size, i // 2, sample)
 
-return result.raw
+return result[:]
 
 
 def tostereo(cp, size, fac1, fac2):
@@ -362,7 +363,8 @@
 
 sample_count = _sample_count(cp, size)
 
-result = create_string_buffer(len(cp) * 2)
+rv = ffi.new("unsigned char[]", len(cp) * 2)
+result = ffi.buffer(rv)
 clip = _get_clipfn(size)
 
 for i in range(sample_count):
@@ -374,7 +376,7 @@
 _put_sample(result, size, i * 2, l_sample)
 _put_sample(result, size, i * 2 + 1, r_sample)
 
-return result.raw
+return 

[pypy-commit] pypy default: Same issue with tuples containing NaNs

2015-02-10 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r75811:68255911a884
Date: 2015-02-10 19:34 +0100
http://bitbucket.org/pypy/pypy/changeset/68255911a884/

Log:Same issue with tuples containing NaNs

diff --git a/pypy/objspace/std/specialisedtupleobject.py 
b/pypy/objspace/std/specialisedtupleobject.py
--- a/pypy/objspace/std/specialisedtupleobject.py
+++ b/pypy/objspace/std/specialisedtupleobject.py
@@ -5,6 +5,7 @@
 from rpython.rlib.rarithmetic import intmask
 from rpython.rlib.unroll import unrolling_iterable
 from rpython.tool.sourcetools import func_with_new_name
+from rpython.rlib.longlong2float import float2longlong
 
 
 class NotSpecialised(Exception):
@@ -97,6 +98,11 @@
 return space.w_False
 else:
 if myval != otherval:
+if typetuple[i] == float:
+# issue with NaNs, which should be equal here
+if (float2longlong(myval) ==
+float2longlong(otherval)):
+continue
 return space.w_False
 return space.w_True
 
diff --git a/pypy/objspace/std/test/test_specialisedtupleobject.py 
b/pypy/objspace/std/test/test_specialisedtupleobject.py
--- a/pypy/objspace/std/test/test_specialisedtupleobject.py
+++ b/pypy/objspace/std/test/test_specialisedtupleobject.py
@@ -222,6 +222,13 @@
 t = (F(42), F(43))
 assert type(t[0]) is F
 
+def test_bug_tuples_of_nans(self):
+N = float('nan')
+T = (N, N)
+assert N in T
+assert T == (N, N)
+assert (0.0, 0.0) == (-0.0, -0.0)
+
 
 class AppTestAll(test_tupleobject.AppTestW_TupleObject):
 spaceconfig = {"objspace.std.withspecialisedtuple": True}
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix docstring

2015-02-10 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r75813:821eb2210b1a
Date: 2015-02-10 19:58 +0100
http://bitbucket.org/pypy/pypy/changeset/821eb2210b1a/

Log:Fix docstring

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -712,7 +712,7 @@
 return self.wrap(not self.is_true(w_obj))
 
 def eq_w(self, w_obj1, w_obj2):
-"""shortcut for space.is_true(space.eq(w_obj1, w_obj2))"""
+"""Implements equality with the double check 'x is y or x == y'."""
 return self.is_w(w_obj1, w_obj2) or self.is_true(self.eq(w_obj1, 
w_obj2))
 
 def is_(self, w_one, w_two):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: do not modify caller's locals

2015-02-10 Thread mattip
Author: mattip 
Branch: 
Changeset: r75814:6ac9dab8648a
Date: 2015-02-10 22:32 +0200
http://bitbucket.org/pypy/pypy/changeset/6ac9dab8648a/

Log:do not modify caller's locals

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
@@ -196,7 +196,7 @@
 # So please be careful with the order of parameters! ;-)
 pdb_dir = oname.dirname
 if pdb_dir:
-compile_args += ['/Fd%s\\' % (pdb_dir,)]
+compile_args = compile_args + ['/Fd%s\\' % (pdb_dir,)]
 args = ['/nologo', '/c'] + compile_args + ['/Fo%s' % (oname,), 
str(cfile)]
 self._execute_c_compiler(cc, args, oname)
 return oname
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: Fix a corner case where a key of module.__dict__ could be retrieved

2015-02-10 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: py3k
Changeset: r75815:8b50f6d3aebe
Date: 2015-02-10 22:20 +0100
http://bitbucket.org/pypy/pypy/changeset/8b50f6d3aebe/

Log:Fix a corner case where a key of module.__dict__ could be retrieved
as a bytes object.

Probably fixes translation as well

diff --git a/pypy/objspace/std/celldict.py b/pypy/objspace/std/celldict.py
--- a/pypy/objspace/std/celldict.py
+++ b/pypy/objspace/std/celldict.py
@@ -123,7 +123,7 @@
 def w_keys(self, w_dict):
 space = self.space
 l = self.unerase(w_dict.dstorage).keys()
-return space.newlist_bytes(l)
+return space.newlist_unicode(l)
 
 def values(self, w_dict):
 iterator = self.unerase(w_dict.dstorage).itervalues
diff --git a/pypy/objspace/std/test/test_celldict.py 
b/pypy/objspace/std/test/test_celldict.py
--- a/pypy/objspace/std/test/test_celldict.py
+++ b/pypy/objspace/std/test/test_celldict.py
@@ -106,6 +106,11 @@
 assert "s" not in d
 assert F() not in d
 
+def test_reversed(self):
+import __pypy__
+name = next(__pypy__.reversed_dict(__pypy__.__dict__))
+assert isinstance(name, str)
+
 
 class TestModuleDictImplementation(BaseTestRDictImplementation):
 StrategyClass = ModuleDictStrategy
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stdlib-2.7.9: translation fixes

2015-02-10 Thread mattip
Author: mattip 
Branch: stdlib-2.7.9
Changeset: r75818:92a7192649f6
Date: 2015-02-10 23:27 +0200
http://bitbucket.org/pypy/pypy/changeset/92a7192649f6/

Log:translation fixes

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
@@ -552,6 +552,9 @@
 return _decode_certificate(space, self.peer_cert)
 
 def selected_npn_protocol(self, space):
+if not HAS_NPN:
+raise oefmt(space.w_NotImplementedError,
+"The NPN extension requires OpenSSL 1.0.1 or later.")
 with lltype.scoped_alloc(rffi.CCHARPP.TO, 1) as out_ptr:
 with lltype.scoped_alloc(rffi.UINTP.TO, 1) as len_ptr:
 libssl_SSL_get0_next_proto_negotiated(self.ssl,
diff --git a/pypy/module/_ssl/interp_win32.py b/pypy/module/_ssl/interp_win32.py
--- a/pypy/module/_ssl/interp_win32.py
+++ b/pypy/module/_ssl/interp_win32.py
@@ -4,7 +4,7 @@
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from pypy.interpreter.gateway import unwrap_spec
 from pypy.interpreter.error import wrap_windowserror
-
+from rpython.rlib.rarithmetic import intmask, widen
 eci = ExternalCompilationInfo(
 includes = ['windows.h', 'wincrypt.h'],
 libraries = ['crypt32'],
@@ -15,6 +15,9 @@
 
 X509_ASN_ENCODING = rffi_platform.ConstantInteger('X509_ASN_ENCODING')
 PKCS_7_ASN_ENCODING = rffi_platform.ConstantInteger('PKCS_7_ASN_ENCODING')
+CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG = 
rffi_platform.ConstantInteger('CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG')
+CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG = 
rffi_platform.ConstantInteger('CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG')
+CRYPT_E_NOT_FOUND = rffi_platform.ConstantInteger('CRYPT_E_NOT_FOUND')
 
 CERT_ENHKEY_USAGE = rffi_platform.Struct(
 'CERT_ENHKEY_USAGE', [('cUsageIdentifier', rwin32.DWORD),
@@ -38,6 +41,7 @@
 def external(name, argtypes, restype, **kw):
 kw['compilation_info'] = eci
 kw['calling_conv'] = 'win'
+kw['save_err'] = rffi.RFFI_SAVE_LASTERROR
 return rffi.llexternal(
 name, argtypes, restype, **kw)
 
@@ -69,22 +73,22 @@
 return space.wrap(encodingType)
 
 def w_parseKeyUsage(space, pCertCtx, flags):
-with rffi.scoped_alloc(rwin32.LPDWORD.TO, 1) as size_ptr:
+with lltype.scoped_alloc(rwin32.LPDWORD.TO, 1) as size_ptr:
 if not CertGetEnhancedKeyUsage(pCertCtx, flags, None, size_ptr):
 last_error = rwin32.lastSavedWindowsError()
-if last_error == CRYPT_E_NOT_FOUND:
+if last_error.errno == CRYPT_E_NOT_FOUND:
 return space.w_True
-raise wrap_windowserror(WindowsError(last_error))
+raise wrap_windowserror(space, last_error)
 
-size = rffi.widen(size_ptr[0])
-with rffi.scoped_alloc(rffi.CCHARP.TO, size) as buf:
+size = widen(size_ptr[0])
+with lltype.scoped_alloc(rffi.CCHARP.TO, size) as buf:
 usage = rffi.cast(PCERT_ENHKEY_USAGE, buf)
 # Now get the actual enhanced usage property
 if not CertGetEnhancedKeyUsage(pCertCtx, flags, usage, size_ptr):
-last_error = rwin32.lastSavedWindowsError()
-if last_error == CRYPT_E_NOT_FOUND:
+last_error= rwin32.lastSavedWindowsError()
+if last_error.errno == CRYPT_E_NOT_FOUND:
 return space.w_True
-raise wrap_windowserror(WindowsError(last_error))
+raise wrap_windowserror(space, last_error)
 
 result_w = []
 for i in range(usage.c_cUsageIdentifier):
@@ -93,7 +97,7 @@
 result_w.append(
 space.wrap(rffi.charp2str(
 usage.c_rgpszUsageIdentifier[i])))
-return space.newset(result_w)
+return space.newlist(result_w) #space.newset(result_w)
 
 @unwrap_spec(store_name=str)
 def enum_certificates_w(space, store_name):
@@ -107,10 +111,10 @@
 boolean True."""
 
 result_w = []
-pCertCtx = lltype.nullptr(PCCERT_CONTEXT)
+pCertCtx = lltype.nullptr(CERT_CONTEXT)
 hStore = CertOpenSystemStore(None, store_name)
 if not hStore:
-raise wrap_windowserror(rwin32.lastSavedWindowsError())
+raise wrap_windowserror(space, rwin32.lastSavedWindowsError())
 try:
 while True:
 pCertCtx = CertEnumCertificatesInStore(hStore, pCertCtx)
@@ -118,7 +122,7 @@
 break
 w_cert = space.wrapbytes(
 rffi.charpsize2str(pCertCtx.c_pbCertEncoded,
-   pCertCtx.c_cbCertEncoded))
+   intmask(pCertCtx.c_cbCertEncoded)))
 w_enc = w_certEncodingType(space, pCertCtx.c_dwCertEncodingType)
 w_keyusage = w_parseKeyUsage(
 space, pCertCtx, CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG)
@@ -126,13 +130,15 @@
 

[pypy-commit] pypy stdlib-2.7.9: typo

2015-02-10 Thread mattip
Author: mattip 
Branch: stdlib-2.7.9
Changeset: r75816:cbe8c24dac40
Date: 2015-02-10 20:23 +0200
http://bitbucket.org/pypy/pypy/changeset/cbe8c24dac40/

Log:typo

diff --git a/pypy/module/_ssl/interp_win32.py b/pypy/module/_ssl/interp_win32.py
--- a/pypy/module/_ssl/interp_win32.py
+++ b/pypy/module/_ssl/interp_win32.py
@@ -159,7 +159,7 @@
 rffi.charpsize2str(pCrlCtx.c_pbCrlEncoded,
pCrlCtx.c_cbCrlEncoded))
 w_enc = w_certEncodingType(space, pCrlCtx.c_dwCertEncodingType)
-result_w.append(space.newtuple([w_cert, w_enc]))
+result_w.append(space.newtuple([w_crl, w_enc]))
 finally:
 if pCrlCtx:
 # loop ended with an error, need to clean up context manually
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stdlib-2.7.9: avoid modifying caller's args

2015-02-10 Thread mattip
Author: mattip 
Branch: stdlib-2.7.9
Changeset: r75817:6e439976f4a6
Date: 2015-02-10 20:55 +0200
http://bitbucket.org/pypy/pypy/changeset/6e439976f4a6/

Log:avoid modifying caller's args

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
@@ -196,7 +196,7 @@
 # So please be careful with the order of parameters! ;-)
 pdb_dir = oname.dirname
 if pdb_dir:
-compile_args += ['/Fd%s\\' % (pdb_dir,)]
+compile_args = compile_args + ['/Fd%s\\' % (pdb_dir,)]
 args = ['/nologo', '/c'] + compile_args + ['/Fo%s' % (oname,), 
str(cfile)]
 self._execute_c_compiler(cc, args, oname)
 return oname
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] buildbot issue-1759: allow valid slave names in slaveinfo.py even if debugging

2015-02-10 Thread mattip
Author: mattip 
Branch: issue-1759
Changeset: r925:306d94b288c6
Date: 2015-02-09 20:05 +0200
http://bitbucket.org/pypy/buildbot/changeset/306d94b288c6/

Log:allow valid slave names in slaveinfo.py even if debugging

diff --git a/master/master.cfg b/master/master.cfg
--- a/master/master.cfg
+++ b/master/master.cfg
@@ -23,5 +23,9 @@
 
 if we_are_debugging():
 for builderdict in BuildmasterConfig['builders']:
-builderdict["slavenames"] = ['localhost']
+valid_slaves = ['localhost']
+for s in builderdict['slavenames']:
+if s in slaveinfo.passwords:
+valid_slaves.append(s)
+builderdict["slavenames"] = valid_slaves
 BuildmasterConfig['buildbotURL'] = "http://localhost:%d/"; % 
(httpPortNumber)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] buildbot issue-1759: make dual numpy targets work

2015-02-10 Thread mattip
Author: mattip 
Branch: issue-1759
Changeset: r929:158e6b7e5482
Date: 2015-02-10 21:49 +0200
http://bitbucket.org/pypy/buildbot/changeset/158e6b7e5482/

Log:make dual numpy targets work

diff --git a/bot2/pypybuildbot/builds.py b/bot2/pypybuildbot/builds.py
--- a/bot2/pypybuildbot/builds.py
+++ b/bot2/pypybuildbot/builds.py
@@ -843,7 +843,6 @@
 '''
 def __init__(self, platform='linux',
  app_tests=False,
- host = 'tannit',
  lib_python=False,
  pypyjit=True,
  prefix=None,
@@ -854,9 +853,18 @@
 self.addStep(ParseRevision(hideStepIf=ParseRevision.hideStepIf,
   doStepIf=ParseRevision.doStepIf))
 # download corresponding nightly build
+if platform == 'win32':
+target = r'pypy-c\pypy.exe'
+untar = ['unzip']
+sep = '\\'
+else:
+target = r'pypy-c/bin/pypy'
+untar = ['tar', '--strip-components=1', '--directory=.', '-xf']
+sep = '/'
 self.addStep(ShellCmd(
-description="Clear pypy-c",
-command=['rm', '-rf', 'pypy-c'],
+description="Clear",
+# assume, as part of git, that windows has rm
+command=['rm', '-rf', 'pypy-c', 'install'],
 workdir='.'))
 extension = get_extension(platform)
 name = build_name(platform, pypyjit, translationArgs, 
placeholder='%(final_file_name)s') + extension
@@ -867,12 +875,17 @@
 workdir='pypy-c'))
 
 # extract downloaded file
-if platform.startswith('win'):
-raise NotImplementedError
-else:
+self.addStep(ShellCmd(
+description="decompress pypy-c",
+command=untar + ['pypy_build'+ extension],
+workdir='pypy-c',
+haltOnFailure=True,
+))
+
+if platform == 'win32':
 self.addStep(ShellCmd(
-description="decompress pypy-c",
-command=['tar', '--extract', '--file=pypy_build'+ extension, 
'--strip-components=1', '--directory=.'],
+description='move decomporessed dir',
+command = ['mv', '*/*', '.'],
 workdir='pypy-c',
 haltOnFailure=True,
 ))
@@ -880,21 +893,21 @@
 # virtualenv the download
 self.addStep(ShellCmd(
 description="create virtualenv",
-command=['virtualenv','-p', 'pypy-c/bin/pypy', 'install'],
+command=['virtualenv','-p', target, 'install'],
 workdir='./',
 haltOnFailure=True,
 ))
 
 self.addStep(ShellCmd(
 description="report version",
-command=['install/bin/pypy', '--version'],
+command=[sep.join(['install','bin','pypy'])] + ['--version'],
 workdir='./',
 haltOnFailure=True,
 ))
 
 self.addStep(ShellCmd(
 description="install nose",
-command=['install/bin/pip', 'install','nose'],
+command=[sep.join(['install','bin','pip'])] + ['install','nose'],
 workdir='./',
 haltOnFailure=True,
 ))
@@ -905,19 +918,20 @@
 
 self.addStep(ShellCmd(
 description="install numpy",
-command=['../install/bin/python', 'setup.py','install'],
+command=[sep.join(['..', 'install', 'bin', 'pypy'])] + 
['setup.py','install'],
 workdir='numpy_src'))
 
 self.addStep(ShellCmd(
 description="test numpy",
-command=['bin/nosetests', 'site-packages/numpy',
+command=[sep.join(['bin', 'nosetests'])] + ['site-packages/numpy',
+# XXX enable '-with-doctest',
 ],
 #logfiles={'pytestLog': 'pytest-numpy.log'},
 timeout=4000,
 workdir='install',
 #env={"PYTHONPATH": ['download']}, # shouldn't be needed, but what 
if it is set externally?
 ))
-if host == 'tannit':
+if platform != 'win32':
 self.addStep(ShellCmd(
 description="install jinja2",
 command=['install/bin/pip', 'install', 'jinja2'],
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] buildbot issue-1759: platform and host attributes are not magic, this probably was a bug in the configuration

2015-02-10 Thread mattip
Author: mattip 
Branch: issue-1759
Changeset: r928:766b7373be46
Date: 2015-02-10 20:47 +0200
http://bitbucket.org/pypy/buildbot/changeset/766b7373be46/

Log:platform and host attributes are not magic, this probably was a bug
in the configuration

diff --git a/bot2/pypybuildbot/master.py b/bot2/pypybuildbot/master.py
--- a/bot2/pypybuildbot/master.py
+++ b/bot2/pypybuildbot/master.py
@@ -146,14 +146,17 @@
 app_tests=True,
 )
 
-pypyJITBenchmarkFactory_tannit = pypybuilds.JITBenchmark()
+pypyJITBenchmarkFactory_tannit = pypybuilds.JITBenchmark(host='tannit')
 pypyJITBenchmarkFactory64_tannit = pypybuilds.JITBenchmark(platform='linux64',
+   host='tannit',
postfix='-64')
 pypyJITBenchmarkFactory64_speed = pypybuilds.JITBenchmarkSingleRun(
 platform='linux64',
+host='speed_python',
 postfix='-64')
 
 pypyNumpyCompatability = pypybuilds.NativeNumpyTests(platform='linux64')
+pypyNumpyCompatabilityWin = pypybuilds.NativeNumpyTests(platform='win32')
 
 #
 
@@ -477,7 +480,7 @@
   {'name': NUMPY_WIN,
'slavenames': ["allegro_win32", "SalsaSalsa"],
'builddir': NUMPY_WIN,
-   'factory': pypyNumpyCompatability,
+   'factory': pypyNumpyCompatabilityWin,
"locks": [WinSlaveLock.access('counting')],
'category': 'numpy',
   },
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] buildbot issue-1759: move numpy testing to a triggerable build, add win32 target as well

2015-02-10 Thread mattip
Author: mattip 
Branch: issue-1759
Changeset: r927:caa856444a44
Date: 2015-02-10 18:52 +0200
http://bitbucket.org/pypy/buildbot/changeset/caa856444a44/

Log:move numpy testing to a triggerable build, add win32 target as well

diff --git a/bot2/pypybuildbot/builds.py b/bot2/pypybuildbot/builds.py
--- a/bot2/pypybuildbot/builds.py
+++ b/bot2/pypybuildbot/builds.py
@@ -326,14 +326,14 @@
 workdir=workdir,
 logEnviron=False))
 
-def update_git(platform, factory, repourl, workdir, use_branch,
-  force_branch=None):
+def update_git(platform, factory, repourl, workdir, branch='master'):
 factory.addStep(
 Git(
 repourl=repourl,
 mode='full',
 method='fresh',
 workdir=workdir,
+branch=branch,
 logEnviron=False))
 
 def setup_steps(platform, factory, workdir=None,
@@ -473,7 +473,8 @@
  interpreter='pypy',
  lib_python=False,
  pypyjit=False,
- prefix=None
+ prefix=None,
+ trigger=None,
  ):
 factory.BuildFactory.__init__(self)
 if prefix is not None:
@@ -502,6 +503,9 @@
 workdir='.',
 blocksize=100 * 1024))
 
+if trigger: # if provided trigger schedulers that depend on this one
+self.addStep(Trigger(schedulerNames=[trigger]))
+
 add_translated_tests(self, prefix, platform, app_tests, lib_python, 
pypyjit)
 
 
@@ -882,6 +886,13 @@
 ))
 
 self.addStep(ShellCmd(
+description="report version",
+command=['install/bin/pypy', '--version'],
+workdir='./',
+haltOnFailure=True,
+))
+
+self.addStep(ShellCmd(
 description="install nose",
 command=['install/bin/pip', 'install','nose'],
 workdir='./',
@@ -890,9 +901,7 @@
 
 # obtain a pypy-compatible branch of numpy
 numpy_url = 'https://www.bitbucket.org/pypy/numpy'
-numpy_pypy_branch = 'pypy-compat'
-update_git(platform, self, numpy_url, 'numpy_src', use_branch=True,
-  force_branch=numpy_pypy_branch)
+update_git(platform, self, numpy_url, 'numpy_src', branch='master')
 
 self.addStep(ShellCmd(
 description="install numpy",
diff --git a/bot2/pypybuildbot/master.py b/bot2/pypybuildbot/master.py
--- a/bot2/pypybuildbot/master.py
+++ b/bot2/pypybuildbot/master.py
@@ -1,6 +1,6 @@
 
 import os
-from buildbot.scheduler import Nightly
+from buildbot.scheduler import Nightly, Triggerable
 from buildbot.schedulers.forcesched import ForceScheduler
 from buildbot.schedulers.forcesched import ValidationError
 from buildbot.buildslave import BuildSlave
@@ -96,6 +96,7 @@
 pypyjit=True,
 app_tests=True,
 platform='linux64',
+trigger='NUMPY64_scheduler',
 )
 
 pypyJITTranslatedTestFactoryIndiana = pypybuilds.Translated(
@@ -133,6 +134,7 @@
 lib_python=True,
 pypyjit=True,
 app_tests=True,
+trigger='NUMPYWIN_scheduler',
 )
 
 pypyJITTranslatedTestFactoryFreeBSD = pypybuilds.Translated(
@@ -186,6 +188,7 @@
 JITBENCH64_NEW = 'jit-benchmark-linux-x86-64-single-run'
 CPYTHON_64 = "cpython-2-benchmark-x86-64"
 NUMPY_64 = "numpy-compatability-linux-x86-64"
+NUMPY_WIN = "numpy-compatability-win-x86-32"
 # buildbot builder
 PYPYBUILDBOT = 'pypy-buildbot'
 
@@ -216,8 +219,8 @@
 APPLVLLINUX64, # on allegro64, uses 1 core
 # other platforms
 #MACOSX32, # on minime
-JITWIN32,  # on aurora, SalsaSalsa
-WIN32, # on aurora, SalsaSalsa
+JITWIN32,  # on allegro_win32, SalsaSalsa
+WIN32, # on allegro_win32, SalsaSalsa
 #JITFREEBSD764,# on headless
 #JITFREEBSD864,# on ananke
 JITFREEBSD964, # on tavendo
@@ -227,14 +230,20 @@
 ], branch='default', hour=0, minute=0),
 
 Nightly("nightly-1-00", [
-NUMPY_64,  # on tannit64, uses 1 core, takes about 
15min.
-   # XXX maybe use a trigger instead?
 JITBENCH,  # on tannit32, uses 1 core (in part 
exclusively)
 JITBENCH64,# on tannit64, uses 1 core (in part 
exclusively)
 JITBENCH64_NEW,# on speed64, uses 1 core (in part 
exclusively)
 
 ], branch=None, hour=1, minute=0),
 
+Triggerable("NUMPY64_scheduler", [
+NUMPY_64,  # on tannit64, uses 1 core, takes about 
15min.
+]),
+
+Triggerable("NUMPYWIN_scheduler", [
+NUMPY_WIN,  # on allegro_win32, SalsaSalsa
+]),
+

[pypy-commit] buildbot issue-1759: unused import

2015-02-10 Thread mattip
Author: mattip 
Branch: issue-1759
Changeset: r926:6f2c2f52bd05
Date: 2015-02-09 20:06 +0200
http://bitbucket.org/pypy/buildbot/changeset/6f2c2f52bd05/

Log:unused import

diff --git a/bot2/pypybuildbot/arm_master.py b/bot2/pypybuildbot/arm_master.py
--- a/bot2/pypybuildbot/arm_master.py
+++ b/bot2/pypybuildbot/arm_master.py
@@ -1,5 +1,5 @@
 from buildbot.scheduler import Nightly, Triggerable
-from pypybuildbot.util import we_are_debugging, load
+from pypybuildbot.util import load
 
 pypybuilds = load('pypybuildbot.builds')
 ARMCrossLock = pypybuilds.ARMCrossLock
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stdlib-2.7.9: Add newset() to the FakeObjSpace, to fix test_ztranslation

2015-02-10 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: stdlib-2.7.9
Changeset: r75819:6e6e94392240
Date: 2015-02-10 23:11 +0100
http://bitbucket.org/pypy/pypy/changeset/6e6e94392240/

Log:Add newset() to the FakeObjSpace, to fix test_ztranslation

diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -145,6 +145,12 @@
 is_root(w_x)
 return w_some_obj()
 
+def newset(self, list_w=None):
+if list_w is not None:
+for w_x in list_w:
+is_root(w_x)
+return w_some_obj()
+
 def newlist(self, list_w):
 for w_x in list_w:
 is_root(w_x)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stdlib-2.7.9: Try space.newset() again

2015-02-10 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: stdlib-2.7.9
Changeset: r75820:30bb6fb168fa
Date: 2015-02-10 23:12 +0100
http://bitbucket.org/pypy/pypy/changeset/30bb6fb168fa/

Log:Try space.newset() again

diff --git a/pypy/module/_ssl/interp_win32.py b/pypy/module/_ssl/interp_win32.py
--- a/pypy/module/_ssl/interp_win32.py
+++ b/pypy/module/_ssl/interp_win32.py
@@ -97,7 +97,7 @@
 result_w.append(
 space.wrap(rffi.charp2str(
 usage.c_rgpszUsageIdentifier[i])))
-return space.newlist(result_w) #space.newset(result_w)
+return space.newset(result_w)
 
 @unwrap_spec(store_name=str)
 def enum_certificates_w(space, store_name):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stdlib-2.7.9: Use intmask() instead of widen(), the original is unsigned.

2015-02-10 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: stdlib-2.7.9
Changeset: r75822:43c604f7b364
Date: 2015-02-10 23:19 +0100
http://bitbucket.org/pypy/pypy/changeset/43c604f7b364/

Log:Use intmask() instead of widen(), the original is unsigned.

diff --git a/pypy/module/_ssl/interp_win32.py b/pypy/module/_ssl/interp_win32.py
--- a/pypy/module/_ssl/interp_win32.py
+++ b/pypy/module/_ssl/interp_win32.py
@@ -4,7 +4,7 @@
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from pypy.interpreter.gateway import unwrap_spec
 from pypy.interpreter.error import wrap_windowserror
-from rpython.rlib.rarithmetic import intmask, widen
+from rpython.rlib.rarithmetic import intmask
 eci = ExternalCompilationInfo(
 includes = ['windows.h', 'wincrypt.h'],
 libraries = ['crypt32'],
@@ -80,7 +80,7 @@
 return space.w_True
 raise wrap_windowserror(space, last_error)
 
-size = widen(size_ptr[0])
+size = intmask(size_ptr[0])
 with lltype.scoped_alloc(rffi.CCHARP.TO, size) as buf:
 usage = rffi.cast(PCERT_ENHKEY_USAGE, buf)
 # Now get the actual enhanced usage property
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stdlib-2.7.9: Looks like RPython WindowsError instances only have winerror.

2015-02-10 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: stdlib-2.7.9
Changeset: r75821:b2e29ad07409
Date: 2015-02-10 23:18 +0100
http://bitbucket.org/pypy/pypy/changeset/b2e29ad07409/

Log:Looks like RPython WindowsError instances only have winerror.

diff --git a/pypy/module/_ssl/interp_win32.py b/pypy/module/_ssl/interp_win32.py
--- a/pypy/module/_ssl/interp_win32.py
+++ b/pypy/module/_ssl/interp_win32.py
@@ -76,7 +76,7 @@
 with lltype.scoped_alloc(rwin32.LPDWORD.TO, 1) as size_ptr:
 if not CertGetEnhancedKeyUsage(pCertCtx, flags, None, size_ptr):
 last_error = rwin32.lastSavedWindowsError()
-if last_error.errno == CRYPT_E_NOT_FOUND:
+if last_error.winerror == CRYPT_E_NOT_FOUND:
 return space.w_True
 raise wrap_windowserror(space, last_error)
 
@@ -86,7 +86,7 @@
 # Now get the actual enhanced usage property
 if not CertGetEnhancedKeyUsage(pCertCtx, flags, usage, size_ptr):
 last_error= rwin32.lastSavedWindowsError()
-if last_error.errno == CRYPT_E_NOT_FOUND:
+if last_error.winerror == CRYPT_E_NOT_FOUND:
 return space.w_True
 raise wrap_windowserror(space, last_error)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: Need to decode keys before calling newlist_unicode.

2015-02-10 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: py3k
Changeset: r75823:b46622fb88b7
Date: 2015-02-10 23:00 +0100
http://bitbucket.org/pypy/pypy/changeset/b46622fb88b7/

Log:Need to decode keys before calling newlist_unicode.

diff --git a/pypy/objspace/std/celldict.py b/pypy/objspace/std/celldict.py
--- a/pypy/objspace/std/celldict.py
+++ b/pypy/objspace/std/celldict.py
@@ -122,8 +122,8 @@
 
 def w_keys(self, w_dict):
 space = self.space
-l = self.unerase(w_dict.dstorage).keys()
-return space.newlist_unicode(l)
+keys = self.unerase(w_dict.dstorage).keys()
+return space.newlist_unicode([key.decode('utf-8') for key in keys])
 
 def values(self, w_dict):
 iterator = self.unerase(w_dict.dstorage).itervalues
diff --git a/pypy/objspace/std/kwargsdict.py b/pypy/objspace/std/kwargsdict.py
--- a/pypy/objspace/std/kwargsdict.py
+++ b/pypy/objspace/std/kwargsdict.py
@@ -115,8 +115,9 @@
 return w_dict.getitem(w_key)
 
 def w_keys(self, w_dict):
-l = self.unerase(w_dict.dstorage)[0]
-return self.space.newlist_unicode(l[:])
+space = self.space
+keys = self.unerase(w_dict.dstorage)[0]
+return space.newlist_unicode([key.decode('utf-8') for key in keys])
 
 def values(self, w_dict):
 return self.unerase(w_dict.dstorage)[1][:] # to make non-resizable
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stdlib-2.7.9: Avoid resizing the list passed to space.newset()

2015-02-10 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: stdlib-2.7.9
Changeset: r75824:ee0c5e8894ed
Date: 2015-02-10 23:40 +0100
http://bitbucket.org/pypy/pypy/changeset/ee0c5e8894ed/

Log:Avoid resizing the list passed to space.newset()

diff --git a/pypy/module/_ssl/interp_win32.py b/pypy/module/_ssl/interp_win32.py
--- a/pypy/module/_ssl/interp_win32.py
+++ b/pypy/module/_ssl/interp_win32.py
@@ -90,13 +90,12 @@
 return space.w_True
 raise wrap_windowserror(space, last_error)
 
-result_w = []
+result_w = [None] * usage.c_cUsageIdentifier
 for i in range(usage.c_cUsageIdentifier):
 if not usage.c_rgpszUsageIdentifier[i]:
 continue
-result_w.append(
-space.wrap(rffi.charp2str(
-usage.c_rgpszUsageIdentifier[i])))
+result_w[i] = space.wrap(rffi.charp2str(
+usage.c_rgpszUsageIdentifier[i]))
 return space.newset(result_w)
 
 @unwrap_spec(store_name=str)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit