[pypy-commit] pypy stm-gc: hg merge default

arigo noreply at buildbot.pypy.org
Sun Feb 12 11:59:50 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r52388:6a3921493c66
Date: 2012-02-12 11:59 +0100
http://bitbucket.org/pypy/pypy/changeset/6a3921493c66/

Log:	hg merge default

diff --git a/ctypes_configure/cbuild.py b/ctypes_configure/cbuild.py
--- a/ctypes_configure/cbuild.py
+++ b/ctypes_configure/cbuild.py
@@ -206,8 +206,9 @@
     cfiles += eci.separate_module_files
     include_dirs = list(eci.include_dirs)
     library_dirs = list(eci.library_dirs)
-    if sys.platform == 'darwin':    # support Fink & Darwinports
-        for s in ('/sw/', '/opt/local/'):
+    if (sys.platform == 'darwin' or    # support Fink & Darwinports
+            sys.platform.startswith('freebsd')):
+        for s in ('/sw/', '/opt/local/', '/usr/local/'):
             if s + 'include' not in include_dirs and \
                os.path.exists(s + 'include'):
                 include_dirs.append(s + 'include')
@@ -380,9 +381,9 @@
             self.link_extra += ['-pthread']
         if sys.platform == 'win32':
             self.link_extra += ['/DEBUG'] # generate .pdb file
-        if sys.platform == 'darwin':
-            # support Fink & Darwinports
-            for s in ('/sw/', '/opt/local/'):
+        if (sys.platform == 'darwin' or    # support Fink & Darwinports
+                sys.platform.startswith('freebsd')):
+            for s in ('/sw/', '/opt/local/', '/usr/local/'):
                 if s + 'include' not in self.include_dirs and \
                    os.path.exists(s + 'include'):
                     self.include_dirs.append(s + 'include')
@@ -395,7 +396,6 @@
             self.outputfilename = py.path.local(cfilenames[0]).new(ext=ext)
         else: 
             self.outputfilename = py.path.local(outputfilename)
-        self.eci = eci
 
     def build(self, noerr=False):
         basename = self.outputfilename.new(ext='')
@@ -436,7 +436,7 @@
             old = cfile.dirpath().chdir() 
             try: 
                 res = compiler.compile([cfile.basename], 
-                                       include_dirs=self.eci.include_dirs,
+                                       include_dirs=self.include_dirs,
                                        extra_preargs=self.compile_extra)
                 assert len(res) == 1
                 cobjfile = py.path.local(res[0]) 
@@ -445,9 +445,9 @@
             finally: 
                 old.chdir() 
         compiler.link_executable(objects, str(self.outputfilename),
-                                 libraries=self.eci.libraries,
+                                 libraries=self.libraries,
                                  extra_preargs=self.link_extra,
-                                 library_dirs=self.eci.library_dirs)
+                                 library_dirs=self.library_dirs)
 
 def build_executable(*args, **kwds):
     noerr = kwds.pop('noerr', False)
diff --git a/lib_pypy/datetime.py b/lib_pypy/datetime.py
--- a/lib_pypy/datetime.py
+++ b/lib_pypy/datetime.py
@@ -1520,7 +1520,7 @@
     def utcfromtimestamp(cls, t):
         "Construct a UTC datetime from a POSIX timestamp (like time.time())."
         t, frac = divmod(t, 1.0)
-        us = round(frac * 1e6)
+        us = int(round(frac * 1e6))
 
         # If timestamp is less than one microsecond smaller than a
         # full second, us can be rounded up to 1000000.  In this case,
diff --git a/lib_pypy/numpy.py b/lib_pypy/numpy.py
new file mode 100644
--- /dev/null
+++ b/lib_pypy/numpy.py
@@ -0,0 +1,5 @@
+raise ImportError(
+    "The 'numpy' module of PyPy is in-development and not complete. "
+    "To try it out anyway, you can either import from 'numpypy', "
+    "or just write 'import numpypy' first in your program and then "
+    "import from 'numpy' as usual.")
diff --git a/lib_pypy/numpypy/__init__.py b/lib_pypy/numpypy/__init__.py
--- a/lib_pypy/numpypy/__init__.py
+++ b/lib_pypy/numpypy/__init__.py
@@ -1,2 +1,5 @@
 from _numpypy import *
 from .core import *
+
+import sys
+sys.modules.setdefault('numpy', sys.modules['numpypy'])
diff --git a/lib_pypy/numpypy/core/numeric.py b/lib_pypy/numpypy/core/numeric.py
--- a/lib_pypy/numpypy/core/numeric.py
+++ b/lib_pypy/numpypy/core/numeric.py
@@ -1,6 +1,7 @@
 
-from _numpypy import array, ndarray, int_, float_ #, complex_# , longlong
+from _numpypy import array, ndarray, int_, float_, bool_ #, complex_# , longlong
 from _numpypy import concatenate
+import math
 import sys
 import _numpypy as multiarray # ARGH
 from numpypy.core.arrayprint import array2string
@@ -309,3 +310,13 @@
 set_string_function(array_repr, 1)
 
 little_endian = (sys.byteorder == 'little')
+
+Inf = inf = infty = Infinity = PINF = float('inf')
+NINF = float('-inf')
+PZERO = 0.0
+NZERO = -0.0
+nan = NaN = NAN = float('nan')
+False_ = bool_(False)
+True_ = bool_(True)
+e = math.e
+pi = math.pi
\ No newline at end of file
diff --git a/py/_io/terminalwriter.py b/py/_io/terminalwriter.py
--- a/py/_io/terminalwriter.py
+++ b/py/_io/terminalwriter.py
@@ -271,16 +271,24 @@
                     ('srWindow', SMALL_RECT),
                     ('dwMaximumWindowSize', COORD)]
 
+    _GetStdHandle = ctypes.windll.kernel32.GetStdHandle
+    _GetStdHandle.argtypes = [wintypes.DWORD]
+    _GetStdHandle.restype = wintypes.HANDLE
     def GetStdHandle(kind):
-        return ctypes.windll.kernel32.GetStdHandle(kind)
+        return _GetStdHandle(kind)
 
-    SetConsoleTextAttribute = \
-        ctypes.windll.kernel32.SetConsoleTextAttribute
-
+    SetConsoleTextAttribute = ctypes.windll.kernel32.SetConsoleTextAttribute
+    SetConsoleTextAttribute.argtypes = [wintypes.HANDLE, wintypes.WORD]
+    SetConsoleTextAttribute.restype = wintypes.BOOL
+        
+    _GetConsoleScreenBufferInfo = \
+        ctypes.windll.kernel32.GetConsoleScreenBufferInfo
+    _GetConsoleScreenBufferInfo.argtypes = [wintypes.HANDLE, 
+                                ctypes.POINTER(CONSOLE_SCREEN_BUFFER_INFO)]
+    _GetConsoleScreenBufferInfo.restype = wintypes.BOOL
     def GetConsoleInfo(handle):
         info = CONSOLE_SCREEN_BUFFER_INFO()
-        ctypes.windll.kernel32.GetConsoleScreenBufferInfo(\
-            handle, ctypes.byref(info))
+        _GetConsoleScreenBufferInfo(handle, ctypes.byref(info))
         return info
 
     def _getdimensions():
diff --git a/pypy/doc/getting-started-python.rst b/pypy/doc/getting-started-python.rst
--- a/pypy/doc/getting-started-python.rst
+++ b/pypy/doc/getting-started-python.rst
@@ -103,18 +103,22 @@
 executable. The executable behaves mostly like a normal Python interpreter::
 
     $ ./pypy-c
-    Python 2.7.0 (61ef2a11b56a, Mar 02 2011, 03:00:11)
-    [PyPy 1.6.0 with GCC 4.4.3] on linux2
+    Python 2.7.2 (0e28b379d8b3, Feb 09 2012, 19:41:03)
+    [PyPy 1.8.0 with GCC 4.4.3] on linux2
     Type "help", "copyright", "credits" or "license" for more information.
     And now for something completely different: ``this sentence is false''
     >>>> 46 - 4
     42
     >>>> from test import pystone
     >>>> pystone.main()
-    Pystone(1.1) time for 50000 passes = 0.280017
-    This machine benchmarks at 178561 pystones/second
-    >>>>
+    Pystone(1.1) time for 50000 passes = 0.220015
+    This machine benchmarks at 227257 pystones/second
+    >>>> pystone.main()
+    Pystone(1.1) time for 50000 passes = 0.060004
+    This machine benchmarks at 833278 pystones/second
+    >>>> 
 
+Note that pystone gets faster as the JIT kicks in.
 This executable can be moved around or copied on other machines; see
 Installation_ below.
 
diff --git a/pypy/doc/getting-started.rst b/pypy/doc/getting-started.rst
--- a/pypy/doc/getting-started.rst
+++ b/pypy/doc/getting-started.rst
@@ -53,14 +53,15 @@
 PyPy is ready to be executed as soon as you unpack the tarball or the zip
 file, with no need to install it in any specific location::
 
-    $ tar xf pypy-1.7-linux.tar.bz2
-
-    $ ./pypy-1.7/bin/pypy
-    Python 2.7.1 (?, Apr 27 2011, 12:44:21)
-    [PyPy 1.7.0 with GCC 4.4.3] on linux2
+    $ tar xf pypy-1.8-linux.tar.bz2
+    $ ./pypy-1.8/bin/pypy
+    Python 2.7.2 (0e28b379d8b3, Feb 09 2012, 19:41:03)
+    [PyPy 1.8.0 with GCC 4.4.3] on linux2
     Type "help", "copyright", "credits" or "license" for more information.
-    And now for something completely different: ``implementing LOGO in LOGO:
-    "turtles all the way down"''
+    And now for something completely different: ``it seems to me that once you
+    settle on an execution / object model and / or bytecode format, you've already
+    decided what languages (where the 's' seems superfluous) support is going to be
+    first class for''
     >>>>
 
 If you want to make PyPy available system-wide, you can put a symlink to the
@@ -75,14 +76,14 @@
 
     $ curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
 
-    $ ./pypy-1.7/bin/pypy distribute_setup.py
+    $ ./pypy-1.8/bin/pypy distribute_setup.py
 
-    $ ./pypy-1.7/bin/pypy get-pip.py
+    $ ./pypy-1.8/bin/pypy get-pip.py
 
-    $ ./pypy-1.7/bin/pip install pygments  # for example
+    $ ./pypy-1.8/bin/pip install pygments  # for example
 
-3rd party libraries will be installed in ``pypy-1.7/site-packages``, and
-the scripts in ``pypy-1.7/bin``.
+3rd party libraries will be installed in ``pypy-1.8/site-packages``, and
+the scripts in ``pypy-1.8/bin``.
 
 Installing using virtualenv
 ---------------------------
diff --git a/pypy/doc/index.rst b/pypy/doc/index.rst
--- a/pypy/doc/index.rst
+++ b/pypy/doc/index.rst
@@ -15,7 +15,7 @@
 
 * `FAQ`_: some frequently asked questions.
 
-* `Release 1.7`_: the latest official release
+* `Release 1.8`_: the latest official release
 
 * `PyPy Blog`_: news and status info about PyPy 
 
@@ -75,7 +75,7 @@
 .. _`Getting Started`: getting-started.html
 .. _`Papers`: extradoc.html
 .. _`Videos`: video-index.html
-.. _`Release 1.7`: http://pypy.org/download.html
+.. _`Release 1.8`: http://pypy.org/download.html
 .. _`speed.pypy.org`: http://speed.pypy.org
 .. _`RPython toolchain`: translation.html
 .. _`potential project ideas`: project-ideas.html
@@ -120,9 +120,9 @@
 Windows, on top of .NET, and on top of Java.
 To dig into PyPy it is recommended to try out the current
 Mercurial default branch, which is always working or mostly working,
-instead of the latest release, which is `1.7`__.
+instead of the latest release, which is `1.8`__.
 
-.. __: release-1.7.0.html
+.. __: release-1.8.0.html
 
 PyPy is mainly developed on Linux and Mac OS X.  Windows is supported,
 but platform-specific bugs tend to take longer before we notice and fix
diff --git a/pypy/doc/jit-hooks.rst b/pypy/doc/jit-hooks.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/jit-hooks.rst
@@ -0,0 +1,66 @@
+JIT hooks in PyPy
+=================
+
+There are several hooks in the `pypyjit` module that may help you with
+understanding what's pypy's JIT doing while running your program. There
+are three functions related to that coming from the `pypyjit` module:
+
+* `set_optimize_hook`::
+
+    Set a compiling hook that will be called each time a loop is optimized,
+    but before assembler compilation. This allows to add additional
+    optimizations on Python level.
+    
+    The hook will be called with the following signature:
+    hook(jitdriver_name, loop_type, greenkey or guard_number, operations)
+
+    jitdriver_name is the name of this particular jitdriver, 'pypyjit' is
+    the main interpreter loop
+
+    loop_type can be either `loop` `entry_bridge` or `bridge`
+    in case loop is not `bridge`, greenkey will be a tuple of constants
+    or a string describing it.
+
+    for the interpreter loop` it'll be a tuple
+    (code, offset, is_being_profiled)
+
+    Note that jit hook is not reentrant. It means that if the code
+    inside the jit hook is itself jitted, it will get compiled, but the
+    jit hook won't be called for that.
+
+    Result value will be the resulting list of operations, or None
+
+* `set_compile_hook`::
+
+    Set a compiling hook that will be called each time a loop is compiled.
+    The hook will be called with the following signature:
+    hook(jitdriver_name, loop_type, greenkey or guard_number, operations,
+         assembler_addr, assembler_length)
+
+    jitdriver_name is the name of this particular jitdriver, 'pypyjit' is
+    the main interpreter loop
+
+    loop_type can be either `loop` `entry_bridge` or `bridge`
+    in case loop is not `bridge`, greenkey will be a tuple of constants
+    or a string describing it.
+
+    for the interpreter loop` it'll be a tuple
+    (code, offset, is_being_profiled)
+
+    assembler_addr is an integer describing where assembler starts,
+    can be accessed via ctypes, assembler_lenght is the lenght of compiled
+    asm
+
+    Note that jit hook is not reentrant. It means that if the code
+    inside the jit hook is itself jitted, it will get compiled, but the
+    jit hook won't be called for that.
+
+* `set_abort_hook`::
+
+    Set a hook (callable) that will be called each time there is tracing
+    aborted due to some reason.
+
+    The hook will be called as in: hook(jitdriver_name, greenkey, reason)
+
+    Where reason is the reason for abort, see documentation for set_compile_hook
+    for descriptions of other arguments.
diff --git a/pypy/doc/jit/index.rst b/pypy/doc/jit/index.rst
--- a/pypy/doc/jit/index.rst
+++ b/pypy/doc/jit/index.rst
@@ -21,6 +21,9 @@
 
 - Notes_ about the current work in PyPy
 
+- Hooks_ debugging facilities available to a python programmer
+
 
 .. _Overview: overview.html
 .. _Notes: pyjitpl5.html
+.. _Hooks: ../jit-hooks.html
diff --git a/pypy/doc/release-1.8.0.rst b/pypy/doc/release-1.8.0.rst
--- a/pypy/doc/release-1.8.0.rst
+++ b/pypy/doc/release-1.8.0.rst
@@ -2,16 +2,21 @@
 PyPy 1.8 - business as usual
 ============================
 
-We're pleased to announce the 1.8 release of PyPy. As became a habit, this
-release brings a lot of bugfixes, performance and memory improvements over
-the 1.7 release. The main highlight of the release is the introduction of
-list strategies which makes homogenous lists more efficient both in terms
-of performance and memory. Otherwise it's "business as usual" in the sense
-that performance improved roughly 10% on average since the previous release.
-You can download the PyPy 1.8 release here:
+We're pleased to announce the 1.8 release of PyPy. As habitual this
+release brings a lot of bugfixes, together with performance and memory
+improvements over the 1.7 release. The main highlight of the release
+is the introduction of `list strategies`_ which makes homogenous lists
+more efficient both in terms of performance and memory. This release
+also upgrades us from Python 2.7.1 compatibility to 2.7.2. Otherwise
+it's "business as usual" in the sense that performance improved
+roughly 10% on average since the previous release.
+
+you can download the PyPy 1.8 release here:
 
     http://pypy.org/download.html
 
+.. _`list strategies`: http://morepypy.blogspot.com/2011/10/more-compact-lists-with-list-strategies.html
+
 What is PyPy?
 =============
 
@@ -20,7 +25,8 @@
 due to its integrated tracing JIT compiler.
 
 This release supports x86 machines running Linux 32/64, Mac OS X 32/64 or
-Windows 32. Windows 64 work is ongoing, but not yet natively supported.
+Windows 32. Windows 64 work has been stalled, we would welcome a volunteer
+to handle that.
 
 .. _`pypy 1.8 and cpython 2.7.1`: http://speed.pypy.org
 
@@ -33,8 +39,8 @@
   the JIT performance in places that use such lists. There are also special
   strategies for unicode and string lists.
 
-* As usual, numerous performance improvements. There are too many examples
-  of python constructs that now should behave faster to list them.
+* As usual, numerous performance improvements. There are many examples
+  of python constructs that now should be faster; too many to list them.
 
 * Bugfixes and compatibility fixes with CPython.
 
@@ -44,9 +50,49 @@
   consult the `numpy status page`_. A tentative list of things that has
   been done:
 
-  xxxx # list it, multidim arrays in particular
+  * multi dimensional arrays
 
-* Fundraising XXX
+  * various sizes of dtypes
 
-.. _`numpy status page`: xxx
-.. _`numpy status update blog report`: xxx
+  * a lot of ufuncs
+
+  * a lot of other minor changes
+
+  Right now the `numpy` module is available under both `numpy` and `numpypy`
+  names. However, because it's incomplete, you have to `import numpypy` first
+  before doing any imports from `numpy`.
+
+* New JIT hooks that allow you to hook into the JIT process from your python
+  program. There is a `brief overview`_ of what they offer.
+
+* Standard library upgrade from 2.7.1 to 2.7.2.
+
+Ongoing work
+============
+
+As usual, there is quite a bit of ongoing work that either didn't make it to
+the release or is not ready yet. Highlights include:
+
+* Non-x86 backends for the JIT: ARMv7 (almost ready) and PPC64 (in progress)
+
+* Specialized type instances - allocate instances as efficient as C structs,
+  including type specialization
+
+* More numpy work
+
+* Since the last release there was a significant breakthrough in PyPy's
+  fundraising. We now have enough funds to work on first stages of `numpypy`_
+  and `py3k`_. We would like to thank again to everyone who donated.
+
+* It's also probably worth noting, we're considering donations for the
+  Software Transactional Memory project. You can read more about `our plans`_
+
+Cheers,
+The PyPy Team
+
+.. _`brief overview`: http://doc.pypy.org/en/latest/jit-hooks.html
+.. _`numpy status page`: http://buildbot.pypy.org/numpy-status/latest.html
+.. _`numpy status update blog report`: http://morepypy.blogspot.com/2012/01/numpypy-status-update.html
+.. _`numpypy`: http://pypy.org/numpydonate.html
+.. _`py3k`: http://pypy.org/py3donate.html
+.. _`our plans`: http://morepypy.blogspot.com/2012/01/transactional-memory-ii.html
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1340,6 +1340,15 @@
     def unicode_w(self, w_obj):
         return w_obj.unicode_w(self)
 
+    def unicode0_w(self, w_obj):
+        "Like unicode_w, but rejects strings with NUL bytes."
+        from pypy.rlib import rstring
+        result = w_obj.unicode_w(self)
+        if u'\x00' in result:
+            raise OperationError(self.w_TypeError, self.wrap(
+                    'argument must be a unicode string without NUL characters'))
+        return rstring.assert_str0(result)
+
     def realunicode_w(self, w_obj):
         # Like unicode_w, but only works if w_obj is really of type
         # 'unicode'.
@@ -1638,6 +1647,9 @@
     'UnicodeEncodeError',
     'UnicodeDecodeError',
     ]
+    
+if sys.platform.startswith("win"):
+    ObjSpace.ExceptionTable += ['WindowsError']
 
 ## Irregular part of the interface:
 #
diff --git a/pypy/interpreter/test/test_objspace.py b/pypy/interpreter/test/test_objspace.py
--- a/pypy/interpreter/test/test_objspace.py
+++ b/pypy/interpreter/test/test_objspace.py
@@ -178,6 +178,14 @@
         res = self.space.interp_w(Function, w(None), can_be_None=True)
         assert res is None
 
+    def test_str0_w(self):
+        space = self.space
+        w = space.wrap
+        assert space.str0_w(w("123")) == "123"
+        exc = space.raises_w(space.w_TypeError, space.str0_w, w("123\x004"))
+        assert space.unicode0_w(w(u"123")) == u"123"
+        exc = space.raises_w(space.w_TypeError, space.unicode0_w, w(u"123\x004"))
+
     def test_getindex_w(self):
         w_instance1 = self.space.appexec([], """():
             class X(object):
diff --git a/pypy/jit/codewriter/flatten.py b/pypy/jit/codewriter/flatten.py
--- a/pypy/jit/codewriter/flatten.py
+++ b/pypy/jit/codewriter/flatten.py
@@ -162,7 +162,9 @@
         if len(block.exits) == 1:
             # A single link, fall-through
             link = block.exits[0]
-            assert link.exitcase is None
+            assert link.exitcase in (None, False, True)
+            # the cases False or True should not really occur, but can show
+            # up in the manually hacked graphs for generators...
             self.make_link(link)
         #
         elif block.exitswitch is c_last_exception:
diff --git a/pypy/jit/codewriter/policy.py b/pypy/jit/codewriter/policy.py
--- a/pypy/jit/codewriter/policy.py
+++ b/pypy/jit/codewriter/policy.py
@@ -48,7 +48,7 @@
         mod = func.__module__ or '?'
         if mod.startswith('pypy.rpython.module.'):
             return True
-        if mod.startswith('pypy.translator.'): # XXX wtf?
+        if mod == 'pypy.translator.goal.nanos':    # more helpers
             return True
         return False
 
diff --git a/pypy/jit/metainterp/test/test_ajit.py b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -3706,6 +3706,18 @@
         # here it works again
         self.check_operations_history(guard_class=0, record_known_class=1)
 
+    def test_generator(self):
+        def g(n):
+            yield n+1
+            yield n+2
+            yield n+3
+        def f(n):
+            gen = g(n)
+            return gen.next() * gen.next() * gen.next()
+        res = self.interp_operations(f, [10])
+        assert res == 11 * 12 * 13
+        self.check_operations_history(int_add=3, int_mul=2)
+
 
 class TestLLtype(BaseLLtypeTests, LLJitMixin):
     def test_tagged(self):
diff --git a/pypy/module/_ffi/test/test__ffi.py b/pypy/module/_ffi/test/test__ffi.py
--- a/pypy/module/_ffi/test/test__ffi.py
+++ b/pypy/module/_ffi/test/test__ffi.py
@@ -190,6 +190,7 @@
 
     def test_convert_strings_to_char_p(self):
         """
+            DLLEXPORT
             long mystrlen(char* s)
             {
                 long len = 0;
@@ -215,6 +216,7 @@
     def test_convert_unicode_to_unichar_p(self):
         """
             #include <wchar.h>
+            DLLEXPORT
             long mystrlen_u(wchar_t* s)
             {
                 long len = 0;
@@ -241,6 +243,7 @@
 
     def test_keepalive_temp_buffer(self):
         """
+            DLLEXPORT
             char* do_nothing(char* s)
             {
                 return s;
@@ -525,5 +528,7 @@
         from _ffi import CDLL, types
         libfoo = CDLL(self.libfoo_name)
         raises(AttributeError, "libfoo.getfunc('I_do_not_exist', [], types.void)")
+        if self.iswin32:
+            skip("unix specific")
         libnone = CDLL(None)
         raises(AttributeError, "libnone.getfunc('I_do_not_exist', [], types.void)")
diff --git a/pypy/module/_file/test/test_file.py b/pypy/module/_file/test/test_file.py
--- a/pypy/module/_file/test/test_file.py
+++ b/pypy/module/_file/test/test_file.py
@@ -265,6 +265,13 @@
 
         if option.runappdirect:
             py.test.skip("works with internals of _file impl on py.py")
+        import platform
+        if platform.system() == 'Windows':
+            # XXX This test crashes until someone implements something like
+            # XXX verify_fd from
+            # XXX http://hg.python.org/cpython/file/80ddbd822227/Modules/posixmodule.c#l434
+            # XXX and adds it to fopen
+            assert False
 
         state = [0]
         def read(fd, n=None):
diff --git a/pypy/module/_io/test/test_fileio.py b/pypy/module/_io/test/test_fileio.py
--- a/pypy/module/_io/test/test_fileio.py
+++ b/pypy/module/_io/test/test_fileio.py
@@ -134,7 +134,10 @@
         assert a == 'a\nbxxxxxxx'
 
     def test_nonblocking_read(self):
-        import os, fcntl
+        try:
+            import os, fcntl
+        except ImportError:
+            skip("need fcntl to set nonblocking mode")
         r_fd, w_fd = os.pipe()
         # set nonblocking
         fcntl.fcntl(r_fd, fcntl.F_SETFL, os.O_NONBLOCK)
diff --git a/pypy/module/cpyext/include/patchlevel.h b/pypy/module/cpyext/include/patchlevel.h
--- a/pypy/module/cpyext/include/patchlevel.h
+++ b/pypy/module/cpyext/include/patchlevel.h
@@ -21,12 +21,12 @@
 /* Version parsed out into numeric values */
 #define PY_MAJOR_VERSION	2
 #define PY_MINOR_VERSION	7
-#define PY_MICRO_VERSION	1
+#define PY_MICRO_VERSION	2
 #define PY_RELEASE_LEVEL	PY_RELEASE_LEVEL_FINAL
 #define PY_RELEASE_SERIAL	0
 
 /* Version as a string */
-#define PY_VERSION		"2.7.1"
+#define PY_VERSION		"2.7.2"
 
 /* PyPy version as a string */
 #define PYPY_VERSION "1.8.1"
diff --git a/pypy/module/micronumpy/__init__.py b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -31,7 +31,7 @@
         'concatenate': 'interp_numarray.concatenate',
 
         'set_string_function': 'appbridge.set_string_function',
-        
+
         'count_reduce_items': 'interp_numarray.count_reduce_items',
 
         'True_': 'types.Bool.True',
@@ -95,6 +95,7 @@
         ("tan", "tan"),
         ('bitwise_and', 'bitwise_and'),
         ('bitwise_or', 'bitwise_or'),
+        ('bitwise_xor', 'bitwise_xor'),
         ('bitwise_not', 'invert'),
         ('isnan', 'isnan'),
         ('isinf', 'isinf'),
@@ -111,8 +112,5 @@
         'min': 'app_numpy.min',
         'identity': 'app_numpy.identity',
         'max': 'app_numpy.max',
-        'inf': 'app_numpy.inf',
-        'e': 'app_numpy.e',
-        'pi': 'app_numpy.pi',
         'arange': 'app_numpy.arange',
     }
diff --git a/pypy/module/micronumpy/app_numpy.py b/pypy/module/micronumpy/app_numpy.py
--- a/pypy/module/micronumpy/app_numpy.py
+++ b/pypy/module/micronumpy/app_numpy.py
@@ -3,11 +3,6 @@
 import _numpypy
 
 
-inf = float("inf")
-e = math.e
-pi = math.pi
-
-
 def average(a):
     # This implements a weighted average, for now we don't implement the
     # weighting, just the average part!
@@ -59,7 +54,7 @@
     if not hasattr(a, "max"):
         a = _numpypy.array(a)
     return a.max(axis)
-    
+
 def arange(start, stop=None, step=1, dtype=None):
     '''arange([start], stop[, step], dtype=None)
     Generate values in the half-interval [start, stop).
diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -80,7 +80,15 @@
     descr_sub = _binop_impl("subtract")
     descr_mul = _binop_impl("multiply")
     descr_div = _binop_impl("divide")
+    descr_truediv = _binop_impl("true_divide")
+    descr_mod = _binop_impl("mod")
     descr_pow = _binop_impl("power")
+    descr_lshift = _binop_impl("left_shift")
+    descr_rshift = _binop_impl("right_shift")
+    descr_and = _binop_impl("bitwise_and")
+    descr_or = _binop_impl("bitwise_or")
+    descr_xor = _binop_impl("bitwise_xor")
+
     descr_eq = _binop_impl("equal")
     descr_ne = _binop_impl("not_equal")
     descr_lt = _binop_impl("less")
@@ -91,9 +99,30 @@
     descr_radd = _binop_right_impl("add")
     descr_rsub = _binop_right_impl("subtract")
     descr_rmul = _binop_right_impl("multiply")
+    descr_rdiv = _binop_right_impl("divide")
+    descr_rtruediv = _binop_right_impl("true_divide")
+    descr_rmod = _binop_right_impl("mod")
+    descr_rpow = _binop_right_impl("power")
+    descr_rlshift = _binop_right_impl("left_shift")
+    descr_rrshift = _binop_right_impl("right_shift")
+    descr_rand = _binop_right_impl("bitwise_and")
+    descr_ror = _binop_right_impl("bitwise_or")
+    descr_rxor = _binop_right_impl("bitwise_xor")
 
+    descr_pos = _unaryop_impl("positive")
     descr_neg = _unaryop_impl("negative")
     descr_abs = _unaryop_impl("absolute")
+    descr_invert = _unaryop_impl("invert")
+
+    def descr_divmod(self, space, w_other):
+        w_quotient = self.descr_div(space, w_other)
+        w_remainder = self.descr_mod(space, w_other)
+        return space.newtuple([w_quotient, w_remainder])
+
+    def descr_rdivmod(self, space, w_other):
+        w_quotient = self.descr_rdiv(space, w_other)
+        w_remainder = self.descr_rmod(space, w_other)
+        return space.newtuple([w_quotient, w_remainder])
 
     def item(self, space):
         return self.get_dtype(space).itemtype.to_builtin_type(space, self)
@@ -174,11 +203,29 @@
     __sub__ = interp2app(W_GenericBox.descr_sub),
     __mul__ = interp2app(W_GenericBox.descr_mul),
     __div__ = interp2app(W_GenericBox.descr_div),
+    __truediv__ = interp2app(W_GenericBox.descr_truediv),
+    __mod__ = interp2app(W_GenericBox.descr_mod),
+    __divmod__ = interp2app(W_GenericBox.descr_divmod),
     __pow__ = interp2app(W_GenericBox.descr_pow),
+    __lshift__ = interp2app(W_GenericBox.descr_lshift),
+    __rshift__ = interp2app(W_GenericBox.descr_rshift),
+    __and__ = interp2app(W_GenericBox.descr_and),
+    __or__ = interp2app(W_GenericBox.descr_or),
+    __xor__ = interp2app(W_GenericBox.descr_xor),
 
     __radd__ = interp2app(W_GenericBox.descr_radd),
     __rsub__ = interp2app(W_GenericBox.descr_rsub),
     __rmul__ = interp2app(W_GenericBox.descr_rmul),
+    __rdiv__ = interp2app(W_GenericBox.descr_rdiv),
+    __rtruediv__ = interp2app(W_GenericBox.descr_rtruediv),
+    __rmod__ = interp2app(W_GenericBox.descr_rmod),
+    __rdivmod__ = interp2app(W_GenericBox.descr_rdivmod),
+    __rpow__ = interp2app(W_GenericBox.descr_rpow),
+    __rlshift__ = interp2app(W_GenericBox.descr_rlshift),
+    __rrshift__ = interp2app(W_GenericBox.descr_rrshift),
+    __rand__ = interp2app(W_GenericBox.descr_rand),
+    __ror__ = interp2app(W_GenericBox.descr_ror),
+    __rxor__ = interp2app(W_GenericBox.descr_rxor),
 
     __eq__ = interp2app(W_GenericBox.descr_eq),
     __ne__ = interp2app(W_GenericBox.descr_ne),
@@ -187,8 +234,10 @@
     __gt__ = interp2app(W_GenericBox.descr_gt),
     __ge__ = interp2app(W_GenericBox.descr_ge),
 
+    __pos__ = interp2app(W_GenericBox.descr_pos),
     __neg__ = interp2app(W_GenericBox.descr_neg),
     __abs__ = interp2app(W_GenericBox.descr_abs),
+    __invert__ = interp2app(W_GenericBox.descr_invert),
 
     tolist = interp2app(W_GenericBox.item),
 )
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
@@ -4,17 +4,17 @@
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
 from pypy.module.micronumpy import (interp_ufuncs, interp_dtype, interp_boxes,
     signature, support, loop)
+from pypy.module.micronumpy.appbridge import get_appbridge_cache
+from pypy.module.micronumpy.dot import multidim_dot, match_dot_shapes
+from pypy.module.micronumpy.interp_iter import (ArrayIterator,
+    SkipLastAxisIterator, Chunk, ViewIterator)
 from pypy.module.micronumpy.strides import (calculate_slice_strides,
     shape_agreement, find_shape_and_elems, get_shape_from_iterable,
     calc_new_strides, to_coords)
-from dot import multidim_dot, match_dot_shapes
 from pypy.rlib import jit
+from pypy.rlib.rstring import StringBuilder
 from pypy.rpython.lltypesystem import lltype, rffi
 from pypy.tool.sourcetools import func_with_new_name
-from pypy.rlib.rstring import StringBuilder
-from pypy.module.micronumpy.interp_iter import (ArrayIterator,
-    SkipLastAxisIterator, Chunk, ViewIterator)
-from pypy.module.micronumpy.appbridge import get_appbridge_cache
 
 
 count_driver = jit.JitDriver(
@@ -101,8 +101,14 @@
     descr_sub = _binop_impl("subtract")
     descr_mul = _binop_impl("multiply")
     descr_div = _binop_impl("divide")
+    descr_truediv = _binop_impl("true_divide")
+    descr_mod = _binop_impl("mod")
     descr_pow = _binop_impl("power")
-    descr_mod = _binop_impl("mod")
+    descr_lshift = _binop_impl("left_shift")
+    descr_rshift = _binop_impl("right_shift")
+    descr_and = _binop_impl("bitwise_and")
+    descr_or = _binop_impl("bitwise_or")
+    descr_xor = _binop_impl("bitwise_xor")
 
     descr_eq = _binop_impl("equal")
     descr_ne = _binop_impl("not_equal")
@@ -111,8 +117,10 @@
     descr_gt = _binop_impl("greater")
     descr_ge = _binop_impl("greater_equal")
 
-    descr_and = _binop_impl("bitwise_and")
-    descr_or = _binop_impl("bitwise_or")
+    def descr_divmod(self, space, w_other):
+        w_quotient = self.descr_div(space, w_other)
+        w_remainder = self.descr_mod(space, w_other)
+        return space.newtuple([w_quotient, w_remainder])
 
     def _binop_right_impl(ufunc_name):
         def impl(self, space, w_other):
@@ -127,8 +135,19 @@
     descr_rsub = _binop_right_impl("subtract")
     descr_rmul = _binop_right_impl("multiply")
     descr_rdiv = _binop_right_impl("divide")
+    descr_rtruediv = _binop_right_impl("true_divide")
+    descr_rmod = _binop_right_impl("mod")
     descr_rpow = _binop_right_impl("power")
-    descr_rmod = _binop_right_impl("mod")
+    descr_rlshift = _binop_right_impl("left_shift")
+    descr_rrshift = _binop_right_impl("right_shift")
+    descr_rand = _binop_right_impl("bitwise_and")
+    descr_ror = _binop_right_impl("bitwise_or")
+    descr_rxor = _binop_right_impl("bitwise_xor")
+
+    def descr_rdivmod(self, space, w_other):
+        w_quotient = self.descr_rdiv(space, w_other)
+        w_remainder = self.descr_rmod(space, w_other)
+        return space.newtuple([w_quotient, w_remainder])
 
     def _reduce_ufunc_impl(ufunc_name, promote_to_largest=False):
         def impl(self, space, w_axis=None):
@@ -1227,21 +1246,36 @@
     __pos__ = interp2app(BaseArray.descr_pos),
     __neg__ = interp2app(BaseArray.descr_neg),
     __abs__ = interp2app(BaseArray.descr_abs),
+    __invert__ = interp2app(BaseArray.descr_invert),
     __nonzero__ = interp2app(BaseArray.descr_nonzero),
 
     __add__ = interp2app(BaseArray.descr_add),
     __sub__ = interp2app(BaseArray.descr_sub),
     __mul__ = interp2app(BaseArray.descr_mul),
     __div__ = interp2app(BaseArray.descr_div),
+    __truediv__ = interp2app(BaseArray.descr_truediv),
+    __mod__ = interp2app(BaseArray.descr_mod),
+    __divmod__ = interp2app(BaseArray.descr_divmod),
     __pow__ = interp2app(BaseArray.descr_pow),
-    __mod__ = interp2app(BaseArray.descr_mod),
+    __lshift__ = interp2app(BaseArray.descr_lshift),
+    __rshift__ = interp2app(BaseArray.descr_rshift),
+    __and__ = interp2app(BaseArray.descr_and),
+    __or__ = interp2app(BaseArray.descr_or),
+    __xor__ = interp2app(BaseArray.descr_xor),
 
     __radd__ = interp2app(BaseArray.descr_radd),
     __rsub__ = interp2app(BaseArray.descr_rsub),
     __rmul__ = interp2app(BaseArray.descr_rmul),
     __rdiv__ = interp2app(BaseArray.descr_rdiv),
+    __rtruediv__ = interp2app(BaseArray.descr_rtruediv),
+    __rmod__ = interp2app(BaseArray.descr_rmod),
+    __rdivmod__ = interp2app(BaseArray.descr_rdivmod),
     __rpow__ = interp2app(BaseArray.descr_rpow),
-    __rmod__ = interp2app(BaseArray.descr_rmod),
+    __rlshift__ = interp2app(BaseArray.descr_rlshift),
+    __rrshift__ = interp2app(BaseArray.descr_rrshift),
+    __rand__ = interp2app(BaseArray.descr_rand),
+    __ror__ = interp2app(BaseArray.descr_ror),
+    __rxor__ = interp2app(BaseArray.descr_rxor),
 
     __eq__ = interp2app(BaseArray.descr_eq),
     __ne__ = interp2app(BaseArray.descr_ne),
@@ -1250,10 +1284,6 @@
     __gt__ = interp2app(BaseArray.descr_gt),
     __ge__ = interp2app(BaseArray.descr_ge),
 
-    __and__ = interp2app(BaseArray.descr_and),
-    __or__ = interp2app(BaseArray.descr_or),
-    __invert__ = interp2app(BaseArray.descr_invert),
-
     __repr__ = interp2app(BaseArray.descr_repr),
     __str__ = interp2app(BaseArray.descr_str),
     __array_interface__ = GetSetProperty(BaseArray.descr_array_iface),
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
@@ -383,14 +383,17 @@
             ("subtract", "sub", 2),
             ("multiply", "mul", 2, {"identity": 1}),
             ("bitwise_and", "bitwise_and", 2, {"identity": 1,
-                                               'int_only': True}),
+                                               "int_only": True}),
             ("bitwise_or", "bitwise_or", 2, {"identity": 0,
-                                             'int_only': True}),
+                                             "int_only": True}),
+            ("bitwise_xor", "bitwise_xor", 2, {"int_only": True}),
             ("invert", "invert", 1, {"int_only": True}),
             ("divide", "div", 2, {"promote_bools": True}),
             ("true_divide", "div", 2, {"promote_to_float": True}),
             ("mod", "mod", 2, {"promote_bools": True}),
             ("power", "pow", 2, {"promote_bools": True}),
+            ("left_shift", "lshift", 2, {"int_only": True}),
+            ("right_shift", "rshift", 2, {"int_only": True}),
 
             ("equal", "eq", 2, {"comparison_func": True}),
             ("not_equal", "ne", 2, {"comparison_func": True}),
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
@@ -401,3 +401,33 @@
         else:
             assert issubclass(int64, int)
             assert int_ is int64
+
+    def test_operators(self):
+        from operator import truediv
+        from _numpypy import float64, int_, True_, False_
+
+        assert 5 / int_(2) == int_(2)
+        assert truediv(int_(3), int_(2)) == float64(1.5)
+        assert truediv(3, int_(2)) == float64(1.5)
+        assert int_(8) % int_(3) == int_(2)
+        assert 8 % int_(3) == int_(2)
+        assert divmod(int_(8), int_(3)) == (int_(2), int_(2))
+        assert divmod(8, int_(3)) == (int_(2), int_(2))
+        assert 2 ** int_(3) == int_(8)
+        assert int_(3) << int_(2) == int_(12)
+        assert 3 << int_(2) == int_(12)
+        assert int_(8) >> int_(2) == int_(2)
+        assert 8 >> int_(2) == int_(2)
+        assert int_(3) & int_(1) == int_(1)
+        assert 2 & int_(3) == int_(2)
+        assert int_(2) | int_(1) == int_(3)
+        assert 2 | int_(1) == int_(3)
+        assert int_(3) ^ int_(5) == int_(6)
+        assert True_ ^ False_ is True_
+        assert 5 ^ int_(3) == int_(6)
+
+        assert +int_(3) == int_(3)
+        assert ~int_(3) == int_(-4)
+
+        raises(TypeError, lambda: float64(3) & 1)
+
diff --git a/pypy/module/micronumpy/test/test_module.py b/pypy/module/micronumpy/test/test_module.py
--- a/pypy/module/micronumpy/test/test_module.py
+++ b/pypy/module/micronumpy/test/test_module.py
@@ -21,13 +21,3 @@
         from _numpypy import array, max
         assert max(range(10)) == 9
         assert max(array(range(10))) == 9
-
-    def test_constants(self):
-        import math
-        from _numpypy import inf, e, pi
-        assert type(inf) is float
-        assert inf == float("inf")
-        assert e == math.e
-        assert type(e) is float
-        assert pi == math.pi
-        assert type(pi) is float
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
@@ -579,7 +579,7 @@
 
     def test_div(self):
         from math import isnan
-        from _numpypy import array, dtype, inf
+        from _numpypy import array, dtype
 
         a = array(range(1, 6))
         b = a / a
@@ -600,15 +600,15 @@
         a = array([-1.0, 0.0, 1.0])
         b = array([0.0, 0.0, 0.0])
         c = a / b
-        assert c[0] == -inf
+        assert c[0] == float('-inf')
         assert isnan(c[1])
-        assert c[2] == inf
+        assert c[2] == float('inf')
 
         b = array([-0.0, -0.0, -0.0])
         c = a / b
-        assert c[0] == inf
+        assert c[0] == float('inf')
         assert isnan(c[1])
-        assert c[2] == -inf
+        assert c[2] == float('-inf')
 
     def test_div_other(self):
         from _numpypy import array
@@ -625,6 +625,59 @@
         for i in range(5):
             assert b[i] == i / 5.0
 
+    def test_truediv(self):
+        from operator import truediv
+        from _numpypy import arange
+
+        assert (truediv(arange(5), 2) == [0., .5, 1., 1.5, 2.]).all()
+        assert (truediv(2, arange(3)) == [float("inf"), 2., 1.]).all()
+
+    def test_divmod(self):
+        from _numpypy import arange
+
+        a, b = divmod(arange(10), 3)
+        assert (a == [0, 0, 0, 1, 1, 1, 2, 2, 2, 3]).all()
+        assert (b == [0, 1, 2, 0, 1, 2, 0, 1, 2, 0]).all()
+
+    def test_rdivmod(self):
+        from _numpypy import arange
+
+        a, b = divmod(3, arange(1, 5))
+        assert (a == [3, 1, 1, 0]).all()
+        assert (b == [0, 1, 0, 3]).all()
+
+    def test_lshift(self):
+        from _numpypy import array
+
+        a = array([0, 1, 2, 3])
+        assert (a << 2 == [0, 4, 8, 12]).all()
+        a = array([True, False])
+        assert (a << 2 == [4, 0]).all()
+        a = array([1.0])
+        raises(TypeError, lambda: a << 2)
+
+    def test_rlshift(self):
+        from _numpypy import arange
+
+        a = arange(3)
+        assert (2 << a == [2, 4, 8]).all()
+
+    def test_rshift(self):
+        from _numpypy import arange, array
+
+        a = arange(10)
+        assert (a >> 2 == [0, 0, 0, 0, 1, 1, 1, 1, 2, 2]).all()
+        a = array([True, False])
+        assert (a >> 1 == [0, 0]).all()
+        a = arange(3, dtype=float)
+        raises(TypeError, lambda: a >> 1)
+
+    def test_rrshift(self):
+        from _numpypy import arange
+
+        a = arange(5)
+        assert (2 >> a == [2, 1, 0, 0, 0]).all()
+
     def test_pow(self):
         from _numpypy import array
         a = array(range(5), float)
@@ -678,6 +731,30 @@
         for i in range(5):
             assert b[i] == i % 2
 
+    def test_rand(self):
+        from _numpypy import arange
+
+        a = arange(5)
+        assert (3 & a == [0, 1, 2, 3, 0]).all()
+
+    def test_ror(self):
+        from _numpypy import arange
+
+        a = arange(5)
+        assert (3 | a == [3, 3, 3, 3, 7]).all()
+
+    def test_xor(self):
+        from _numpypy import arange
+
+        a = arange(5)
+        assert (a ^ 3 == [3, 2, 1, 0, 7]).all()
+
+    def test_rxor(self):
+        from _numpypy import arange
+
+        a = arange(5)
+        assert (3 ^ a == [3, 2, 1, 0, 7]).all()
+
     def test_pos(self):
         from _numpypy import array
         a = array([1., -2., 3., -4., -5.])
diff --git a/pypy/module/micronumpy/test/test_ufuncs.py b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -312,9 +312,9 @@
 
     def test_arcsinh(self):
         import math
-        from _numpypy import arcsinh, inf
+        from _numpypy import arcsinh
 
-        for v in [inf, -inf, 1.0, math.e]:
+        for v in [float('inf'), float('-inf'), 1.0, math.e]:
             assert math.asinh(v) == arcsinh(v)
         assert math.isnan(arcsinh(float("nan")))
 
@@ -367,15 +367,15 @@
         b = add.reduce(a, 0, keepdims=True)
         assert b.shape == (1, 4)
         assert (add.reduce(a, 0, keepdims=True) == [12, 15, 18, 21]).all()
-        
 
     def test_bitwise(self):
-        from _numpypy import bitwise_and, bitwise_or, arange, array
+        from _numpypy import bitwise_and, bitwise_or, bitwise_xor, arange, array
         a = arange(6).reshape(2, 3)
         assert (a & 1 == [[0, 1, 0], [1, 0, 1]]).all()
         assert (a & 1 == bitwise_and(a, 1)).all()
         assert (a | 1 == [[1, 1, 3], [3, 5, 5]]).all()
         assert (a | 1 == bitwise_or(a, 1)).all()
+        assert (a ^ 3 == bitwise_xor(a, 3)).all()
         raises(TypeError, 'array([1.0]) & 1')
 
     def test_unary_bitops(self):
@@ -416,7 +416,7 @@
         assert count_reduce_items(a) == 24
         assert count_reduce_items(a, 1) == 3
         assert count_reduce_items(a, (1, 2)) == 3 * 4
-        
+
     def test_true_divide(self):
         from _numpypy import arange, array, true_divide
         assert (true_divide(arange(3), array([2, 2, 2])) == array([0, 0.5, 1])).all()
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
@@ -59,10 +59,6 @@
 class BaseType(object):
     def _unimplemented_ufunc(self, *args):
         raise NotImplementedError
-    # add = sub = mul = div = mod = pow = eq = ne = lt = le = gt = ge = max = \
-    #     min = copysign = pos = neg = abs = sign = reciprocal = fabs = floor = \
-    #     exp = sin = cos = tan = arcsin = arccos = arctan = arcsinh = \
-    #     arctanh = _unimplemented_ufunc
 
 class Primitive(object):
     _mixin_ = True
@@ -253,6 +249,10 @@
     def bitwise_or(self, v1, v2):
         return v1 | v2
 
+    @simple_binary_op
+    def bitwise_xor(self, v1, v2):
+        return v1 ^ v2
+
     @simple_unary_op
     def invert(self, v):
         return ~v
@@ -295,6 +295,14 @@
             v1 *= v1
         return res
 
+    @simple_binary_op
+    def lshift(self, v1, v2):
+        return v1 << v2
+
+    @simple_binary_op
+    def rshift(self, v1, v2):
+        return v1 >> v2
+
     @simple_unary_op
     def sign(self, v):
         if v > 0:
@@ -313,6 +321,10 @@
     def bitwise_or(self, v1, v2):
         return v1 | v2
 
+    @simple_binary_op
+    def bitwise_xor(self, v1, v2):
+        return v1 ^ v2
+
     @simple_unary_op
     def invert(self, v):
         return ~v
diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -48,7 +48,7 @@
         return fsencode_w(self.space, self.w_obj)
 
     def as_unicode(self):
-        return self.space.unicode_w(self.w_obj)
+        return self.space.unicode0_w(self.w_obj)
 
 class FileDecoder(object):
     def __init__(self, space, w_obj):
@@ -62,7 +62,7 @@
         space = self.space
         w_unicode = space.call_method(self.w_obj, 'decode',
                                       getfilesystemencoding(space))
-        return space.unicode_w(w_unicode)
+        return space.unicode0_w(w_unicode)
 
 @specialize.memo()
 def dispatch_filename(func, tag=0):
@@ -543,10 +543,16 @@
             dirname = FileEncoder(space, w_dirname)
             result = rposix.listdir(dirname)
             w_fs_encoding = getfilesystemencoding(space)
-            result_w = [
-                space.call_method(space.wrap(s), "decode", w_fs_encoding)
-                for s in result
-            ]
+            len_result = len(result)
+            result_w = [None] * len_result
+            for i in range(len_result):
+                w_bytes = space.wrap(result[i])
+                try:
+                    result_w[i] = space.call_method(w_bytes,
+                                                    "decode", w_fs_encoding)
+                except OperationError, e:
+                    # fall back to the original byte string
+                    result_w[i] = w_bytes
         else:
             dirname = space.str0_w(w_dirname)
             result = rposix.listdir(dirname)
diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -29,6 +29,7 @@
     mod.pdir = pdir
     unicode_dir = udir.ensure('fi\xc5\x9fier.txt', dir=True)
     unicode_dir.join('somefile').write('who cares?')
+    unicode_dir.join('caf\xe9').write('who knows?')
     mod.unicode_dir = unicode_dir
 
     # in applevel tests, os.stat uses the CPython os.stat.
@@ -308,14 +309,22 @@
                           'file2']
 
     def test_listdir_unicode(self):
+        import sys
         unicode_dir = self.unicode_dir
         if unicode_dir is None:
             skip("encoding not good enough")
         posix = self.posix
         result = posix.listdir(unicode_dir)
-        result.sort()
-        assert result == [u'somefile']
-        assert type(result[0]) is unicode
+        typed_result = [(type(x), x) for x in result]
+        assert (unicode, u'somefile') in typed_result
+        try:
+            u = "caf\xe9".decode(sys.getfilesystemencoding())
+        except UnicodeDecodeError:
+            # Could not decode, listdir returned the byte string
+            assert (str, "caf\xe9") in typed_result
+        else:
+            assert (unicode, u) in typed_result
+
 
     def test_access(self):
         pdir = self.pdir + '/file1'
diff --git a/pypy/module/posix/test/test_ztranslation.py b/pypy/module/posix/test/test_ztranslation.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/posix/test/test_ztranslation.py
@@ -0,0 +1,4 @@
+from pypy.objspace.fake.checkmodule import checkmodule
+
+def test_posix_translates():
+    checkmodule('posix')
\ No newline at end of file
diff --git a/pypy/module/pypyjit/__init__.py b/pypy/module/pypyjit/__init__.py
--- a/pypy/module/pypyjit/__init__.py
+++ b/pypy/module/pypyjit/__init__.py
@@ -13,6 +13,7 @@
         'ResOperation': 'interp_resop.WrappedOp',
         'DebugMergePoint': 'interp_resop.DebugMergePoint',
         'Box': 'interp_resop.WrappedBox',
+        'PARAMETER_DOCS': 'space.wrap(pypy.rlib.jit.PARAMETER_DOCS)',
     }
 
     def setup_after_space_initialization(self):
diff --git a/pypy/module/pypyjit/test/test_jit_setup.py b/pypy/module/pypyjit/test/test_jit_setup.py
--- a/pypy/module/pypyjit/test/test_jit_setup.py
+++ b/pypy/module/pypyjit/test/test_jit_setup.py
@@ -45,6 +45,12 @@
             pypyjit.set_compile_hook(None)
             pypyjit.set_param('default')
 
+    def test_doc(self):
+        import pypyjit
+        d = pypyjit.PARAMETER_DOCS
+        assert type(d) is dict
+        assert 'threshold' in d
+
 
 def test_interface_residual_call():
     space = gettestobjspace(usemodules=['pypyjit'])
diff --git a/pypy/module/sys/version.py b/pypy/module/sys/version.py
--- a/pypy/module/sys/version.py
+++ b/pypy/module/sys/version.py
@@ -7,7 +7,7 @@
 from pypy.interpreter import gateway
 
 #XXX # the release serial 42 is not in range(16)
-CPYTHON_VERSION            = (2, 7, 1, "final", 42)   #XXX # sync patchlevel.h
+CPYTHON_VERSION            = (2, 7, 2, "final", 42)   #XXX # sync patchlevel.h
 CPYTHON_API_VERSION        = 1013   #XXX # sync with include/modsupport.h
 
 PYPY_VERSION               = (1, 8, 1, "dev", 0)    #XXX # sync patchlevel.h
diff --git a/pypy/module/test_lib_pypy/numpypy/test_numpy.py b/pypy/module/test_lib_pypy/numpypy/test_numpy.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/test_lib_pypy/numpypy/test_numpy.py
@@ -0,0 +1,13 @@
+from pypy.conftest import gettestobjspace
+
+class AppTestNumpy:
+    def setup_class(cls):
+        cls.space = gettestobjspace(usemodules=['micronumpy'])
+
+    def test_imports(self):
+        try:
+            import numpy   # fails if 'numpypy' was not imported so far
+        except ImportError:
+            pass
+        import numpypy
+        import numpy     # works after 'numpypy' has been imported
diff --git a/pypy/module/test_lib_pypy/test_datetime.py b/pypy/module/test_lib_pypy/test_datetime.py
--- a/pypy/module/test_lib_pypy/test_datetime.py
+++ b/pypy/module/test_lib_pypy/test_datetime.py
@@ -22,3 +22,7 @@
             del os.environ["TZ"]
         else:
             os.environ["TZ"] = prev_tz
+
+def test_utcfromtimestamp_microsecond():
+    dt = datetime.datetime.utcfromtimestamp(0)
+    assert isinstance(dt.microsecond, int)
diff --git a/pypy/module/zipimport/interp_zipimport.py b/pypy/module/zipimport/interp_zipimport.py
--- a/pypy/module/zipimport/interp_zipimport.py
+++ b/pypy/module/zipimport/interp_zipimport.py
@@ -123,7 +123,9 @@
         self.prefix = prefix
 
     def getprefix(self, space):
-        return space.wrap(self.prefix)
+        if ZIPSEP == os.path.sep:
+            return space.wrap(self.prefix)
+        return space.wrap(self.prefix.replace(ZIPSEP, os.path.sep))    
 
     def _find_relative_path(self, filename):
         if filename.startswith(self.filename):
@@ -381,7 +383,7 @@
     prefix = name[len(filename):]
     if prefix.startswith(os.path.sep) or prefix.startswith(ZIPSEP):
         prefix = prefix[1:]
-    if prefix and not prefix.endswith(ZIPSEP):
+    if prefix and not prefix.endswith(ZIPSEP) and not prefix.endswith(os.path.sep):
         prefix += ZIPSEP
     w_result = space.wrap(W_ZipImporter(space, name, filename, zip_file, prefix))
     zip_cache.set(filename, w_result)
diff --git a/pypy/module/zipimport/test/test_undocumented.py b/pypy/module/zipimport/test/test_undocumented.py
--- a/pypy/module/zipimport/test/test_undocumented.py
+++ b/pypy/module/zipimport/test/test_undocumented.py
@@ -119,7 +119,7 @@
             zip_importer = zipimport.zipimporter(path)
             assert isinstance(zip_importer, zipimport.zipimporter)
             assert zip_importer.archive == zip_path
-            assert zip_importer.prefix == prefix
+            assert zip_importer.prefix == prefix.replace('/', os.path.sep)
             assert zip_path in zipimport._zip_directory_cache
         finally:
             self.cleanup_zipfile(self.created_paths)
diff --git a/pypy/module/zipimport/test/test_zipimport.py b/pypy/module/zipimport/test/test_zipimport.py
--- a/pypy/module/zipimport/test/test_zipimport.py
+++ b/pypy/module/zipimport/test/test_zipimport.py
@@ -15,7 +15,7 @@
     cpy's regression tests
     """
     compression = ZIP_STORED
-    pathsep = '/'
+    pathsep = os.path.sep
     
     def make_pyc(cls, space, co, mtime):
         data = marshal.dumps(co)
@@ -129,7 +129,7 @@
         self.writefile('sub/__init__.py', '')
         self.writefile('sub/yy.py', '')
         from zipimport import _zip_directory_cache, zipimporter
-        sub_importer = zipimporter(self.zipfile + '/sub')
+        sub_importer = zipimporter(self.zipfile + os.path.sep + 'sub')
         main_importer = zipimporter(self.zipfile)
 
         assert main_importer is not sub_importer
diff --git a/pypy/rlib/ropenssl.py b/pypy/rlib/ropenssl.py
--- a/pypy/rlib/ropenssl.py
+++ b/pypy/rlib/ropenssl.py
@@ -54,6 +54,7 @@
 
 ASN1_STRING = lltype.Ptr(lltype.ForwardReference())
 ASN1_ITEM = rffi.COpaquePtr('ASN1_ITEM')
+ASN1_ITEM_EXP = lltype.Ptr(lltype.FuncType([], ASN1_ITEM))
 X509_NAME = rffi.COpaquePtr('X509_NAME')
 
 class CConfig:
@@ -101,12 +102,11 @@
     X509_extension_st = rffi_platform.Struct(
         'struct X509_extension_st',
         [('value', ASN1_STRING)])
-    ASN1_ITEM_EXP = lltype.FuncType([], ASN1_ITEM)
     X509V3_EXT_D2I = lltype.FuncType([rffi.VOIDP, rffi.CCHARPP, rffi.LONG], 
                                      rffi.VOIDP)
     v3_ext_method = rffi_platform.Struct(
         'struct v3_ext_method',
-        [('it', lltype.Ptr(ASN1_ITEM_EXP)),
+        [('it', ASN1_ITEM_EXP),
          ('d2i', lltype.Ptr(X509V3_EXT_D2I))])
     GENERAL_NAME_st = rffi_platform.Struct(
         'struct GENERAL_NAME_st',
@@ -118,6 +118,8 @@
          ('block_size', rffi.INT)])
     EVP_MD_SIZE = rffi_platform.SizeOf('EVP_MD')
     EVP_MD_CTX_SIZE = rffi_platform.SizeOf('EVP_MD_CTX')
+    OPENSSL_EXPORT_VAR_AS_FUNCTION = rffi_platform.Defined(
+                                             "OPENSSL_EXPORT_VAR_AS_FUNCTION")
 
 
 for k, v in rffi_platform.configure(CConfig).items():
@@ -224,7 +226,10 @@
 ssl_external('i2a_ASN1_INTEGER', [BIO, ASN1_INTEGER], rffi.INT)
 ssl_external('ASN1_item_d2i', 
              [rffi.VOIDP, rffi.CCHARPP, rffi.LONG, ASN1_ITEM], rffi.VOIDP)
-ssl_external('ASN1_ITEM_ptr', [rffi.VOIDP], ASN1_ITEM, macro=True)
+if OPENSSL_EXPORT_VAR_AS_FUNCTION:             
+    ssl_external('ASN1_ITEM_ptr', [ASN1_ITEM_EXP], ASN1_ITEM, macro=True)
+else:    
+    ssl_external('ASN1_ITEM_ptr', [rffi.VOIDP], ASN1_ITEM, macro=True)
 
 ssl_external('sk_GENERAL_NAME_num', [GENERAL_NAMES], rffi.INT,
              macro=True)
diff --git a/pypy/rpython/module/ll_os.py b/pypy/rpython/module/ll_os.py
--- a/pypy/rpython/module/ll_os.py
+++ b/pypy/rpython/module/ll_os.py
@@ -43,7 +43,7 @@
     arglist = ['arg%d' % (i,) for i in range(len(signature))]
     transformed_arglist = arglist[:]
     for i, arg in enumerate(signature):
-        if arg is unicode:
+        if arg in (unicode, unicode0):
             transformed_arglist[i] = transformed_arglist[i] + '.as_unicode()'
 
     args = ', '.join(arglist)
@@ -67,7 +67,7 @@
     exec source.compile() in miniglobals
     new_func = miniglobals[func_name]
     specialized_args = [i for i in range(len(signature))
-                        if signature[i] in (unicode, None)]
+                        if signature[i] in (unicode, unicode0, None)]
     new_func = specialize.argtype(*specialized_args)(new_func)
 
     # Monkeypatch the function in pypy.rlib.rposix
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
@@ -60,7 +60,8 @@
     if sys.platform == 'win32':
         # Can't rename a DLL: it is always called 'libpypy-c.dll'
         for extra in ['libpypy-c.dll',
-                      'libexpat.dll', 'sqlite3.dll', 'msvcr90.dll']:
+                      'libexpat.dll', 'sqlite3.dll', 'msvcr90.dll',
+                      'libeay32.dll', 'ssleay32.dll']:
             p = pypy_c.dirpath().join(extra)
             if not p.check():
                 p = py.path.local.sysfind(extra)
@@ -125,7 +126,7 @@
             zf.close()
         else:
             archive = str(builddir.join(name + '.tar.bz2'))
-            if sys.platform == 'darwin':
+            if sys.platform == 'darwin' or sys.platform.startswith('freebsd'):
                 e = os.system('tar --numeric-owner -cvjf ' + archive + " " + name)
             else:
                 e = os.system('tar --owner=root --group=root --numeric-owner -cvjf ' + archive + " " + name)
diff --git a/pypy/translator/c/gc.py b/pypy/translator/c/gc.py
--- a/pypy/translator/c/gc.py
+++ b/pypy/translator/c/gc.py
@@ -46,8 +46,7 @@
         return ExternalCompilationInfo(
             pre_include_bits=['/* using %s */' % (gct.__class__.__name__,),
                               '#define MALLOC_ZERO_FILLED %d' % (gct.malloc_zero_filled,),
-                              ],
-            post_include_bits=['typedef void *GC_hidden_pointer;']
+                              ]
             )
 
     def get_prebuilt_hash(self, obj):
diff --git a/pypy/translator/c/gcc/trackgcroot.py b/pypy/translator/c/gcc/trackgcroot.py
--- a/pypy/translator/c/gcc/trackgcroot.py
+++ b/pypy/translator/c/gcc/trackgcroot.py
@@ -478,6 +478,7 @@
         'cvt', 'ucomi', 'comi', 'subs', 'subp' , 'adds', 'addp', 'xorp',
         'movap', 'movd', 'movlp', 'sqrtsd', 'movhpd',
         'mins', 'minp', 'maxs', 'maxp', 'unpck', 'pxor', 'por', # sse2
+        'shufps', 'shufpd',
         # arithmetic operations should not produce GC pointers
         'inc', 'dec', 'not', 'neg', 'or', 'and', 'sbb', 'adc',
         'shl', 'shr', 'sal', 'sar', 'rol', 'ror', 'mul', 'imul', 'div', 'idiv',
diff --git a/pypy/translator/goal/app_main.py b/pypy/translator/goal/app_main.py
--- a/pypy/translator/goal/app_main.py
+++ b/pypy/translator/goal/app_main.py
@@ -139,8 +139,14 @@
     items = pypyjit.defaults.items()
     items.sort()
     for key, value in items:
-        print '  --jit %s=N %s%s (default %s)' % (
-            key, ' '*(18-len(key)), pypyjit.PARAMETER_DOCS[key], value)
+        prefix = '  --jit %s=N %s' % (key, ' '*(18-len(key)))
+        doc = '%s (default %s)' % (pypyjit.PARAMETER_DOCS[key], value)
+        while len(doc) > 51:
+            i = doc[:51].rfind(' ')
+            print prefix + doc[:i]
+            doc = doc[i+1:]
+            prefix = ' '*len(prefix)
+        print prefix + doc
     print '  --jit off                  turn off the JIT'
 
 def print_version(*args):


More information about the pypy-commit mailing list