[pypy-commit] pypy default: Hack around a FreeBSD issue

2013-11-18 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r68200:afb227c80804
Date: 2013-11-18 09:28 +0100
http://bitbucket.org/pypy/pypy/changeset/afb227c80804/

Log:Hack around a FreeBSD issue

diff --git a/rpython/rlib/rdynload.py b/rpython/rlib/rdynload.py
--- a/rpython/rlib/rdynload.py
+++ b/rpython/rlib/rdynload.py
@@ -4,6 +4,7 @@
 from rpython.rtyper.tool import rffi_platform
 from rpython.rtyper.lltypesystem import rffi
 from rpython.rlib.rarithmetic import r_uint
+from rpython.rlib.objectmodel import we_are_translated
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from rpython.translator.platform import platform
 
@@ -79,6 +80,38 @@
 RTLD_NOW = cConfig.RTLD_NOW
 RTLD_LAZY = cConfig.RTLD_LAZY
 
+_t_opened = {}
+
+def t_dlopen(name):
+# for direct execution: can't use the regular way on FreeBSD :-(
+# 
http://factor-language.blogspot.de/2009/02/note-about-libdl-functions-on-netbsd.html
+import ctypes
+if name:
+name = rffi.charp2str(name)
+else:
+name = None
+try:
+res = ctypes.cdll.LoadLibrary(name)
+except OSError, e:
+raise DLOpenError(str(e))
+h = rffi.cast(rffi.VOIDP, res._handle)
+_t_opened[rffi.cast(rffi.LONG, h)] = res
+return h
+
+def t_dlclose(handle):
+_t_opened.pop(rffi.cast(rffi.LONG, handle))
+return rffi.cast(rffi.INT, 0)
+
+def t_dldym(handle, name):
+import ctypes
+lib = _t_opened[rffi.cast(rffi.LONG, handle)]
+try:
+symbol = lib[name]
+except AttributeError:
+raise KeyError(name)
+res = ctypes.cast(symbol, ctypes.c_void_p)
+return rffi.cast(rffi.VOIDP, res.value or 0)
+
 def dlerror():
 # XXX this would never work on top of ll2ctypes, because
 # ctypes are calling dlerror itself, unsure if I can do much in this
@@ -91,6 +124,8 @@
 def dlopen(name, mode=-1):
  Wrapper around C-level dlopen
 
+if not we_are_translated():
+return t_dlopen(name)
 if mode == -1:
 if RTLD_LOCAL is not None:
 mode = RTLD_LOCAL
@@ -104,11 +139,16 @@
 raise DLOpenError(err)
 return res
 
-dlclose = c_dlclose
+def dlclose(handle):
+if not we_are_translated():
+return t_dlclose(handle)
+return c_dlclose(handle)
 
 def dlsym(libhandle, name):
  Wrapper around C-level dlsym
 
+if not we_are_translated():
+return t_dldym(libhandle, name)
 res = c_dlsym(libhandle, name)
 if not res:
 raise KeyError(name)
diff --git a/rpython/rlib/test/test_rdynload.py 
b/rpython/rlib/test/test_rdynload.py
--- a/rpython/rlib/test/test_rdynload.py
+++ b/rpython/rlib/test/test_rdynload.py
@@ -21,3 +21,4 @@
lltype.Signed)), dlsym(lib, 'abs'))
 assert 1 == handle(1)
 assert 1 == handle(-1)
+dlclose(lib)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy stmgc-c4: after a transaction break, we need to check for invalidation again

2013-11-18 Thread Raemi
Author: Remi Meier remi.me...@gmail.com
Branch: stmgc-c4
Changeset: r68199:4fb6c8277d6c
Date: 2013-11-18 09:28 +0100
http://bitbucket.org/pypy/pypy/changeset/4fb6c8277d6c/

Log:after a transaction break, we need to check for invalidation again

diff --git a/rpython/jit/metainterp/optimizeopt/heap.py 
b/rpython/jit/metainterp/optimizeopt/heap.py
--- a/rpython/jit/metainterp/optimizeopt/heap.py
+++ b/rpython/jit/metainterp/optimizeopt/heap.py
@@ -262,12 +262,14 @@
 opnum == rop.COPYSTRCONTENT or   # no effect on GC struct/array
 opnum == rop.COPYUNICODECONTENT):# no effect on GC struct/array
 return
+if (opnum == rop.STM_TRANSACTION_BREAK or
+opnum == rop.CALL_ASSEMBLER):
+self._seen_guard_not_invalidated = False
 if (opnum == rop.CALL or
 opnum == rop.CALL_PURE or
 opnum == rop.COND_CALL or
 opnum == rop.CALL_MAY_FORCE or
-opnum == rop.CALL_RELEASE_GIL or
-opnum == rop.CALL_ASSEMBLER):
+opnum == rop.CALL_RELEASE_GIL):
 if opnum == rop.CALL_ASSEMBLER:
 self._seen_guard_not_invalidated = False
 else:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix the test.

2013-11-18 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r68201:c4dd095a23ea
Date: 2013-11-18 09:37 +0100
http://bitbucket.org/pypy/pypy/changeset/c4dd095a23ea/

Log:Fix the test.

diff --git a/rpython/jit/backend/x86/test/test_ztranslation_basic.py 
b/rpython/jit/backend/x86/test/test_ztranslation_basic.py
--- a/rpython/jit/backend/x86/test/test_ztranslation_basic.py
+++ b/rpython/jit/backend/x86/test/test_ztranslation_basic.py
@@ -1,11 +1,11 @@
 from rpython.jit.backend.llsupport.test.ztranslation_test import 
TranslationTest
-from rpython.translator.translator import TranslationContext
-from rpython.config.translationoption import DEFL_GC
+from rpython.jit.backend.x86.arch import WORD
 
 
 class TestTranslationX86(TranslationTest):
 def _check_cbuilder(self, cbuilder):
 # We assume here that we have sse2.  If not, the CPUClass
 # needs to be changed to CPU386_NO_SSE2, but well.
-assert '-msse2' in cbuilder.eci.compile_extra
-assert '-mfpmath=sse' in cbuilder.eci.compile_extra
+if WORD == 4:
+assert '-msse2' in cbuilder.eci.compile_extra
+assert '-mfpmath=sse' in cbuilder.eci.compile_extra
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] stmgc default: fix some debug assert

2013-11-18 Thread Raemi
Author: Remi Meier remi.me...@gmail.com
Branch: 
Changeset: r547:3d0358c80701
Date: 2013-11-08 15:28 +0100
http://bitbucket.org/pypy/stmgc/changeset/3d0358c80701/

Log:fix some debug assert

diff --git a/c4/nursery.c b/c4/nursery.c
--- a/c4/nursery.c
+++ b/c4/nursery.c
@@ -84,7 +84,7 @@
 }
 #ifdef _GC_DEBUG
 if (P != NULL) {
-assert(P-h_tid != 0);
+assert((P-h_tid  STM_USER_TID_MASK) == (tid  STM_USER_TID_MASK));
 assert_cleared(((char *)P) + sizeof(revision_t),
size - sizeof(revision_t));
 }
diff --git a/c4/stmgc.h b/c4/stmgc.h
--- a/c4/stmgc.h
+++ b/c4/stmgc.h
@@ -38,7 +38,7 @@
 
 /* allocates a public reference to the object that will 
not be freed until stm_unregister_integer_address is 
-   called on the result */
+   called on the result (push roots!) */
 intptr_t stm_allocate_public_integer_address(gcptr);
 void stm_unregister_integer_address(intptr_t);
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] stmgc default: fix public ints (usage of public h_originals is not always right, they

2013-11-18 Thread Raemi
Author: Remi Meier remi.me...@gmail.com
Branch: 
Changeset: r548:68677625f2be
Date: 2013-11-18 11:19 +0100
http://bitbucket.org/pypy/stmgc/changeset/68677625f2be/

Log:fix public ints (usage of public h_originals is not always right,
they need to be PREBUILT_ORIGINALs to be sure...)

diff --git a/c4/demo_random.c b/c4/demo_random.c
--- a/c4/demo_random.c
+++ b/c4/demo_random.c
@@ -278,8 +278,7 @@
 gcptr obj = (gcptr)ip;
 assert(obj-h_tid  GCFLAG_PUBLIC);
 assert((obj-h_tid  GCFLAG_SMALLSTUB)
-   || (obj-h_original == 0 
-   || obj-h_tid  GCFLAG_PREBUILT_ORIGINAL));
+   || (obj-h_tid  GCFLAG_PREBUILT_ORIGINAL));
 check(obj);
 if (obj-h_revision  2)
 check((gcptr)(obj-h_revision - 2));
@@ -304,7 +303,9 @@
 if (td.num_public_ints == 0)
 return;
 
+push_roots();
 stm_unregister_integer_address(td.public_ints[--td.num_public_ints]);
+pop_roots();
 }
 
 gcptr read_barrier(gcptr p)
diff --git a/c4/et.c b/c4/et.c
--- a/c4/et.c
+++ b/c4/et.c
@@ -138,6 +138,7 @@
 
   d-count_reads++;
   assert(IMPLIES(!(P-h_tid  GCFLAG_OLD), stmgc_is_in_nursery(d, P)));
+  assert(G-h_revision != 0);
 
  restart_all:
   if (P-h_tid  GCFLAG_PRIVATE_FROM_PROTECTED)
@@ -355,7 +356,7 @@
   assert(P-h_tid  GCFLAG_PUBLIC);
   assert(IMPLIES(!(P-h_tid  GCFLAG_OLD), 
  stmgc_is_in_nursery(thread_descriptor, P)));
-
+  assert(P-h_revision != 0);
 
   revision_t v = ACCESS_ONCE(P-h_revision);
   assert(IS_POINTER(v));  /* is a pointer, has a more recent revision */
@@ -660,6 +661,7 @@
 
 gcptr stm_RepeatWriteBarrier(gcptr P)
 {
+  assert(P-h_revision != 0);
   assert(IMPLIES(!(P-h_tid  GCFLAG_OLD), 
  stmgc_is_in_nursery(thread_descriptor, P)));
 
@@ -673,6 +675,7 @@
 
 gcptr stm_WriteBarrier(gcptr P)
 {
+  assert(P-h_revision != 0);
   assert(!(P-h_tid  GCFLAG_IMMUTABLE));
   assert((P-h_tid  GCFLAG_STUB) ||
  stmgc_size(P)  sizeof(struct stm_stub_s) - WORD);
diff --git a/c4/extra.c b/c4/extra.c
--- a/c4/extra.c
+++ b/c4/extra.c
@@ -65,7 +65,7 @@
 
 
 intptr_t stm_allocate_public_integer_address(gcptr obj)
-{
+{   /* push roots! */
 struct tx_descriptor *d = thread_descriptor;
 gcptr stub;
 intptr_t result;
@@ -75,6 +75,12 @@
During major collections, we visit them and update
their references. */
 
+/* stm_register_integer_address needs to run in inevitable
+   transaction */
+stm_push_root(obj);
+stm_become_inevitable(stm_allocate_public_integer_address);
+obj = stm_pop_root();
+
 /* we don't want to deal with young objs */
 if (!(obj-h_tid  GCFLAG_OLD)) {
 stm_push_root(obj);
@@ -93,9 +99,11 @@
 orig = (gcptr)obj-h_original;
 }
 
-if (orig-h_tid  GCFLAG_PUBLIC) {
-/* the original is public, so we can take that as a non-movable
- object to register */
+if ((orig-h_tid  (GCFLAG_PUBLIC | GCFLAG_PREBUILT_ORIGINAL))
+== (GCFLAG_PUBLIC | GCFLAG_PREBUILT_ORIGINAL)) {
+/* public is not enough as public stubs may get replaced
+   by the protected object they point to, if they are in the 
+   same thread (I think...) */
 result = (intptr_t)orig;
 }
 else {
@@ -115,9 +123,11 @@
 result = (intptr_t)stub;
 }
 spinlock_release(d-public_descriptor-collection_lock);
+
+dprintf((allocate_public_int_adr(%p): %p, obj, (void*)result));
+
 stm_register_integer_address(result);
 
-dprintf((allocate_public_int_adr(%p): %p, obj, (void*)result));
 return result;
 }
 
diff --git a/c4/gcpage.c b/c4/gcpage.c
--- a/c4/gcpage.c
+++ b/c4/gcpage.c
@@ -218,10 +218,11 @@
 /* registering of small stubs as integer addresses */
 
 void stm_register_integer_address(intptr_t adr)
-{
+{   /* needs to be inevitable! */
 wlog_t *found;
 gcptr obj = (gcptr)adr;
 /* current limitations for 'adr': smallstub or h_original */
+assert(stm_active == 2);
 assert((obj-h_tid  GCFLAG_SMALLSTUB)
|| (obj-h_original == 0 || obj-h_tid  GCFLAG_PREBUILT_ORIGINAL));
 assert(obj-h_tid  GCFLAG_PUBLIC);
@@ -241,7 +242,7 @@
 }
 
 void stm_unregister_integer_address(intptr_t adr)
-{
+{   /* push roots! */
 wlog_t *found;
 gcptr obj = (gcptr)adr;
 
@@ -249,6 +250,11 @@
|| (obj-h_original == 0 || obj-h_tid  GCFLAG_PREBUILT_ORIGINAL));
 assert(obj-h_tid  GCFLAG_PUBLIC);
 
+/* become inevitable because we would have to re-register them
+   on abort, but make sure only to re-register if not registered
+   in the same aborted transaction (XXX) */
+stm_become_inevitable(stm_unregister_integer_address());
+
 stmgcpage_acquire_global_lock();
 
 /* find and decrement refcount */
@@ -527,12 +533,18 @@
 G2L_LOOP_FORWARD(registered_objs, item) {
 gcptr R = item-addr;
 

[pypy-commit] pypy stmgc-c4: import stmgc

2013-11-18 Thread Raemi
Author: Remi Meier remi.me...@gmail.com
Branch: stmgc-c4
Changeset: r68202:88a0f0cc46a5
Date: 2013-11-18 11:20 +0100
http://bitbucket.org/pypy/pypy/changeset/88a0f0cc46a5/

Log:import stmgc

diff --git a/rpython/translator/stm/src_stm/et.c 
b/rpython/translator/stm/src_stm/et.c
--- a/rpython/translator/stm/src_stm/et.c
+++ b/rpython/translator/stm/src_stm/et.c
@@ -139,6 +139,7 @@
 
   d-count_reads++;
   assert(IMPLIES(!(P-h_tid  GCFLAG_OLD), stmgc_is_in_nursery(d, P)));
+  assert(G-h_revision != 0);
 
  restart_all:
   if (P-h_tid  GCFLAG_PRIVATE_FROM_PROTECTED)
@@ -356,7 +357,7 @@
   assert(P-h_tid  GCFLAG_PUBLIC);
   assert(IMPLIES(!(P-h_tid  GCFLAG_OLD), 
  stmgc_is_in_nursery(thread_descriptor, P)));
-
+  assert(P-h_revision != 0);
 
   revision_t v = ACCESS_ONCE(P-h_revision);
   assert(IS_POINTER(v));  /* is a pointer, has a more recent revision */
@@ -661,6 +662,7 @@
 
 gcptr stm_RepeatWriteBarrier(gcptr P)
 {
+  assert(P-h_revision != 0);
   assert(IMPLIES(!(P-h_tid  GCFLAG_OLD), 
  stmgc_is_in_nursery(thread_descriptor, P)));
 
@@ -674,6 +676,7 @@
 
 gcptr stm_WriteBarrier(gcptr P)
 {
+  assert(P-h_revision != 0);
   assert(!(P-h_tid  GCFLAG_IMMUTABLE));
   assert((P-h_tid  GCFLAG_STUB) ||
  stmgc_size(P)  sizeof(struct stm_stub_s) - WORD);
diff --git a/rpython/translator/stm/src_stm/extra.c 
b/rpython/translator/stm/src_stm/extra.c
--- a/rpython/translator/stm/src_stm/extra.c
+++ b/rpython/translator/stm/src_stm/extra.c
@@ -66,7 +66,7 @@
 
 
 intptr_t stm_allocate_public_integer_address(gcptr obj)
-{
+{   /* push roots! */
 struct tx_descriptor *d = thread_descriptor;
 gcptr stub;
 intptr_t result;
@@ -76,6 +76,12 @@
During major collections, we visit them and update
their references. */
 
+/* stm_register_integer_address needs to run in inevitable
+   transaction */
+stm_push_root(obj);
+stm_become_inevitable(stm_allocate_public_integer_address);
+obj = stm_pop_root();
+
 /* we don't want to deal with young objs */
 if (!(obj-h_tid  GCFLAG_OLD)) {
 stm_push_root(obj);
@@ -94,9 +100,11 @@
 orig = (gcptr)obj-h_original;
 }
 
-if (orig-h_tid  GCFLAG_PUBLIC) {
-/* the original is public, so we can take that as a non-movable
- object to register */
+if ((orig-h_tid  (GCFLAG_PUBLIC | GCFLAG_PREBUILT_ORIGINAL))
+== (GCFLAG_PUBLIC | GCFLAG_PREBUILT_ORIGINAL)) {
+/* public is not enough as public stubs may get replaced
+   by the protected object they point to, if they are in the 
+   same thread (I think...) */
 result = (intptr_t)orig;
 }
 else {
@@ -116,9 +124,11 @@
 result = (intptr_t)stub;
 }
 spinlock_release(d-public_descriptor-collection_lock);
+
+dprintf((allocate_public_int_adr(%p): %p, obj, (void*)result));
+
 stm_register_integer_address(result);
 
-dprintf((allocate_public_int_adr(%p): %p, obj, (void*)result));
 return result;
 }
 
diff --git a/rpython/translator/stm/src_stm/gcpage.c 
b/rpython/translator/stm/src_stm/gcpage.c
--- a/rpython/translator/stm/src_stm/gcpage.c
+++ b/rpython/translator/stm/src_stm/gcpage.c
@@ -219,10 +219,11 @@
 /* registering of small stubs as integer addresses */
 
 void stm_register_integer_address(intptr_t adr)
-{
+{   /* needs to be inevitable! */
 wlog_t *found;
 gcptr obj = (gcptr)adr;
 /* current limitations for 'adr': smallstub or h_original */
+assert(stm_active == 2);
 assert((obj-h_tid  GCFLAG_SMALLSTUB)
|| (obj-h_original == 0 || obj-h_tid  GCFLAG_PREBUILT_ORIGINAL));
 assert(obj-h_tid  GCFLAG_PUBLIC);
@@ -242,7 +243,7 @@
 }
 
 void stm_unregister_integer_address(intptr_t adr)
-{
+{   /* push roots! */
 wlog_t *found;
 gcptr obj = (gcptr)adr;
 
@@ -250,6 +251,11 @@
|| (obj-h_original == 0 || obj-h_tid  GCFLAG_PREBUILT_ORIGINAL));
 assert(obj-h_tid  GCFLAG_PUBLIC);
 
+/* become inevitable because we would have to re-register them
+   on abort, but make sure only to re-register if not registered
+   in the same aborted transaction (XXX) */
+stm_become_inevitable(stm_unregister_integer_address());
+
 stmgcpage_acquire_global_lock();
 
 /* find and decrement refcount */
@@ -528,12 +534,18 @@
 G2L_LOOP_FORWARD(registered_objs, item) {
 gcptr R = item-addr;
 assert(R-h_tid  GCFLAG_PUBLIC);
-
-if ((R-h_original == 0) || (R-h_tid  GCFLAG_PREBUILT_ORIGINAL)) {
-/* the obj is an original and will therefore survive: */
-gcptr V = stmgcpage_visit(R);
-assert(V == R);
+
+if (R-h_tid  GCFLAG_PREBUILT_ORIGINAL) {
+/* already done by mark_prebuilt_roots */
+assert((R-h_tid  (GCFLAG_MARKED|GCFLAG_VISITED|GCFLAG_PUBLIC))
+   == 

[pypy-commit] cffi default: Add a note to avoid people getting confused by the error message.

2013-11-18 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r1421:dd14c6808158
Date: 2013-11-18 12:05 +0100
http://bitbucket.org/cffi/cffi/changeset/dd14c6808158/

Log:Add a note to avoid people getting confused by the error message.

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -48,6 +48,7 @@
 try:
 compiler.compile(['c/check__thread.c'])
 except distutils.errors.CompileError:
+print  sys.stderr, the above error message can be safely ignored;
 print  sys.stderr, will not use '__thread' in the C code
 else:
 define_macros.append(('USE__THREAD', None))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy windows-packaging: close branch to be merged

2013-11-18 Thread mattip
Author: Matti Picus matti.pi...@gmail.com
Branch: windows-packaging
Changeset: r68205:2d1eb388152e
Date: 2013-11-18 13:06 +0200
http://bitbucket.org/pypy/pypy/changeset/2d1eb388152e/

Log:close branch to be merged

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


[pypy-commit] pypy default: merge windows-packaging, which add the tcl/tk runtime to win32 for cpython compatability

2013-11-18 Thread mattip
Author: Matti Picus matti.pi...@gmail.com
Branch: 
Changeset: r68206:4cc0b451e81f
Date: 2013-11-18 13:07 +0200
http://bitbucket.org/pypy/pypy/changeset/4cc0b451e81f/

Log:merge windows-packaging, which add the tcl/tk runtime to win32 for
cpython compatability

diff --git a/lib_pypy/_tkinter/tklib.py b/lib_pypy/_tkinter/tklib.py
--- a/lib_pypy/_tkinter/tklib.py
+++ b/lib_pypy/_tkinter/tklib.py
@@ -112,6 +112,10 @@
 incdirs = ['/usr/local/include/tcl8.5', '/usr/local/include/tk8.5', 
'/usr/X11R6/include']
 linklibs = ['tk85', 'tcl85']
 libdirs = ['/usr/local/lib', '/usr/X11R6/lib']
+elif sys.platform == 'win32':
+incdirs = []
+linklibs = ['tcl85', 'tk85']
+libdirs = []
 else:
 incdirs=['/usr/include/tcl']
 linklibs=['tcl', 'tk']
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -9,3 +9,7 @@
 
 .. branch: numpy-newbyteorder
 Clean up numpy types, add newbyteorder functionality
+
+.. branch windows-packaging
+Package tk/tcl runtime with win32
+
diff --git a/pypy/doc/windows.rst b/pypy/doc/windows.rst
--- a/pypy/doc/windows.rst
+++ b/pypy/doc/windows.rst
@@ -73,11 +73,11 @@
 https://bitbucket.org/pypy/pypy/downloads/local.zip
 Then expand it into the base directory (base_dir) and modify your environment 
to reflect this::
 
-set PATH=base_dir\bin;%PATH%
-set INCLUDE=base_dir\include;%INCLUDE%
-set LIB=base_dir\lib;%LIB%
+set PATH=base_dir\bin;base_dir\tcltk\bin;%PATH%
+set INCLUDE=base_dir\include;base_dir\tcltk\include;%INCLUDE%
+set LIB=base_dir\lib;base_dir\tcltk\lib;%LIB%
 
-Now you should be good to go. Read on for more information.
+Now you should be good to go. Read on for more information. 
 
 The Boehm garbage collector
 ~~~
@@ -109,11 +109,10 @@
 The bz2 compression library
 ~~~
 
-Download http://bzip.org/1.0.5/bzip2-1.0.5.tar.gz and extract it in
-the base directory.  Then compile::
-
-cd bzip2-1.0.5
+svn export http://svn.python.org/projects/external/bzip2-1.0.6
+cd bzip2-1.0.6
 nmake -f makefile.msc
+copy bzip.dll somewhere in the PATH\bzip.dll
 
 The sqlite3 database library
 
@@ -122,8 +121,6 @@
 wrapper is compiled when the module is imported for the first time.
 The sqlite3.dll should be version 3.6.21 for CPython2.7 compatablility.
 
-
-
 The expat XML parser
 
 
@@ -146,13 +143,33 @@
 use the one distributed by ActiveState, or the one from cygwin.  In
 both case the perl interpreter must be found on the PATH.
 
-Get http://www.openssl.org/source/openssl-0.9.8k.tar.gz and extract it
-in the base directory. Then compile::
-
+svn export http://svn.python.org/projects/external/openssl-0.9.8y
+cd openssl-0.9.8y
 perl Configure VC-WIN32
 ms\do_ms.bat
 nmake -f ms\nt.mak install
 
+TkInter module support
+~~
+
+Note that much of this is taken from the cpython build process.
+Tkinter is imported via cffi, so the module is optional. To recreate the tcltk
+directory found for the release script, create the dlls, libs, headers and
+runtime by running::
+
+   svn export http://svn.python.org/projects/external/tcl-8.5.2.1 tcl85 
+   svn export http://svn.python.org/projects/external/tk-8.5.2.0 tk85
+   cd tcl85\win 
+   nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=0 
INSTALLDIR=..\..\tcltk clean all 
+   nmake -f makefile.vc DEBUG=0 INSTALLDIR=..\..\tcltk install
+   cd ..\..\tk85\win 
+   nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 
INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl85 clean all 
+   nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 
INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl85 install
+
+Now you should have a tcktk\bin, tcltk\lib, and tcltk\include directory ready
+for use. The release packaging script will pick up the tcltk runtime in the lib
+directory and put it in the archive.
+
 Using the mingw compiler
 
 
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
@@ -67,18 +67,22 @@
 raise PyPyCNotFound(
 'Bogus path: %r does not exist (see docstring for more info)'
 % (os.path.dirname(str(pypy_c)),))
+win_extras = ['libpypy-c.dll', 'libexpat.dll', 'sqlite3.dll',
+  'libeay32.dll', 'ssleay32.dll']
 subprocess.check_call([str(pypy_c), '-c', 'import _sqlite3'])
 if not sys.platform == 'win32':
 subprocess.check_call([str(pypy_c), '-c', 'import _curses'])
 subprocess.check_call([str(pypy_c), '-c', 'import syslog'])
-if not withouttk:
-try:
-subprocess.check_call([str(pypy_c), '-c', 'import _tkinter'])
-except subprocess.CalledProcessError:
-

[pypy-commit] pypy windows-packaging: merge with default into branch

2013-11-18 Thread mattip
Author: Matti Picus matti.pi...@gmail.com
Branch: windows-packaging
Changeset: r68203:7d65e31ab264
Date: 2013-11-18 13:04 +0200
http://bitbucket.org/pypy/pypy/changeset/7d65e31ab264/

Log:merge with default into branch

diff --git a/lib-python/2.7/test/test_old_mailbox.py 
b/lib-python/2.7/test/test_old_mailbox.py
--- a/lib-python/2.7/test/test_old_mailbox.py
+++ b/lib-python/2.7/test/test_old_mailbox.py
@@ -73,7 +73,9 @@
 self.createMessage(cur)
 self.mbox = mailbox.Maildir(test_support.TESTFN)
 self.assertTrue(len(self.mbox) == 1)
-self.assertTrue(self.mbox.next() is not None)
+msg = self.mbox.next()
+self.assertTrue(msg is not None)
+msg.fp.close()
 self.assertTrue(self.mbox.next() is None)
 self.assertTrue(self.mbox.next() is None)
 
@@ -81,7 +83,9 @@
 self.createMessage(new)
 self.mbox = mailbox.Maildir(test_support.TESTFN)
 self.assertTrue(len(self.mbox) == 1)
-self.assertTrue(self.mbox.next() is not None)
+msg = self.mbox.next()
+self.assertTrue(msg is not None)
+msg.fp.close()
 self.assertTrue(self.mbox.next() is None)
 self.assertTrue(self.mbox.next() is None)
 
@@ -90,8 +94,12 @@
 self.createMessage(new)
 self.mbox = mailbox.Maildir(test_support.TESTFN)
 self.assertTrue(len(self.mbox) == 2)
-self.assertTrue(self.mbox.next() is not None)
-self.assertTrue(self.mbox.next() is not None)
+msg = self.mbox.next()
+self.assertTrue(msg is not None)
+msg.fp.close()
+msg = self.mbox.next()
+self.assertTrue(msg is not None)
+msg.fp.close()
 self.assertTrue(self.mbox.next() is None)
 self.assertTrue(self.mbox.next() is None)
 
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -268,10 +268,18 @@
 if _has_load_extension():
 _ffi.cdef(int sqlite3_enable_load_extension(sqlite3 *db, int onoff);)
 
-_lib = _ffi.verify(
-#include sqlite3.h
-, libraries=['sqlite3']
-)
+if sys.platform.startswith('freebsd'):
+_lib = _ffi.verify(
+#include sqlite3.h
+, libraries=['sqlite3'],
+ include_dirs=['/usr/local/include'],
+ library_dirs=['/usr/local/lib']
+)
+else:
+_lib = _ffi.verify(
+#include sqlite3.h
+, libraries=['sqlite3']
+)
 
 exported_sqlite_symbols = [
 'SQLITE_ALTER_TABLE',
diff --git a/pypy/interpreter/test/test_app_main.py 
b/pypy/interpreter/test/test_app_main.py
--- a/pypy/interpreter/test/test_app_main.py
+++ b/pypy/interpreter/test/test_app_main.py
@@ -942,7 +942,8 @@
 
 self.w_tmp_dir = self.space.wrap(tmp_dir)
 
-foo_py = prefix.join('foo.py').write(pass)
+foo_py = prefix.join('foo.py')
+foo_py.write(pass)
 self.w_foo_py = self.space.wrap(str(foo_py))
 
 def test_setup_bootstrap_path(self):
diff --git a/pypy/module/termios/test/test_termios.py 
b/pypy/module/termios/test/test_termios.py
--- a/pypy/module/termios/test/test_termios.py
+++ b/pypy/module/termios/test/test_termios.py
@@ -7,6 +7,9 @@
 if os.name != 'posix':
 py.test.skip('termios module only available on unix')
 
+if sys.platform.startswith('freebsd'):
+raise Exception('XXX seems to hangs on FreeBSD9')
+
 class TestTermios(object):
 def setup_class(cls):
 try:
diff --git a/pypy/module/test_lib_pypy/cffi_tests/test_verify.py 
b/pypy/module/test_lib_pypy/cffi_tests/test_verify.py
--- a/pypy/module/test_lib_pypy/cffi_tests/test_verify.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/test_verify.py
@@ -1638,7 +1638,11 @@
 #include malloc.h
 #define alloca _alloca
 #else
-#include alloca.h
+# ifdef __FreeBSD__
+#  include stdlib.h
+# else
+#  include alloca.h
+# endif
 #endif
 static int (*python_callback)(int how_many, int *values);
 static int c_callback(int how_many, ...) {
diff --git a/pypy/module/test_lib_pypy/pyrepl/__init__.py 
b/pypy/module/test_lib_pypy/pyrepl/__init__.py
--- a/pypy/module/test_lib_pypy/pyrepl/__init__.py
+++ b/pypy/module/test_lib_pypy/pyrepl/__init__.py
@@ -1,3 +1,6 @@
 import sys
 import lib_pypy.pyrepl
 sys.modules['pyrepl'] = sys.modules['lib_pypy.pyrepl']
+
+if sys.platform.startswith('freebsd'):
+raise Exception('XXX seems to hangs on FreeBSD9')
diff --git a/pypy/module/test_lib_pypy/test_grp_extra.py 
b/pypy/module/test_lib_pypy/test_grp_extra.py
--- a/pypy/module/test_lib_pypy/test_grp_extra.py
+++ b/pypy/module/test_lib_pypy/test_grp_extra.py
@@ -16,7 +16,7 @@
 except KeyError:
 continue
 assert g.gr_gid == 0
-assert g.gr_mem == ['root'] or g.gr_mem == []
+assert 'root' in g.gr_mem or g.gr_mem == []
 assert g.gr_name == name
 assert isinstance(g.gr_passwd, str)# usually just 'x', don't 
hope :-)

[pypy-commit] pypy windows-packaging: document branch

2013-11-18 Thread mattip
Author: Matti Picus matti.pi...@gmail.com
Branch: windows-packaging
Changeset: r68204:d1aeb871790a
Date: 2013-11-18 13:06 +0200
http://bitbucket.org/pypy/pypy/changeset/d1aeb871790a/

Log:document branch

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -9,3 +9,7 @@
 
 .. branch: numpy-newbyteorder
 Clean up numpy types, add newbyteorder functionality
+
+.. branch windows-packaging
+Package tk/tcl runtime with win32
+
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-2.2.x: Merge the non-doc parts of the 'windows-packaging' branch here.

2013-11-18 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: release-2.2.x
Changeset: r68207:1567dba349e6
Date: 2013-11-18 12:14 +0100
http://bitbucket.org/pypy/pypy/changeset/1567dba349e6/

Log:Merge the non-doc parts of the 'windows-packaging' branch here.

diff --git a/lib_pypy/_tkinter/tklib.py b/lib_pypy/_tkinter/tklib.py
--- a/lib_pypy/_tkinter/tklib.py
+++ b/lib_pypy/_tkinter/tklib.py
@@ -112,6 +112,10 @@
 incdirs = ['/usr/local/include/tcl8.5', '/usr/local/include/tk8.5', 
'/usr/X11R6/include']
 linklibs = ['tk85', 'tcl85']
 libdirs = ['/usr/local/lib', '/usr/X11R6/lib']
+elif sys.platform == 'win32':
+incdirs = []
+linklibs = ['tcl85', 'tk85']
+libdirs = []
 else:
 incdirs=['/usr/include/tcl']
 linklibs=['tcl', 'tk']
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
@@ -67,18 +67,22 @@
 raise PyPyCNotFound(
 'Bogus path: %r does not exist (see docstring for more info)'
 % (os.path.dirname(str(pypy_c)),))
+win_extras = ['libpypy-c.dll', 'libexpat.dll', 'sqlite3.dll',
+  'libeay32.dll', 'ssleay32.dll']
 subprocess.check_call([str(pypy_c), '-c', 'import _sqlite3'])
 if not sys.platform == 'win32':
 subprocess.check_call([str(pypy_c), '-c', 'import _curses'])
 subprocess.check_call([str(pypy_c), '-c', 'import syslog'])
-if not withouttk:
-try:
-subprocess.check_call([str(pypy_c), '-c', 'import _tkinter'])
-except subprocess.CalledProcessError:
-print sys.stderr, Building Tk bindings failed.
+if not withouttk:
+try:
+subprocess.check_call([str(pypy_c), '-c', 'import _tkinter'])
+except subprocess.CalledProcessError:
+print sys.stderr, Building Tk bindings failed.
 You can either install Tk development headers package or
 add --without-tk option to skip packaging binary CFFI extension.
-sys.exit(1)
+sys.exit(1)
+#Can the dependencies be found from cffi somehow?
+win_extras += ['tcl85.dll', 'tk85.dll']
 if sys.platform == 'win32' and not rename_pypy_c.lower().endswith('.exe'):
 rename_pypy_c += '.exe'
 binaries = [(pypy_c, rename_pypy_c)]
@@ -101,9 +105,7 @@
 
 # Can't rename a DLL: it is always called 'libpypy-c.dll'
 
-for extra in ['libpypy-c.dll',
-  'libexpat.dll', 'sqlite3.dll',
-  'libeay32.dll', 'ssleay32.dll']:
+for extra in win_extras:
 p = pypy_c.dirpath().join(extra)
 if not p.check():
 p = py.path.local.sysfind(extra)
@@ -122,6 +124,19 @@
 # XXX users will complain that they cannot compile cpyext
 # modules for windows, has the lib moved or are there no
 # exported functions in the dll so no import library is created?
+if not withouttk:
+try:
+p = pypy_c.dirpath().join('tcl85.dll')
+if not p.check():
+p = py.path.local.sysfind('tcl85.dll')
+tktcldir = p.dirpath().join('..').join('lib')
+shutil.copytree(str(tktcldir), str(pypydir.join('tcl')))
+except WindowsError:
+print sys.stderr, Packaging Tk runtime failed.
+tk85.dll and tcl85.dll found, expecting to find runtime in ..\\lib
+directory next to the dlls, as per build instructions.
+import traceback;traceback.print_exc()
+sys.exit(1)
 
 # Careful: to copy lib_pypy, copying just the hg-tracked files
 # would not be enough: there are also ctypes_config_cache/_*_cache.py.
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-2.2.x: make it possible to disable suprocess with an env var

2013-11-18 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: release-2.2.x
Changeset: r68208:1f5ff8d1ee6e
Date: 2013-11-18 13:41 +0100
http://bitbucket.org/pypy/pypy/changeset/1f5ff8d1ee6e/

Log:make it possible to disable suprocess with an env var

diff --git a/rpython/tool/runsubprocess.py b/rpython/tool/runsubprocess.py
--- a/rpython/tool/runsubprocess.py
+++ b/rpython/tool/runsubprocess.py
@@ -49,7 +49,7 @@
 sys.stdout.flush()
 
 
-if sys.platform != 'win32' and hasattr(os, 'fork'):
+if sys.platform != 'win32' and hasattr(os, 'fork') and not 
os.getenv(PYPY_DONT_RUN_SUBPROCESS, None):
 # do this at import-time, when the process is still tiny
 _source = os.path.dirname(os.path.abspath(__file__))
 _source = os.path.join(_source, 'runsubprocess.py')   # and not e.g. '.pyc'
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Bah. print sys.stderr, ... is syntactically valid on Python 3,

2013-11-18 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r1422:c1c4583b0bd1
Date: 2013-11-18 14:26 +0100
http://bitbucket.org/cffi/cffi/changeset/c1c4583b0bd1/

Log:Bah. print  sys.stderr, ... is syntactically valid on Python 3,
but does nonsense.

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -48,8 +48,8 @@
 try:
 compiler.compile(['c/check__thread.c'])
 except distutils.errors.CompileError:
-print  sys.stderr, the above error message can be safely ignored;
-print  sys.stderr, will not use '__thread' in the C code
+sys.stderr.write(the above error message can be safely ignored;\n)
+sys.stderr.write(will not use '__thread' in the C code\n)
 else:
 define_macros.append(('USE__THREAD', None))
 try:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: allow disable stripping/tk via env var

2013-11-18 Thread oberstet
Author: Tobias Oberstein tobias.oberst...@tavendo.de
Branch: 
Changeset: r68209:679ca2fdefb6
Date: 2013-11-18 14:04 +0100
http://bitbucket.org/pypy/pypy/changeset/679ca2fdefb6/

Log:allow disable stripping/tk via env var

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
@@ -217,5 +217,11 @@
 else:
 print_usage()
 
+if os.environ.has_key(PYPY_PACKAGE_NOSTRIP):
+kw['nostrip'] = True
+
+if os.environ.has_key(PYPY_PACKAGE_WITHOUTTK):
+kw['withouttk'] = True
+
 args = args[i:]
 package(*args, **kw)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: skip test that assume glibc specific, non-standard-C behavior

2013-11-18 Thread oberstet
Author: Tobias Oberstein tobias.oberst...@tavendo.de
Branch: 
Changeset: r68213:dc08f917cd4f
Date: 2013-11-18 14:43 +0100
http://bitbucket.org/pypy/pypy/changeset/dc08f917cd4f/

Log:skip test that assume glibc specific, non-standard-C behavior

diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py 
b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -1086,7 +1086,9 @@
 assert strlenaddr == cast(BVoidP, strlen)
 
 def test_read_variable():
-if sys.platform == 'win32' or sys.platform == 'darwin':
+## FIXME: this test assumes glibc specific behavior, it's not compliant 
with C standard
+## https://bugs.pypy.org/issue1643
+if sys.platform == 'win32' or sys.platform == 'darwin' or 
sys.platform.startswith('freebsd'):
 py.test.skip(untested)
 BVoidP = new_pointer_type(new_void_type())
 ll = find_and_load_library('c')
@@ -1094,7 +1096,9 @@
 assert stderr == cast(BVoidP, _testfunc(8))
 
 def test_read_variable_as_unknown_length_array():
-if sys.platform == 'win32' or sys.platform == 'darwin':
+## FIXME: this test assumes glibc specific behavior, it's not compliant 
with C standard
+## https://bugs.pypy.org/issue1643
+if sys.platform == 'win32' or sys.platform == 'darwin' or 
sys.platform.startswith('freebsd'):
 py.test.skip(untested)
 BCharP = new_pointer_type(new_primitive_type(char))
 BArray = new_array_type(BCharP, None)
@@ -1104,7 +1108,9 @@
 # ^^ and not 'char[]', which is basically not allowed and would crash
 
 def test_write_variable():
-if sys.platform == 'win32' or sys.platform == 'darwin':
+## FIXME: this test assumes glibc specific behavior, it's not compliant 
with C standard
+## https://bugs.pypy.org/issue1643
+if sys.platform == 'win32' or sys.platform == 'darwin' or 
sys.platform.startswith('freebsd'):
 py.test.skip(untested)
 BVoidP = new_pointer_type(new_void_type())
 ll = find_and_load_library('c')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: FreeBSD 9.2 / Tcl/Tk 8.6 paths include and lib paths

2013-11-18 Thread oberstet
Author: Tobias Oberstein tobias.oberst...@tavendo.de
Branch: 
Changeset: r68212:68fe795f0c67
Date: 2013-11-18 14:18 +0100
http://bitbucket.org/pypy/pypy/changeset/68fe795f0c67/

Log:FreeBSD 9.2 / Tcl/Tk 8.6 paths include and lib paths

diff --git a/lib_pypy/_tkinter/tklib.py b/lib_pypy/_tkinter/tklib.py
--- a/lib_pypy/_tkinter/tklib.py
+++ b/lib_pypy/_tkinter/tklib.py
@@ -112,6 +112,10 @@
 incdirs = ['/usr/local/include/tcl8.5', '/usr/local/include/tk8.5', 
'/usr/X11R6/include']
 linklibs = ['tk85', 'tcl85']
 libdirs = ['/usr/local/lib', '/usr/X11R6/lib']
+elif sys.platform.startswith(freebsd):
+incdirs = ['/usr/local/include/tcl8.6', '/usr/local/include/tk8.6', 
'/usr/local/include/X11']
+linklibs = ['tk86', 'tcl86']
+libdirs = ['/usr/local/lib']
 elif sys.platform == 'win32':
 incdirs = []
 linklibs = ['tcl85', 'tk85']
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: allow disable strip/tk via env vars

2013-11-18 Thread oberstet
Author: Tobias Oberstein tobias.oberst...@tavendo.de
Branch: 
Changeset: r68211:0924956bd436
Date: 2013-11-18 14:11 +0100
http://bitbucket.org/pypy/pypy/changeset/0924956bd436/

Log:allow disable strip/tk via env vars

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


[pypy-commit] pypy default: allow disable strip/tk via env vars

2013-11-18 Thread oberstet
Author: Tobias Oberstein tobias.oberst...@tavendo.de
Branch: 
Changeset: r68210:76bc9f2cd215
Date: 2013-11-18 14:10 +0100
http://bitbucket.org/pypy/pypy/changeset/76bc9f2cd215/

Log:allow disable strip/tk via env vars

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
@@ -232,5 +232,11 @@
 else:
 print_usage()
 
+if os.environ.has_key(PYPY_PACKAGE_NOSTRIP):
+kw['nostrip'] = True
+
+if os.environ.has_key(PYPY_PACKAGE_WITHOUTTK):
+kw['withouttk'] = True
+
 args = args[i:]
 package(*args, **kw)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Skip these tests on FreeBSD too

2013-11-18 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r1423:8b8f7428bd31
Date: 2013-11-18 15:14 +0100
http://bitbucket.org/cffi/cffi/changeset/8b8f7428bd31/

Log:Skip these tests on FreeBSD too

diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -1097,7 +1097,9 @@
 assert strlenaddr == cast(BVoidP, strlen)
 
 def test_read_variable():
-if sys.platform == 'win32' or sys.platform == 'darwin':
+## FIXME: this test assumes glibc specific behavior, it's not compliant 
with C standard
+## https://bugs.pypy.org/issue1643
+if sys.platform == 'win32' or sys.platform == 'darwin' or 
sys.platform.startswith('freebsd'):
 py.test.skip(untested)
 BVoidP = new_pointer_type(new_void_type())
 ll = find_and_load_library('c')
@@ -1105,7 +1107,9 @@
 assert stderr == cast(BVoidP, _testfunc(8))
 
 def test_read_variable_as_unknown_length_array():
-if sys.platform == 'win32' or sys.platform == 'darwin':
+## FIXME: this test assumes glibc specific behavior, it's not compliant 
with C standard
+## https://bugs.pypy.org/issue1643
+if sys.platform == 'win32' or sys.platform == 'darwin' or 
sys.platform.startswith('freebsd'):
 py.test.skip(untested)
 BCharP = new_pointer_type(new_primitive_type(char))
 BArray = new_array_type(BCharP, None)
@@ -1115,7 +1119,9 @@
 # ^^ and not 'char[]', which is basically not allowed and would crash
 
 def test_write_variable():
-if sys.platform == 'win32' or sys.platform == 'darwin':
+## FIXME: this test assumes glibc specific behavior, it's not compliant 
with C standard
+## https://bugs.pypy.org/issue1643
+if sys.platform == 'win32' or sys.platform == 'darwin' or 
sys.platform.startswith('freebsd'):
 py.test.skip(untested)
 BVoidP = new_pointer_type(new_void_type())
 ll = find_and_load_library('c')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-array_prepare_-array_wrap: Revert Ufunc{1, 2}.call

2013-11-18 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r68214:d18c4175125e
Date: 2013-11-18 17:39 +0100
http://bitbucket.org/pypy/pypy/changeset/d18c4175125e/

Log:Revert Ufunc{1,2}.call

diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -343,17 +343,15 @@
   w_obj.get_scalar_value().convert_to(calc_dtype))
 if out is None:
 return w_val
-if isinstance(out, W_NDimArray):
-if out.is_scalar():
-out.set_scalar_value(w_val)
-else:
-out.fill(res_dtype.coerce(space, w_val))
-return self.call_prepare(space, out, w_obj, w_val)
+if out.is_scalar():
+out.set_scalar_value(w_val)
+else:
+out.fill(res_dtype.coerce(space, w_val))
+return out
 shape = shape_agreement(space, w_obj.get_shape(), out,
 broadcast_down=False)
-w_result = loop.call1(space, shape, self.func, calc_dtype, res_dtype,
+return loop.call1(space, shape, self.func, calc_dtype, res_dtype,
   w_obj, out)
-return self.call_prepare(space, out, w_obj, w_result)
 
 
 class W_Ufunc2(W_Ufunc):
@@ -423,11 +421,11 @@
 promote_bools=self.promote_bools)
 if space.is_none(w_out):
 out = None
-#elif not isinstance(w_out, W_NDimArray):
-#raise OperationError(space.w_TypeError, space.wrap(
-#'output must be an array'))
+elif not isinstance(w_out, W_NDimArray):
+raise OperationError(space.w_TypeError, space.wrap(
+'output must be an array'))
 else:
-out = convert_to_array(space, w_out)
+out = w_out
 calc_dtype = out.get_dtype()
 if self.comparison_func:
 res_dtype = interp_dtype.get_dtype_cache(space).w_booldtype
@@ -443,15 +441,14 @@
 out.set_scalar_value(arr)
 else:
 out.fill(arr)
-arr = out
-# XXX handle array_priority
-return self.call_prepare(space, out, w_lhs, arr)
+else:
+out = arr
+return out
 new_shape = shape_agreement(space, w_lhs.get_shape(), w_rhs)
 new_shape = shape_agreement(space, new_shape, out, 
broadcast_down=False)
-w_result = loop.call2(space, new_shape, self.func, calc_dtype,
+return loop.call2(space, new_shape, self.func, calc_dtype,
   res_dtype, w_lhs, w_rhs, out)
-# XXX handle array_priority
-return self.call_prepare(space, out, w_lhs, w_result)
+
 
 W_Ufunc.typedef = TypeDef(ufunc,
 __module__ = numpypy,
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-array_prepare_-array_wrap: Move call_prepare to loop.py

2013-11-18 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r68215:145ff824d697
Date: 2013-11-18 17:42 +0100
http://bitbucket.org/pypy/pypy/changeset/145ff824d697/

Log:Move call_prepare to loop.py

diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -256,38 +256,6 @@
 return out
 return res
 
-def call_prepare(self, space, w_out, w_obj, w_result):
-if isinstance(w_out, W_NDimArray):
-w_array = space.lookup(w_out, __array_prepare__)
-w_caller = w_out
-else:
-w_array = space.lookup(w_obj, __array_prepare__)
-w_caller = w_obj
-if w_array:
-w_retVal = space.get_and_call_function(w_array, w_caller, 
w_result, None)
-if not isinstance(w_retVal, W_NDimArray) and \
-   not isinstance(w_retVal, interp_boxes.Box):
-raise OperationError(space.w_ValueError,
-space.wrap( __array_prepare__ must return an 
-ndarray or subclass thereof))
-if isinstance(w_result, interp_boxes.Box) or \
-w_result.is_scalar():
-if not isinstance(w_retVal, interp_boxes.Box) and not 
w_retVal.is_scalar():
-raise OperationError(space.w_TypeError,
-space.wrap( __array_prepare__ must return an 
-ndarray or subclass thereof which is 
-otherwise identical to its input))
-elif w_result.get_shape() != w_retVal.get_shape() or \
-   w_result.implementation.get_strides() != \
-w_retVal.implementation.get_strides():
-raise OperationError(space.w_TypeError,
-space.wrap( __array_prepare__ must return an 
-ndarray or subclass thereof which is 
-otherwise identical to its input))
-return w_retVal
-return w_result
-
-
 class W_Ufunc1(W_Ufunc):
 _immutable_fields_ = [func, bool_result]
 argcount = 1
diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -19,6 +19,37 @@
  reds = ['shape', 'w_lhs', 'w_rhs', 'out',
  'left_iter', 'right_iter', 'out_iter'])
 
+def call_prepare(self, space, w_out, w_obj, w_result):
+if isinstance(w_out, W_NDimArray):
+w_array = space.lookup(w_out, __array_prepare__)
+w_caller = w_out
+else:
+w_array = space.lookup(w_obj, __array_prepare__)
+w_caller = w_obj
+if w_array:
+w_retVal = space.get_and_call_function(w_array, w_caller, w_result, 
None)
+if not isinstance(w_retVal, W_NDimArray) and \
+not isinstance(w_retVal, interp_boxes.Box):
+raise OperationError(space.w_ValueError,
+space.wrap( __array_prepare__ must return an 
+ndarray or subclass thereof))
+if isinstance(w_result, interp_boxes.Box) or \
+w_result.is_scalar():
+if not isinstance(w_retVal, interp_boxes.Box) and not 
w_retVal.is_scalar():
+raise OperationError(space.w_TypeError,
+space.wrap( __array_prepare__ must return an 
+ndarray or subclass thereof which is 
+otherwise identical to its input))
+elif w_result.get_shape() != w_retVal.get_shape() or \
+w_result.implementation.get_strides() != \
+w_retVal.implementation.get_strides():
+raise OperationError(space.w_TypeError,
+space.wrap( __array_prepare__ must return an 
+ndarray or subclass thereof which is 
+otherwise identical to its input))
+return w_retVal
+return w_result
+
 def call2(space, shape, func, calc_dtype, res_dtype, w_lhs, w_rhs, out):
 # handle array_priority
 # w_lhs and w_rhs could be of different ndarray subtypes. Numpy does:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: C header include paths .. once more

2013-11-18 Thread oberstet
Author: Tobias Oberstein tobias.oberst...@tavendo.de
Branch: 
Changeset: r68216:b6c763cd5357
Date: 2013-11-18 17:08 +0100
http://bitbucket.org/pypy/pypy/changeset/b6c763cd5357/

Log:C header include paths .. once more

diff --git a/lib_pypy/_tkinter/tklib.py b/lib_pypy/_tkinter/tklib.py
--- a/lib_pypy/_tkinter/tklib.py
+++ b/lib_pypy/_tkinter/tklib.py
@@ -113,7 +113,7 @@
 linklibs = ['tk85', 'tcl85']
 libdirs = ['/usr/local/lib', '/usr/X11R6/lib']
 elif sys.platform.startswith(freebsd):
-incdirs = ['/usr/local/include/tcl8.6', '/usr/local/include/tk8.6', 
'/usr/local/include/X11']
+incdirs = ['/usr/local/include/tcl8.6', '/usr/local/include/tk8.6', 
'/usr/local/include/X11', '/usr/local/include']
 linklibs = ['tk86', 'tcl86']
 libdirs = ['/usr/local/lib']
 elif sys.platform == 'win32':
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-array_prepare_-array_wrap: Remove useless code

2013-11-18 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r68217:5848d1c58c12
Date: 2013-11-18 18:30 +0100
http://bitbucket.org/pypy/pypy/changeset/5848d1c58c12/

Log:Remove useless code

diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -173,7 +173,6 @@
 shapelen = len(obj_shape)
 axis = unwrap_axis_arg(space, shapelen, w_axis)
 assert axis = 0
-size = obj.get_size()
 dtype = interp_dtype.decode_w_dtype(space, dtype)
 if dtype is None:
 if self.comparison_func:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpypy-array_prepare_-array_wrap: Implement __array_prepare__ for non-scalar

2013-11-18 Thread rguillebert
Author: Romain Guillebert romain...@gmail.com
Branch: numpypy-array_prepare_-array_wrap
Changeset: r68218:25afd81e613b
Date: 2013-11-18 18:31 +0100
http://bitbucket.org/pypy/pypy/changeset/25afd81e613b/

Log:Implement __array_prepare__ for non-scalar

diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -12,22 +12,12 @@
 from pypy.module.micronumpy.iter import PureShapeIterator
 from pypy.module.micronumpy import constants
 from pypy.module.micronumpy.support import int_w
+from pypy.module.micronumpy import interp_boxes
 
-call2_driver = jit.JitDriver(name='numpy_call2',
- greens = ['shapelen', 'func', 'calc_dtype',
-   'res_dtype'],
- reds = ['shape', 'w_lhs', 'w_rhs', 'out',
- 'left_iter', 'right_iter', 'out_iter'])
-
-def call_prepare(self, space, w_out, w_obj, w_result):
-if isinstance(w_out, W_NDimArray):
-w_array = space.lookup(w_out, __array_prepare__)
-w_caller = w_out
-else:
-w_array = space.lookup(w_obj, __array_prepare__)
-w_caller = w_obj
+def call_prepare(space, w_obj, w_result):
+w_array = space.lookup(w_obj, __array_prepare__)
 if w_array:
-w_retVal = space.get_and_call_function(w_array, w_caller, w_result, 
None)
+w_retVal = space.get_and_call_function(w_array, w_obj, w_result, None)
 if not isinstance(w_retVal, W_NDimArray) and \
 not isinstance(w_retVal, interp_boxes.Box):
 raise OperationError(space.w_ValueError,
@@ -50,6 +40,11 @@
 return w_retVal
 return w_result
 
+call2_driver = jit.JitDriver(name='numpy_call2',
+ greens = ['shapelen', 'func', 'calc_dtype',
+   'res_dtype'],
+ reds = ['shape', 'w_lhs', 'w_rhs', 'out',
+ 'left_iter', 'right_iter', 'out_iter'])
 def call2(space, shape, func, calc_dtype, res_dtype, w_lhs, w_rhs, out):
 # handle array_priority
 # w_lhs and w_rhs could be of different ndarray subtypes. Numpy does:
@@ -78,6 +73,10 @@
 if out is None:
 out = W_NDimArray.from_shape(space, shape, res_dtype,
  w_instance=lhs_for_subtype)
+out = call_prepare(space, w_lhs, out)
+else:
+out = call_prepare(space, out, out)
+
 left_iter = w_lhs.create_iter(shape)
 right_iter = w_rhs.create_iter(shape)
 out_iter = out.create_iter(shape)
@@ -107,6 +106,9 @@
 def call1(space, shape, func, calc_dtype, res_dtype, w_obj, out):
 if out is None:
 out = W_NDimArray.from_shape(space, shape, res_dtype, w_instance=w_obj)
+out = call_prepare(space, w_obj, out)
+else:
+out = call_prepare(space, out, out)
 obj_iter = w_obj.create_iter(shape)
 out_iter = out.create_iter(shape)
 shapelen = len(shape)
diff --git a/pypy/module/micronumpy/test/test_subtype.py 
b/pypy/module/micronumpy/test/test_subtype.py
--- a/pypy/module/micronumpy/test/test_subtype.py
+++ b/pypy/module/micronumpy/test/test_subtype.py
@@ -260,7 +260,7 @@
 assert type(x) == ndarray
 assert a.called_wrap
 
-def test___array_prepare__2arg(self):
+def test___array_prepare__2arg_scalar(self):
 from numpypy import ndarray, array, add, ones
 class with_prepare(ndarray):
 def __array_prepare__(self, arr, context):
@@ -287,7 +287,7 @@
 assert x.called_prepare
 raises(TypeError, add, a, b, out=c)
 
-def test___array_prepare__1arg(self):
+def test___array_prepare__1arg_scalar(self):
 from numpypy import ndarray, array, log, ones
 class with_prepare(ndarray):
 def __array_prepare__(self, arr, context):
@@ -316,6 +316,61 @@
 assert x.called_prepare
 raises(TypeError, log, a, out=c)
 
+def test___array_prepare__2arg_array(self):
+from numpypy import ndarray, array, add, ones
+class with_prepare(ndarray):
+def __array_prepare__(self, arr, context):
+retVal = array(arr).view(type=with_prepare)
+retVal.called_prepare = True
+return retVal
+class with_prepare_fail(ndarray):
+called_prepare = False
+def __array_prepare__(self, arr, context):
+return array(arr[0]).view(type=with_prepare)
+a = array([1])
+b = array([1]).view(type=with_prepare)
+x = add(a, a, out=b)
+assert x == 2
+assert type(x) == with_prepare
+assert x.called_prepare
+b.called_prepare = False
+a = ones((3, 2)).view(type=with_prepare)
+b = ones((3, 2))
+c = ones((3, 2)).view(type=with_prepare_fail)
+x = add(a, b, out=a)
+assert (x == 2).all()
+assert 

[pypy-commit] pypy default: fix indexing using array scalars

2013-11-18 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r68219:f5dbd427526c
Date: 2013-11-18 14:41 -0500
http://bitbucket.org/pypy/pypy/changeset/f5dbd427526c/

Log:fix indexing using array scalars

diff --git a/pypy/module/micronumpy/arrayimpl/concrete.py 
b/pypy/module/micronumpy/arrayimpl/concrete.py
--- a/pypy/module/micronumpy/arrayimpl/concrete.py
+++ b/pypy/module/micronumpy/arrayimpl/concrete.py
@@ -211,7 +211,15 @@
 field named %s not found % idx))
 return RecordChunk(idx)
 if (space.isinstance_w(w_idx, space.w_int) or
-space.isinstance_w(w_idx, space.w_slice)):
+space.isinstance_w(w_idx, space.w_slice)):
+return Chunks([Chunk(*space.decode_index4(w_idx, 
self.get_shape()[0]))])
+elif isinstance(w_idx, W_NDimArray) and \
+isinstance(w_idx.implementation, scalar.Scalar):
+w_idx = w_idx.get_scalar_value().item(space)
+if not space.isinstance_w(w_idx, space.w_int) and \
+not space.isinstance_w(w_idx, space.w_bool):
+raise OperationError(space.w_IndexError, space.wrap(
+arrays used as indices must be of integer (or boolean) 
type))
 return Chunks([Chunk(*space.decode_index4(w_idx, 
self.get_shape()[0]))])
 elif space.is_w(w_idx, space.w_None):
 return Chunks([NewAxisChunk()])
diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -198,7 +198,8 @@
prefix)
 
 def descr_getitem(self, space, w_idx):
-if isinstance(w_idx, W_NDimArray) and w_idx.get_dtype().is_bool_type():
+if isinstance(w_idx, W_NDimArray) and w_idx.get_dtype().is_bool_type() 
\
+and len(w_idx.get_shape())  0:
 return self.getitem_filter(space, w_idx)
 try:
 return self.implementation.descr_getitem(space, self, w_idx)
diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -1862,12 +1862,16 @@
 raises(IndexError, arange(10)[array([10])] = 3)
 raises(IndexError, arange(10)[[-11]] = 3)
 
-def test_bool_single_index(self):
+def test_array_scalar_index(self):
 import numpypy as np
 a = np.array([[1, 2, 3],
   [4, 5, 6],
   [7, 8, 9]])
-a[np.array(True)]; skip(broken)  # check for crash but skip rest of 
test until correct
+assert (a[np.array(0)] == a[0]).all()
+assert (a[np.array(1)] == a[1]).all()
+exc = raises(IndexError, a[np.array(1.1)])
+assert exc.value.message == 'arrays used as indices must be of ' \
+'integer (or boolean) type'
 assert (a[np.array(True)] == a[1]).all()
 assert (a[np.array(False)] == a[0]).all()
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix setitem using array scalars also

2013-11-18 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r68220:c16f3a1dbc73
Date: 2013-11-18 14:48 -0500
http://bitbucket.org/pypy/pypy/changeset/c16f3a1dbc73/

Log:fix setitem using array scalars also

diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -213,7 +213,8 @@
 self.implementation.setitem_index(space, index_list, w_value)
 
 def descr_setitem(self, space, w_idx, w_value):
-if isinstance(w_idx, W_NDimArray) and w_idx.get_dtype().is_bool_type():
+if isinstance(w_idx, W_NDimArray) and w_idx.get_dtype().is_bool_type() 
\
+and len(w_idx.get_shape())  0:
 self.setitem_filter(space, w_idx, convert_to_array(space, w_value))
 return
 try:
diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -1869,11 +1869,19 @@
   [7, 8, 9]])
 assert (a[np.array(0)] == a[0]).all()
 assert (a[np.array(1)] == a[1]).all()
+assert (a[np.array(True)] == a[1]).all()
+assert (a[np.array(False)] == a[0]).all()
 exc = raises(IndexError, a[np.array(1.1)])
 assert exc.value.message == 'arrays used as indices must be of ' \
 'integer (or boolean) type'
-assert (a[np.array(True)] == a[1]).all()
-assert (a[np.array(False)] == a[0]).all()
+
+a[np.array(1)] = a[2]
+assert a[1][1] == 8
+a[np.array(True)] = a[0]
+assert a[1][1] == 2
+exc = raises(IndexError, a[np.array(1.1)] = a[2])
+assert exc.value.message == 'arrays used as indices must be of ' \
+'integer (or boolean) type'
 
 def test_bool_array_index(self):
 from numpypy import arange, array
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy voidtype_strformat: add failing test, almost implement

2013-11-18 Thread mattip
Author: Matti Picus matti.pi...@gmail.com
Branch: voidtype_strformat
Changeset: r68221:889adc434d6e
Date: 2013-11-18 22:03 +0200
http://bitbucket.org/pypy/pypy/changeset/889adc434d6e/

Log:add failing test, almost implement

diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -3099,6 +3099,17 @@
 
 assert len(list(a[0])) == 2
 
+def test_3d_record(self):
+from numpypy import dtype, array
+dt = dtype([('name', 'S4'), ('x', float), ('y', float),
+('block', int, (2, 2, 3))])
+a = array([('', 1.0, 8.0, [[[1, 2, 3], [4, 5, 6]],
+   [[7, 8, 9], [10, 11, 12]]])],
+  dtype=dt)
+s = str(a)
+assert s.endswith([('', 1.0, 8.0, [[[1, 2, 3], [4, 5, 6]], [[7, 
8, 9], [10, 11, 12]]])])
+
+
 def test_issue_1589(self):
 import numpypy as numpy
 c = numpy.array([[(1, 2, 'a'), (3, 4, 'b')], [(5, 6, 'c'), (7, 8, 
'd')]],
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -1789,6 +1789,25 @@
 dtype.subdtype)
 return W_NDimArray(implementation)
 
+def str_format(self, val):
+# only called with the results of readarray()
+from pypy.module.micronumpy.base import W_NDimArray
+assert isinstance(val, W_NDimArray)
+i = val.create_iter()
+first = True
+dtype = val.get_dtype()
+s = StringBuilder()
+s.append('[')
+while not i.done():
+if first:
+first = False
+else:
+s.append(', ')
+s.append(dtype.itemtype.str_format(i.getitem()))
+i.next()
+s.append(']')
+return s.build()
+
 class RecordType(FlexibleType):
 T = lltype.Char
 
@@ -1848,7 +1867,11 @@
 first = False
 else:
 pieces.append(, )
-pieces.append(tp.str_format(tp.read(box.arr, box.ofs, ofs)))
+if isinstance(tp, VoidType):
+val = tp.readarray(box.arr, box.ofs, ofs, subdtype)
+else:
+val = tp.read(box.arr, box.ofs, ofs, subdtype)
+pieces.append(tp.str_format(val))
 pieces.append())
 return .join(pieces)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy less-stringly-ops: cleanup ArgErr*

2013-11-18 Thread rlamy
Author: Ronan Lamy ronan.l...@gmail.com
Branch: less-stringly-ops
Changeset: r68222:ad17710e31c4
Date: 2013-10-30 06:25 +
http://bitbucket.org/pypy/pypy/changeset/ad17710e31c4/

Log:cleanup ArgErr*

diff --git a/rpython/annotator/argument.py b/rpython/annotator/argument.py
--- a/rpython/annotator/argument.py
+++ b/rpython/annotator/argument.py
@@ -105,10 +105,6 @@
 # escape
 num_remainingkwds = len(keywords)
 for i, name in enumerate(keywords):
-# If name was not encoded as a string, it could be None. In 
that
-# case, it's definitely not going to be in the signature.
-if name is None:
-continue
 j = signature.find_argname(name)
 # if j == -1 nothing happens
 if j  input_argcount:
@@ -122,8 +118,8 @@
 if num_remainingkwds:
 if co_argcount == 0:
 raise ArgErrCount(num_args, num_kwds, signature, 
defaults_w, 0)
-raise ArgErrUnknownKwds(self.space, num_remainingkwds, 
keywords,
-kwds_mapping, self.keyword_names_w)
+raise ArgErrUnknownKwds(num_remainingkwds, keywords,
+kwds_mapping)
 
 # check for missing arguments and fill them from the kwds,
 # or with defaults, if available
@@ -298,31 +294,12 @@
 
 
 class ArgErrUnknownKwds(ArgErr):
-def __init__(self, space, num_remainingkwds, keywords, kwds_mapping,
- keyword_names_w):
+def __init__(self, num_remainingkwds, keywords, kwds_mapping):
 name = ''
 self.num_kwds = num_remainingkwds
 if num_remainingkwds == 1:
-for i in range(len(keywords)):
-if i not in kwds_mapping:
-name = keywords[i]
-if name is None:
-# We'll assume it's unicode. Encode it.
-# Careful, I *think* it should not be possible to
-# get an IndexError here but you never know.
-try:
-if keyword_names_w is None:
-raise IndexError
-# note: negative-based indexing from the end
-w_name = keyword_names_w[i - len(keywords)]
-except IndexError:
-name = '?'
-else:
-w_enc = space.wrap(space.sys.defaultencoding)
-w_err = space.wrap(replace)
-w_name = space.call_method(w_name, encode, w_enc,
-   w_err)
-name = space.str_w(w_name)
+for name in keywords:
+if name not in kwds_mapping:
 break
 self.kwd_name = name
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy less-stringly-ops: Turn ArgsFT.keywords into a dict

2013-11-18 Thread rlamy
Author: Ronan Lamy ronan.l...@gmail.com
Branch: less-stringly-ops
Changeset: r68224:ec91da17a267
Date: 2013-10-31 18:40 +
http://bitbucket.org/pypy/pypy/changeset/ec91da17a267/

Log:Turn ArgsFT.keywords into a dict

diff --git a/rpython/annotator/argument.py b/rpython/annotator/argument.py
--- a/rpython/annotator/argument.py
+++ b/rpython/annotator/argument.py
@@ -5,14 +5,13 @@
 
 class ArgumentsForTranslation(object):
 w_starstararg = None
-def __init__(self, args_w, keywords=None, keywords_w=None,
+def __init__(self, args_w, keywords=None,
  w_stararg=None, w_starstararg=None):
 self.w_stararg = w_stararg
 assert w_starstararg is None
 assert isinstance(args_w, list)
 self.arguments_w = args_w
-self.keywords = keywords or []
-self.keywords_w = keywords_w or []
+self.keywords = keywords or {}
 
 def __repr__(self):
  NOT_RPYTHON 
@@ -20,8 +19,7 @@
 if not self.keywords:
 return '%s(%s)' % (name, self.arguments_w,)
 else:
-return '%s(%s, %s, %s)' % (name, self.arguments_w,
-   self.keywords, self.keywords_w)
+return '%s(%s, %s)' % (name, self.arguments_w, self.keywords)
 
 @property
 def positional_args(self):
@@ -52,12 +50,12 @@
 def prepend(self, w_firstarg): # used often
 Return a new Arguments with a new argument inserted first.
 return ArgumentsForTranslation([w_firstarg] + self.arguments_w,
-   self.keywords, self.keywords_w, 
self.w_stararg,
+   self.keywords, self.w_stararg,
self.w_starstararg)
 
 def copy(self):
 return ArgumentsForTranslation(self.arguments_w, self.keywords,
-self.keywords_w, self.w_stararg, self.w_starstararg)
+self.w_stararg, self.w_starstararg)
 
 def _match_signature(self, scope_w, signature, defaults_w=None):
 Parse args and kwargs according to the signature of a code object,
@@ -92,18 +90,17 @@
 
 # handle keyword arguments
 num_remainingkwds = 0
-keywords_w = self.keywords_w
 kwds_mapping = None
 if num_kwds:
 # kwds_mapping maps target indexes in the scope (minus 
input_argcount)
-# to positions in the keywords_w list
-kwds_mapping = [-1] * (co_argcount - input_argcount)
+# to keyword names
+kwds_mapping = []
 # match the keywords given at the call site to the argument names
 # the called function takes
 # this function must not take a scope_w, to make the scope not
 # escape
 num_remainingkwds = len(keywords)
-for i, name in enumerate(keywords):
+for name in keywords:
 j = signature.find_argname(name)
 # if j == -1 nothing happens
 if j  input_argcount:
@@ -111,7 +108,7 @@
 if j = 0:
 raise ArgErrMultipleValues(name)
 else:
-kwds_mapping[j - input_argcount] = i # map to the right 
index
+kwds_mapping.append(name)
 num_remainingkwds -= 1
 
 if num_remainingkwds:
@@ -126,14 +123,11 @@
 if input_argcount  co_argcount:
 def_first = co_argcount - (0 if defaults_w is None else 
len(defaults_w))
 j = 0
-kwds_index = -1
 for i in range(input_argcount, co_argcount):
-if kwds_mapping is not None:
-kwds_index = kwds_mapping[j]
-j += 1
-if kwds_index = 0:
-scope_w[i] = keywords_w[kwds_index]
-continue
+name = signature.argnames[i]
+if name in keywords:
+scope_w[i] = keywords[name]
+continue
 defnum = i - def_first
 if defnum = 0:
 scope_w[i] = defaults_w[defnum]
@@ -144,8 +138,7 @@
 
 def unpack(self):
 Return a ([w1,w2...], {'kw':w3...}) pair.
-kwds_w = dict(zip(self.keywords, self.keywords_w))
-return self.positional_args, kwds_w
+return self.positional_args, self.keywords
 
 def match_signature(self, signature, defaults_w):
 Parse args and kwargs according to the signature of a code object,
@@ -169,7 +162,7 @@
 args_w = data_w[:cnt] + stararg_w
 assert len(args_w) == need_cnt
 assert not self.keywords
-return ArgumentsForTranslation(args_w, [], [])
+return ArgumentsForTranslation(args_w, {})
 else:
 data_w = data_w[:-1]
 assert len(data_w) == cnt
@@ -177,7 +170,7 @@
 args_w 

[pypy-commit] pypy less-stringly-ops: kill all (broken by design) support for **-unpacking

2013-11-18 Thread rlamy
Author: Ronan Lamy ronan.l...@gmail.com
Branch: less-stringly-ops
Changeset: r68225:cda622311685
Date: 2013-11-18 03:49 +
http://bitbucket.org/pypy/pypy/changeset/cda622311685/

Log:kill all (broken by design) support for **-unpacking

diff --git a/rpython/annotator/argument.py b/rpython/annotator/argument.py
--- a/rpython/annotator/argument.py
+++ b/rpython/annotator/argument.py
@@ -4,11 +4,8 @@
 from rpython.annotator.model import SomeTuple
 
 class ArgumentsForTranslation(object):
-w_starstararg = None
-def __init__(self, args_w, keywords=None,
- w_stararg=None, w_starstararg=None):
+def __init__(self, args_w, keywords=None, w_stararg=None):
 self.w_stararg = w_stararg
-assert w_starstararg is None
 assert isinstance(args_w, list)
 self.arguments_w = args_w
 self.keywords = keywords or {}
@@ -50,12 +47,11 @@
 def prepend(self, w_firstarg): # used often
 Return a new Arguments with a new argument inserted first.
 return ArgumentsForTranslation([w_firstarg] + self.arguments_w,
-   self.keywords, self.w_stararg,
-   self.w_starstararg)
+   self.keywords, self.w_stararg)
 
 def copy(self):
 return ArgumentsForTranslation(self.arguments_w, self.keywords,
-self.w_stararg, self.w_starstararg)
+self.w_stararg)
 
 def _match_signature(self, scope_w, signature, defaults_w=None):
 Parse args and kwargs according to the signature of a code object,
@@ -173,7 +169,7 @@
 return ArgumentsForTranslation(args_w, dict(zip(self.keywords, 
keywords_w)))
 
 @classmethod
-def fromshape(cls, (shape_cnt, shape_keys, shape_star, shape_stst), 
data_w):
+def fromshape(cls, (shape_cnt, shape_keys, shape_star), data_w):
 args_w = data_w[:shape_cnt]
 p = end_keys = shape_cnt + len(shape_keys)
 if shape_star:
@@ -181,30 +177,22 @@
 p += 1
 else:
 w_star = None
-if shape_stst:
-w_starstar = data_w[p]
-p += 1
-else:
-w_starstar = None
 return cls(args_w, dict(zip(shape_keys, data_w[shape_cnt:end_keys])),
-w_star, w_starstar)
+w_star)
 
 def flatten(self):
  Argument - list of w_objects together with shape information 

-shape_cnt, shape_keys, shape_star, shape_stst = self._rawshape()
+shape_cnt, shape_keys, shape_star = self._rawshape()
 data_w = self.arguments_w + [self.keywords[key] for key in shape_keys]
 if shape_star:
 data_w.append(self.w_stararg)
-if shape_stst:
-data_w.append(self.w_starstararg)
-return (shape_cnt, shape_keys, shape_star, shape_stst), data_w
+return (shape_cnt, shape_keys, shape_star), data_w
 
 def _rawshape(self, nextra=0):
 shape_cnt = len(self.arguments_w) + nextra  # Number of positional args
 shape_keys = tuple(sorted(self.keywords))
 shape_star = self.w_stararg is not None   # Flag: presence of *arg
-shape_stst = self.w_starstararg is not None  # Flag: presence of **kwds
-return shape_cnt, shape_keys, shape_star, shape_stst
+return shape_cnt, shape_keys, shape_star
 
 
 def rawshape(args, nextra=0):
diff --git a/rpython/annotator/builtin.py b/rpython/annotator/builtin.py
--- a/rpython/annotator/builtin.py
+++ b/rpython/annotator/builtin.py
@@ -307,7 +307,7 @@
 r_func, nimplicitarg = s_repr.const.get_r_implfunc()
 
 nbargs = len(args_s) + nimplicitarg
-s_sigs = r_func.get_s_signatures((nbargs, (), False, False))
+s_sigs = r_func.get_s_signatures((nbargs, (), False))
 if len(s_sigs) != 1:
 raise TyperError(cannot hlinvoke callable %r with not uniform
  annotations: %r % (s_repr.const,
diff --git a/rpython/annotator/test/test_annrpython.py 
b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -1065,8 +1065,9 @@
 gf2 = graphof(a, f2)
 gf3 = graphof(a, f3)
 
-assert fam1.calltables == {(2, (), False, False): [{fdesc1: gf1}], (1, 
(), False, False): [{fdesc1: gf1}]}
-assert fam2.calltables == {(1, (), False, False): [{fdesc2: gf2, 
fdesc3: gf3}]}
+assert fam1.calltables == {(2, (), False): [{fdesc1: gf1}],
+   (1, (), False): [{fdesc1: gf1}]}
+assert fam2.calltables == {(1, (), False): [{fdesc2: gf2, fdesc3: 
gf3}]}
 
 def test_pbc_call_ins(self):
 class A(object):
@@ -1117,14 +1118,14 @@
 gfA_m = graphof(a, A.m.im_func)
 gfC_m = graphof(a, C.m.im_func)
 
-assert famB_n.calltables == {(1, (), False, False): 
[{mdescB_n.funcdesc: gfB_n}] }
-assert famA_m.calltables == {(1, (), False, 

[pypy-commit] pypy less-stringly-ops: make ArgsFT.keywords always be a list

2013-11-18 Thread rlamy
Author: Ronan Lamy ronan.l...@gmail.com
Branch: less-stringly-ops
Changeset: r68223:9c0b00eeb262
Date: 2013-10-31 03:42 +
http://bitbucket.org/pypy/pypy/changeset/9c0b00eeb262/

Log:make ArgsFT.keywords always be a list

diff --git a/rpython/annotator/argument.py b/rpython/annotator/argument.py
--- a/rpython/annotator/argument.py
+++ b/rpython/annotator/argument.py
@@ -11,9 +11,8 @@
 assert w_starstararg is None
 assert isinstance(args_w, list)
 self.arguments_w = args_w
-self.keywords = keywords
-self.keywords_w = keywords_w
-self.keyword_names_w = None
+self.keywords = keywords or []
+self.keywords_w = keywords_w or []
 
 def __repr__(self):
  NOT_RPYTHON 
@@ -71,7 +70,7 @@
 
 args_w = self.positional_args
 num_args = len(args_w)
-keywords = self.keywords or []
+keywords = self.keywords
 num_kwds = len(keywords)
 
 # put as many positional input arguments into place as available
@@ -145,7 +144,7 @@
 
 def unpack(self):
 Return a ([w1,w2...], {'kw':w3...}) pair.
-kwds_w = dict(zip(self.keywords, self.keywords_w)) if self.keywords 
else {}
+kwds_w = dict(zip(self.keywords, self.keywords_w))
 return self.positional_args, kwds_w
 
 def match_signature(self, signature, defaults_w):
@@ -177,9 +176,8 @@
 assert len(data_w) = need_cnt
 args_w = data_w[:need_cnt]
 _kwds_w = dict(zip(argnames[need_cnt:], data_w[need_cnt:]))
-keywords = self.keywords or []
-keywords_w = [_kwds_w[key] for key in keywords]
-return ArgumentsForTranslation(args_w, keywords, keywords_w)
+keywords_w = [_kwds_w[key] for key in self.keywords]
+return ArgumentsForTranslation(args_w, self.keywords, keywords_w)
 
 @classmethod
 def fromshape(cls, (shape_cnt, shape_keys, shape_star, shape_stst), 
data_w):
@@ -210,15 +208,11 @@
 return (shape_cnt, shape_keys, shape_star, shape_stst), data_w
 
 def _rawshape(self, nextra=0):
-shape_cnt = len(self.arguments_w) + nextra   # Number of 
positional args
-if self.keywords:
-shape_keys = self.keywords[:]# List of keywords 
(strings)
-shape_keys.sort()
-else:
-shape_keys = []
+shape_cnt = len(self.arguments_w) + nextra  # Number of positional args
+shape_keys = tuple(sorted(self.keywords))
 shape_star = self.w_stararg is not None   # Flag: presence of *arg
-shape_stst = self.w_starstararg is not None # Flag: presence of **kwds
-return shape_cnt, tuple(shape_keys), shape_star, shape_stst # 
shape_keys are sorted
+shape_stst = self.w_starstararg is not None  # Flag: presence of **kwds
+return shape_cnt, shape_keys, shape_star, shape_stst
 
 
 def rawshape(args, nextra=0):
diff --git a/rpython/annotator/test/test_argument.py 
b/rpython/annotator/test/test_argument.py
--- a/rpython/annotator/test/test_argument.py
+++ b/rpython/annotator/test/test_argument.py
@@ -23,8 +23,8 @@
 args1 = args.prepend(thingy)
 assert args1 is not args
 assert args1.arguments_w == [thingy, 0]
-assert args1.keywords is args.keywords
-assert args1.keywords_w is args.keywords_w
+assert args1.keywords == args.keywords
+assert args1.keywords_w == args.keywords_w
 
 def test_fixedunpacked(self):
 args = MockArgs([], [k], [1])
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] buildbot default: merge add-header-to-nightly

2013-11-18 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: 
Changeset: r898:3f8d7754ec20
Date: 2013-11-18 23:00 +0100
http://bitbucket.org/pypy/buildbot/changeset/3f8d7754ec20/

Log:merge add-header-to-nightly

diff --git a/bot2/pypybuildbot/pypylist.py b/bot2/pypybuildbot/pypylist.py
--- a/bot2/pypybuildbot/pypylist.py
+++ b/bot2/pypybuildbot/pypylist.py
@@ -5,7 +5,8 @@
 import cgi
 import urllib
 import sys
-from twisted.web.static import File, DirectoryLister
+from twisted.web.static import File, formatFileSize
+from buildbot.status.web.base import DirectoryLister
 
 class PyPyTarball(object):
 
@@ -142,98 +143,39 @@
 names = File.listNames(self)
 if is_pypy_dir(names):
 names = self.sortBuildNames(names)
-Listener = PyPyDirectoryLister
 else:
 names = self.sortDirectoryNames(File.listEntities(self))
-Listener = DirectoryLister
+Listener = PyPyDirectoryLister
 return Listener(self.path,
 names,
 self.contentTypes,
 self.contentEncodings,
 self.defaultType)
 
-class NumpyStatusList(File):
-pass
-
 class PyPyDirectoryLister(DirectoryLister):
-template = html
-head
-title%(header)s/title
-style
-.even{ background-color: #eee}
-.odd { background-color: #dedede }
-.even-passed { background-color: #caffd8 }
-.odd-passed  { background-color: #a3feba }
-.even-failed { background-color: #ff }
-.odd-failed  { background-color: #ff9797 }
-
-.summary_link {
-color: black;
-text-decoration: none;
-}
-.summary_link:hover {
-color: blue;
-text-decoration: underline;
-}
-
-.icon { text-align: center }
-.listing {
-margin-left: auto;
-margin-right: auto;
-width: 50%%;
-padding: 0.1em;
-}
-
-body { border: 0; padding: 0; margin: 0; background-color: #efefef; }
-h1 {padding: 0.1em; background-color: #777; color: white; border-bottom: thin 
white dashed;}
-td,th {padding-left: 0.5em; padding-right: 0.5em; }
-
-/style
-/head
-
-body
-h1%(header)s/h1
-
-table
-thead
-tr
-thFilename/th
-thSize/th
-thDate/th
-thiown/i tests/th
-thiapplevel/i tests/th
-/tr
-/thead
-tbody
-%(tableContent)s
-/tbody
-/table
-
-/body
-/html
-
-
-linePattern = tr class=%(class)s
-tda href=%(href)s%(text)s/a/td
-td%(size)s/td
-td%(date)s/td
-td class=%(own_summary_class)s%(own_summary)s/td
-td class=%(app_summary_class)s%(app_summary)s/td
-/tr
-
+'''template based, uses master/templates/directory.html
+'''
 
 def render(self, request):
 self.status = request.site.buildbot_service.getStatus()
 return DirectoryLister.render(self, request)
 
-def _buildTableContent(self, elements):
-tableContent = []
+def _getFilesAndDirectories(self, directory):
+dirs, files = DirectoryLister._getFilesAndDirectories(self, directory)
 rowClasses = itertools.cycle(['odd', 'even'])
-for element, rowClass in zip(elements, rowClasses):
-element[class] = rowClass
-self._add_test_results(element, rowClass)
-tableContent.append(self.linePattern % element)
-return tableContent
+for f, rowClass in zip(files, rowClasses):
+f[class] = rowClass
+self._add_test_results(f, rowClass)
+for d in dirs:
+dirname = urllib.unquote(d['href'])
+dd = py.path.local(self.path).join(dirname)
+date = datetime.date.fromtimestamp(dd.mtime())
+d['date'] = date.isoformat()
+# Assume dir is non-recursive
+size = sum([f.size() for f in dd.listdir() if f.isfile()])
+d['size'] = formatFileSize(size)
+
+return dirs, files
 
 def _add_test_results(self, element, rowClass):
 filename = urllib.unquote(element['href'])
@@ -292,3 +234,6 @@
 else:
 return rowClass + '-failed'
 
+class NumpyStatusList(PyPyList):
+pass
+
diff --git a/master/templates/directory.html b/master/templates/directory.html
new file mode 100644
--- /dev/null
+++ b/master/templates/directory.html
@@ -0,0 +1,94 @@
+{% extends layout.html %}
+{% block morehead %}
+style
+.even{ background-color: #eee}
+.odd { background-color: #dedede }
+.even-passed { background-color: #caffd8 }
+.odd-passed  { background-color: #a3feba }
+.even-failed { background-color: #ff }
+.odd-failed  { background-color: #ff9797 }
+
+.summary_link {
+color: black;
+text-decoration: none;
+}
+.summary_link:hover {
+color: blue;
+text-decoration: underline;
+}
+
+.icon { text-align: center }
+.listing {
+margin-left: auto;
+margin-right: auto;
+width: 50;
+padding: 0.1em;
+}
+
+body { border: 0; padding: 0; margin: 0; background-color: #efefef; }
+td,th {padding-left: 

[pypy-commit] buildbot add-header-to-nightly: close branch

2013-11-18 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: add-header-to-nightly
Changeset: r897:76938234d843
Date: 2013-11-18 23:00 +0100
http://bitbucket.org/pypy/buildbot/changeset/76938234d843/

Log:close branch

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


[pypy-commit] pypy default: support order argument for array.tostring

2013-11-18 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r68229:5898d0122baa
Date: 2013-11-18 19:47 -0500
http://bitbucket.org/pypy/pypy/changeset/5898d0122baa/

Log:support order argument for array.tostring

diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -93,7 +93,11 @@
 def descr_fill(self, space, w_value):
 self.fill(self.get_dtype().coerce(space, w_value))
 
-def descr_tostring(self, space):
+def descr_tostring(self, space, w_order=None):
+order = order_converter(space, w_order, NPY_CORDER)
+if order == NPY_FORTRANORDER:
+raise OperationError(space.w_NotImplementedError, space.wrap(
+unsupported value for order))
 return space.wrap(loop.tostring(space, self))
 
 def getitem_filter(self, space, arr):
diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -2829,6 +2829,15 @@
 assert array([1, 2, 3], 'i2')[::2].tostring() == '\x01\x00\x03\x00'
 assert array([1, 2, 3], 'i2')[::2].tostring() == '\x00\x01\x00\x03'
 assert array(0, dtype='i2').tostring() == '\x00\x00'
+a = array([[1, 2], [3, 4]], dtype='i1')
+for order in (None, False, 'C', 'K', 'a'):
+assert a.tostring(order) == '\x01\x02\x03\x04'
+import sys
+for order in (True, 'F'):
+if '__pypy__' in sys.builtin_module_names:
+raises(NotImplementedError, a.tostring, order)
+else:
+assert a.tostring(order) == '\x01\x03\x02\x04'
 
 
 class AppTestRepr(BaseNumpyAppTest):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy voidtype_strformat: cleanup

2013-11-18 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: voidtype_strformat
Changeset: r68227:03bd65055e04
Date: 2013-11-18 19:32 -0500
http://bitbucket.org/pypy/pypy/changeset/03bd65055e04/

Log:cleanup

diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -3107,8 +3107,8 @@
[[7, 8, 9], [10, 11, 12]]])],
   dtype=dt)
 s = str(a)
-assert s.endswith([('', 1.0, 8.0, [[[1, 2, 3], [4, 5, 6]], [[7, 
8, 9], [10, 11, 12]]])])
-
+assert s.endswith([('', 1.0, 8.0, [[[1, 2, 3], [4, 5, 6]],  \
+  [[7, 8, 9], [10, 11, 12]]])])
 
 def test_issue_1589(self):
 import numpypy as numpy
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: cleanup

2013-11-18 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r68228:911cd20bb189
Date: 2013-11-18 19:35 -0500
http://bitbucket.org/pypy/pypy/changeset/911cd20bb189/

Log:cleanup

diff --git a/pypy/module/micronumpy/test/test_numarray.py 
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -68,7 +68,8 @@
 assert s.start == 1
 assert s.strides == [2, 10, 50]
 assert s.backstrides == [6, 40, 100]
-s = create_slice(self.space, a, [Chunk(1, 5, 3, 2), Chunk(1, 2, 1, 1), 
Chunk(1, 0, 0, 1)])
+s = create_slice(self.space, a, [Chunk(1, 5, 3, 2), Chunk(1, 2, 1, 1),
+ Chunk(1, 0, 0, 1)])
 assert s.shape == [2, 1]
 assert s.strides == [3, 10]
 assert s.backstrides == [3, 0]
@@ -2052,7 +2053,8 @@
 a = array([1, 2], dtype=int64)
 data = a.__reduce__()
 
-assert data[2][4] == 
'\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00'
+assert data[2][4] == '\x01\x00\x00\x00\x00\x00\x00\x00' \
+ '\x02\x00\x00\x00\x00\x00\x00\x00'
 
 pickled_data = dumps(a)
 assert (loads(pickled_data) == a).all()
@@ -2800,9 +2802,11 @@
 assert k[0] == dtype('float16').type(5.)
 dt =  array([5],dtype='longfloat').dtype
 if dt.itemsize == 12:
-m = fromstring('\x00\x00\x00\x00\x00\x00\x00\xa0\x01@\x00\x00', 
dtype='float96')
+m = fromstring('\x00\x00\x00\x00\x00\x00\x00\xa0\x01@\x00\x00',
+   dtype='float96')
 elif dt.itemsize == 16:
-m = 
fromstring('\x00\x00\x00\x00\x00\x00\x00\xa0\x01@\x00\x00\x00\x00\x00\x00', 
dtype='float128')
+m = fromstring('\x00\x00\x00\x00\x00\x00\x00\xa0\x01@\x00\x00' \
+   '\x00\x00\x00\x00', dtype='float128')
 elif dt.itemsize == 8:
 skip('longfloat is float64')
 else:
@@ -3027,7 +3031,8 @@
 from numpypy import dtype, array, zeros
 
 d = dtype([(x, int, 3), (y, float, 5)])
-a = array([([1, 2, 3], [0.5, 1.5, 2.5, 3.5, 4.5]), ([4, 5, 6], [5.5, 
6.5, 7.5, 8.5, 9.5])], dtype=d)
+a = array([([1, 2, 3], [0.5, 1.5, 2.5, 3.5, 4.5]),
+   ([4, 5, 6], [5.5, 6.5, 7.5, 8.5, 9.5])], dtype=d)
 
 for v in ['x', u'x', 0, -2]:
 assert (a[0][v] == [1, 2, 3]).all()
@@ -3037,7 +3042,8 @@
 assert (a[1][v] == [5.5, 6.5, 7.5, 8.5, 9.5]).all()
 for v in [-3, 2]:
 exc = raises(IndexError, a[0][%d] % v)
-assert exc.value.message == invalid index (%d) % (v + 2 if v  0 
else v)
+assert exc.value.message == invalid index (%d) % \
+(v + 2 if v  0 else v)
 exc = raises(IndexError, a[0]['z'])
 assert exc.value.message == invalid index
 exc = raises(IndexError, a[0][None])
@@ -3107,7 +3113,8 @@
 from numpypy import dtype, array
 
 d = dtype([(x, int, 3), (y, float, 5)])
-a = array([([1, 2, 3], [0.5, 1.5, 2.5, 3.5, 4.5]), ([4, 5, 6], [5.5, 
6.5, 7.5, 8.5, 9.5])], dtype=d)
+a = array([([1, 2, 3], [0.5, 1.5, 2.5, 3.5, 4.5]),
+   ([4, 5, 6], [5.5, 6.5, 7.5, 8.5, 9.5])], dtype=d)
 
 assert len(list(a[0])) == 2
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: provide dtype.descr for simple dtypes

2013-11-18 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r68230:38abc15e315d
Date: 2013-11-18 20:10 -0500
http://bitbucket.org/pypy/pypy/changeset/38abc15e315d/

Log:provide dtype.descr for simple dtypes

diff --git a/pypy/module/micronumpy/interp_dtype.py 
b/pypy/module/micronumpy/interp_dtype.py
--- a/pypy/module/micronumpy/interp_dtype.py
+++ b/pypy/module/micronumpy/interp_dtype.py
@@ -151,6 +151,14 @@
 endian = NPY_NATBYTE
 return space.wrap(%s%s%s % (endian, basic, size))
 
+def descr_get_descr(self, space):
+if not self.is_record_type():
+return space.newlist([space.newtuple([space.wrap(),
+  self.descr_get_str(space)])])
+else:
+raise OperationError(space.w_NotImplementedError, space.wrap(
+descr not implemented for record types))
+
 def descr_get_base(self, space):
 return space.wrap(self.base)
 
@@ -447,6 +455,7 @@
 fields = GetSetProperty(W_Dtype.descr_get_fields),
 names = GetSetProperty(W_Dtype.descr_get_names),
 hasobject = GetSetProperty(W_Dtype.descr_get_hasobject),
+descr = GetSetProperty(W_Dtype.descr_get_descr),
 )
 W_Dtype.typedef.acceptable_as_base_class = False
 
diff --git a/pypy/module/micronumpy/test/test_dtypes.py 
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -832,6 +832,17 @@
 assert x.dtype == int8
 assert (x == array(42)).all()
 
+def test_descr(self):
+import numpy as np
+assert np.dtype('i8').descr == [('', 'i8')]
+assert np.dtype('|S4').descr == [('', '|S4')]
+d = [('test', 'i8'), ('blah', 'i2', (2, 3))]
+import sys
+if '__pypy__' in sys.builtin_module_names:
+raises(NotImplementedError, np.dtype(d).descr)
+else:
+assert np.dtype(d).descr == d
+
 class AppTestStrUnicodeDtypes(BaseNumpyAppTest):
 def test_mro(self):
 from numpypy import str_, unicode_, character, flexible, generic
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy less-stringly-ops: make ArgumentsForTranslation a subclass of CallSpec

2013-11-18 Thread rlamy
Author: Ronan Lamy ronan.l...@gmail.com
Branch: less-stringly-ops
Changeset: r68231:5f4e3a547a2c
Date: 2013-11-18 22:07 +
http://bitbucket.org/pypy/pypy/changeset/5f4e3a547a2c/

Log:make ArgumentsForTranslation a subclass of CallSpec

diff --git a/rpython/annotator/argument.py b/rpython/annotator/argument.py
--- a/rpython/annotator/argument.py
+++ b/rpython/annotator/argument.py
@@ -2,22 +2,9 @@
 Arguments objects.
 
 from rpython.annotator.model import SomeTuple
+from rpython.flowspace.argument import CallSpec
 
-class ArgumentsForTranslation(object):
-def __init__(self, args_w, keywords=None, w_stararg=None):
-self.w_stararg = w_stararg
-assert isinstance(args_w, list)
-self.arguments_w = args_w
-self.keywords = keywords or {}
-
-def __repr__(self):
- NOT_RPYTHON 
-name = self.__class__.__name__
-if not self.keywords:
-return '%s(%s)' % (name, self.arguments_w,)
-else:
-return '%s(%s, %s)' % (name, self.arguments_w, self.keywords)
-
+class ArgumentsForTranslation(CallSpec):
 @property
 def positional_args(self):
 if self.w_stararg is not None:
diff --git a/rpython/flowspace/argument.py b/rpython/flowspace/argument.py
--- a/rpython/flowspace/argument.py
+++ b/rpython/flowspace/argument.py
@@ -83,6 +83,14 @@
 self.arguments_w = args_w
 self.keywords = keywords or {}
 
+def __repr__(self):
+ NOT_RPYTHON 
+name = self.__class__.__name__
+if not self.keywords:
+return '%s(%s)' % (name, self.arguments_w,)
+else:
+return '%s(%s, %s)' % (name, self.arguments_w, self.keywords)
+
 def flatten(self):
  Argument - list of w_objects together with shape information 

 shape_cnt  = len(self.arguments_w)# Number of positional args
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: whoops

2013-11-18 Thread mattip
Author: Matti Picus matti.pi...@gmail.com
Branch: 
Changeset: r68233:f265ce8a2524
Date: 2013-11-19 07:48 +0200
http://bitbucket.org/pypy/pypy/changeset/f265ce8a2524/

Log:whoops

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -10,6 +10,6 @@
 .. branch: numpy-newbyteorder
 Clean up numpy types, add newbyteorder functionality
 
-.. branch windows-packaging
+.. branch: windows-packaging
 Package tk/tcl runtime with win32
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit