Commits

mattip  committed 09e6ceb Merge

merge default into branch

  • Participants
  • Parent commits 33c8a99, c915d5e
  • Branches missing-ndarray-attributes

Comments (0)

Files changed (85)

File lib-python/2.7/collections.py

 __all__ += _abcoll.__all__
 
 from _collections import deque, defaultdict
-from operator import itemgetter as _itemgetter
 from keyword import iskeyword as _iskeyword
 import sys as _sys
 import heapq as _heapq
         _fields = %(field_names)r \n
         def __new__(_cls, %(argtxt)s):
             'Create new instance of %(typename)s(%(argtxt)s)'
-            return _tuple.__new__(_cls, (%(argtxt)s)) \n
+            return tuple.__new__(_cls, (%(argtxt)s)) \n
         @classmethod
         def _make(cls, iterable, new=tuple.__new__, len=len):
             'Make a new %(typename)s object from a sequence or iterable'
             'Return self as a plain tuple.  Used by copy and pickle.'
             return tuple(self) \n\n''' % locals()
     for i, name in enumerate(field_names):
-        template += "        %s = _property(_itemgetter(%d), doc='Alias for field number %d')\n" % (name, i, i)
+        template += "        %s = property(lambda self: self[%d], doc='Alias for field number %d')\n" % (name, i, i)
     if verbose:
         print template
 
     # Execute the template string in a temporary namespace and
     # support tracing utilities by setting a value for frame.f_globals['__name__']
-    namespace = dict(_itemgetter=_itemgetter, __name__='namedtuple_%s' % typename,
-                     OrderedDict=OrderedDict, _property=property, _tuple=tuple)
+    namespace = {'__name__': 'namedtuple_%s' % typename,
+                 'OrderedDict': OrderedDict}
     try:
         exec template in namespace
     except SyntaxError, e:

File lib-python/2.7/inspect.py

                 raise TypeError('%s() takes exactly 0 arguments '
                                 '(%d given)' % (f_name, num_total))
         else:
-            raise TypeError('%s() takes no argument (%d given)' %
+            raise TypeError('%s() takes no arguments (%d given)' %
                             (f_name, num_total))
     for arg in args:
         if isinstance(arg, str) and arg in named:

File lib-python/2.7/site.py

 USER_SITE = None
 USER_BASE = None
 
+
 def makepath(*paths):
     dir = os.path.join(*paths)
     try:

File lib-python/2.7/sysconfig.py

         'data'   : '{base}',
         },
     'pypy': {
-        'stdlib': '{base}/lib-python',
-        'platstdlib': '{base}/lib-python',
-        'purelib': '{base}/lib-python',
-        'platlib': '{base}/lib-python',
+        'stdlib': '{base}/lib-python/{py_version_short}',
+        'platstdlib': '{base}/lib-python/{py_version_short}',
+        'purelib': '{base}/lib-python/{py_version_short}',
+        'platlib': '{base}/lib-python/{py_version_short}',
         'include': '{base}/include',
         'platinclude': '{base}/include',
         'scripts': '{base}/bin',

File lib-python/2.7/test/test_capi.py

     threading = None
 import _testcapi
 
+skips = []
+if test_support.check_impl_detail(pypy=True):
+    skips += [
+            'test_broken_memoryview',
+            'test_capsule',
+            'test_lazy_hash_inheritance',
+            'test_widechar',
+            'TestThreadState',
+            'TestPendingCalls',
+            ]
+
 @unittest.skipUnless(threading, 'Threading required for this test.')
 class TestPendingCalls(unittest.TestCase):
 
 def test_main():
 
     for name in dir(_testcapi):
-        if name.startswith('test_'):
+        if name.startswith('test_') and name not in skips:
             test = getattr(_testcapi, name)
             if test_support.verbose:
                 print "internal", name
             raise test_support.TestFailed, \
                   "Couldn't find main thread correctly in the list"
 
-    if threading:
+    if threading and 'TestThreadState' not in skips:
         import thread
         import time
         TestThreadState()
         t.start()
         t.join()
 
-    test_support.run_unittest(TestPendingCalls)
+    if 'TestPendingCalls' not in skips:
+        test_support.run_unittest(TestPendingCalls)
 
 if __name__ == "__main__":
     test_main()

File lib-python/2.7/test/test_itertools.py

         self.assertEqual(list(izip()), zip())
         self.assertRaises(TypeError, izip, 3)
         self.assertRaises(TypeError, izip, range(3), 3)
-
         self.assertEqual([tuple(list(pair)) for pair in izip('abc', 'def')],
                          zip('abc', 'def'))
         self.assertEqual([pair for pair in izip('abc', 'def')],
                          zip('abc', 'def'))
+
     @test_support.impl_detail("tuple reuse is specific to CPython")
     def test_izip_tuple_reuse(self):
         ids = map(id, izip('abc', 'def'))
                          zip('abc', 'def'))
         self.assertEqual([pair for pair in izip_longest('abc', 'def')],
                          zip('abc', 'def'))
+
     @test_support.impl_detail("tuple reuse is specific to CPython")
     def test_izip_longest_tuple_reuse(self):
         ids = map(id, izip_longest('abc', 'def'))

File lib-python/2.7/test/test_multiprocessing.py

 
         # Because we are using xmlrpclib for serialization instead of
         # pickle this will cause a serialization error.
-        self.assertRaises(Exception, queue.put, time.sleep)
+        self.assertRaises(Exception, queue.put, object)
 
         # Make queue finalizer run before the server is stopped
         del queue
         if not gc.isenabled():
             gc.enable()
             self.addCleanup(gc.disable)
-        thresholds = gc.get_threshold()
-        self.addCleanup(gc.set_threshold, *thresholds)
-        gc.set_threshold(10)
+        #thresholds = gc.get_threshold()
+        #self.addCleanup(gc.set_threshold, *thresholds)
+        #gc.set_threshold(10)
 
         # perform numerous block allocations, with cyclic references to make
         # sure objects are collected asynchronously by the gc
     def test_synchronize(self):
         self.test_sharedctypes(lock=True)
 
+    @unittest.skipUnless(test_support.check_impl_detail(pypy=False), "pypy ctypes differences")
     def test_copy(self):
         foo = _Foo(2, 5.0)
         bar = copy(foo)

File lib-python/2.7/test/test_support.py

     else:
         runner = BasicTestRunner()
 
-
     result = runner.run(suite)
     if not result.wasSuccessful():
         if len(result.errors) == 1 and not result.failures:

File lib-python/2.7/test/test_zipfile.py

             self.assertEqual(data1, '1'*FIXEDTEST_SIZE)
             self.assertEqual(data2, '2'*FIXEDTEST_SIZE)
 
+    def test_many_opens(self):
+        # Verify that read() and open() promptly close the file descriptor,
+        # and don't rely on the garbage collector to free resources.
+        with zipfile.ZipFile(TESTFN2, mode="r") as zipf:
+            for x in range(100):
+                zipf.read('ones')
+                with zipf.open('ones') as zopen1:
+                    pass
+        for x in range(10):
+            self.assertLess(open('/dev/null').fileno(), 100)
+
     def tearDown(self):
         unlink(TESTFN2)
 

File lib-python/2.7/zipfile.py

     # Search for universal newlines or line chunks.
     PATTERN = re.compile(r'^(?P<chunk>[^\r\n]+)|(?P<newline>\n|\r\n?)')
 
-    def __init__(self, fileobj, mode, zipinfo, decrypter=None):
+    def __init__(self, fileobj, mode, zipinfo, decrypter=None,
+                 close_fileobj=False):
         self._fileobj = fileobj
         self._decrypter = decrypter
+        self._close_fileobj = close_fileobj
 
         self._compress_type = zipinfo.compress_type
         self._compress_size = zipinfo.compress_size
         self._offset += len(data)
         return data
 
+    def close(self):
+        try:
+            if self._close_fileobj:
+                self._fileobj.close()
+        finally:
+            super(ZipExtFile, self).close()
 
 
 class ZipFile:
 
     def read(self, name, pwd=None):
         """Return file bytes (as a string) for name."""
-        return self.open(name, "r", pwd).read()
+        with self.open(name, "r", pwd) as fp:
+            return fp.read()
 
     def open(self, name, mode="r", pwd=None):
         """Return file-like object for 'name'."""
             zinfo = name
         else:
             # Get info object for name
-            zinfo = self.getinfo(name)
-
+            try:
+                zinfo = self.getinfo(name)
+            except KeyError:
+                if not self._filePassed:
+                    zef_file.close()
+                raise
         zef_file.seek(zinfo.header_offset, 0)
 
         # Skip the file header:
             zef_file.read(fheader[_FH_EXTRA_FIELD_LENGTH])
 
         if fname != zinfo.orig_filename:
+            if not self._filePassed:
+                zef_file.close()
             raise BadZipfile, \
                       'File name in directory "%s" and header "%s" differ.' % (
                           zinfo.orig_filename, fname)
             if not pwd:
                 pwd = self.pwd
             if not pwd:
+                if not self._filePassed:
+                    zef_file.close()
                 raise RuntimeError, "File %s is encrypted, " \
                       "password required for extraction" % name
 
                 # compare against the CRC otherwise
                 check_byte = (zinfo.CRC >> 24) & 0xff
             if ord(h[11]) != check_byte:
+                if not self._filePassed:
+                    zef_file.close()
                 raise RuntimeError("Bad password for file", name)
 
-        return  ZipExtFile(zef_file, mode, zinfo, zd)
+        return ZipExtFile(zef_file, mode, zinfo, zd,
+                          close_fileobj=not self._filePassed)
 
     def extract(self, member, path=None, pwd=None):
         """Extract a member from the archive to the current working directory,
             return targetpath
 
         source = self.open(member, pwd=pwd)
-        target = file(targetpath, "wb")
+        target = open(targetpath, "wb")
         shutil.copyfileobj(source, target)
         source.close()
         target.close()

File lib-python/conftest.py

                                  usemodules = '',
                                  skip=None): 
         self.basename = basename 
-        self._usemodules = usemodules.split() + ['signal']
+        self._usemodules = usemodules.split() + ['signal', 'rctime', 'itertools', '_socket']
         self._compiler = compiler 
         self.core = core
         self.skip = skip
                 m.test_main()
         ''' % locals())
 
-if sys.platform == 'win32':
-    skip_win32 = "Not supported on Windows"
-    only_win32 = False
-else:
-    skip_win32 = False
-    only_win32 = "Only on Windows"
-
 testmap = [
     RegrTest('test___all__.py', core=True),
     RegrTest('test___future__.py', core=True),
-    RegrTest('test__locale.py', skip=skip_win32),
+    RegrTest('test__locale.py', usemodules='_locale'),
     RegrTest('test_abc.py'),
     RegrTest('test_abstract_numbers.py'),
-    RegrTest('test_aepack.py', skip=True),
+    RegrTest('test_aepack.py'),
     RegrTest('test_aifc.py'),
-    RegrTest('test_argparse.py'),
-    RegrTest('test_al.py', skip=True),
-    RegrTest('test_ast.py', core=True),
-    RegrTest('test_anydbm.py'),
-    RegrTest('test_applesingle.py', skip=True),
-    RegrTest('test_array.py', core=True, usemodules='struct array'),
+    RegrTest('test_al.py'),
+    RegrTest('test_anydbm.py', usemodules='struct'),
+    RegrTest('test_applesingle.py'),
+    RegrTest('test_argparse.py', usemodules='binascii'),
+    RegrTest('test_array.py', core=True, usemodules='struct array binascii'),
     RegrTest('test_ascii_formatd.py'),
-    RegrTest('test_asynchat.py', usemodules='thread'),
-    RegrTest('test_asyncore.py'),
+    RegrTest('test_ast.py', core=True, usemodules='struct'),
+    RegrTest('test_asynchat.py', usemodules='select fcntl'),
+    RegrTest('test_asyncore.py', usemodules='select fcntl'),
     RegrTest('test_atexit.py', core=True),
-    RegrTest('test_audioop.py', skip=True),
+    RegrTest('test_audioop.py', skip="unsupported extension module"),
     RegrTest('test_augassign.py', core=True),
-    RegrTest('test_base64.py'),
+    RegrTest('test_base64.py', usemodules='struct'),
     RegrTest('test_bastion.py'),
+    RegrTest('test_bigaddrspace.py'),
+    RegrTest('test_bigmem.py'),
     RegrTest('test_binascii.py', usemodules='binascii'),
-
     RegrTest('test_binhex.py'),
-
     RegrTest('test_binop.py', core=True),
     RegrTest('test_bisect.py', core=True, usemodules='_bisect'),
     RegrTest('test_bool.py', core=True),
-    RegrTest('test_bsddb.py', skip="unsupported extension module"),
-    RegrTest('test_bsddb185.py', skip="unsupported extension module"),
-    RegrTest('test_bsddb3.py', skip="unsupported extension module"),
+    RegrTest('test_bsddb.py'),
+    RegrTest('test_bsddb185.py'),
+    RegrTest('test_bsddb3.py'),
     RegrTest('test_buffer.py'),
     RegrTest('test_bufio.py', core=True),
-    RegrTest('test_builtin.py', core=True),
-    RegrTest('test_bytes.py'),
+    RegrTest('test_builtin.py', core=True, usemodules='binascii'),
+    RegrTest('test_bytes.py', usemodules='struct binascii'),
     RegrTest('test_bz2.py', usemodules='bz2'),
     RegrTest('test_calendar.py'),
     RegrTest('test_call.py', core=True),
-    RegrTest('test_capi.py', skip="not applicable"),
-    RegrTest('test_cd.py', skip=True),
+    RegrTest('test_capi.py'),
+    RegrTest('test_cd.py'),
     RegrTest('test_cfgparser.py'),
-
     RegrTest('test_cgi.py'),
     RegrTest('test_charmapcodec.py', core=True),
-    RegrTest('test_cl.py', skip=True),
+    RegrTest('test_cl.py'),
     RegrTest('test_class.py', core=True),
     RegrTest('test_cmath.py', core=True),
     RegrTest('test_cmd.py'),
+    RegrTest('test_cmd_line.py'),
     RegrTest('test_cmd_line_script.py'),
+    RegrTest('test_code.py', core=True),
     RegrTest('test_codeccallbacks.py', core=True),
     RegrTest('test_codecencodings_cn.py', usemodules='_multibytecodec'),
     RegrTest('test_codecencodings_hk.py', usemodules='_multibytecodec'),
     RegrTest('test_codecencodings_jp.py', usemodules='_multibytecodec'),
     RegrTest('test_codecencodings_kr.py', usemodules='_multibytecodec'),
     RegrTest('test_codecencodings_tw.py', usemodules='_multibytecodec'),
-
     RegrTest('test_codecmaps_cn.py', usemodules='_multibytecodec'),
     RegrTest('test_codecmaps_hk.py', usemodules='_multibytecodec'),
     RegrTest('test_codecmaps_jp.py', usemodules='_multibytecodec'),
     RegrTest('test_codecmaps_tw.py', usemodules='_multibytecodec'),
     RegrTest('test_codecs.py', core=True, usemodules='_multibytecodec'),
     RegrTest('test_codeop.py', core=True),
+    RegrTest('test_coding.py', core=True),
     RegrTest('test_coercion.py', core=True),
     RegrTest('test_collections.py'),
     RegrTest('test_colorsys.py'),
     RegrTest('test_compileall.py'),
     RegrTest('test_compiler.py', core=False, skip="slowly deprecating compiler"),
     RegrTest('test_complex.py', core=True),
-
+    RegrTest('test_complex_args.py'),
     RegrTest('test_contains.py', core=True),
+    RegrTest('test_contextlib.py', usemodules="thread"),
     RegrTest('test_cookie.py'),
     RegrTest('test_cookielib.py'),
     RegrTest('test_copy.py', core=True),
     RegrTest('test_copy_reg.py', core=True),
     RegrTest('test_cpickle.py', core=True),
-    RegrTest('test_cprofile.py'), 
-    RegrTest('test_crypt.py', usemodules='crypt', skip=skip_win32),
+    RegrTest('test_cprofile.py'),
+    RegrTest('test_crypt.py', usemodules='crypt'),
     RegrTest('test_csv.py', usemodules='_csv'),
-
-    RegrTest('test_curses.py', skip="unsupported extension module"),
+    RegrTest('test_ctypes.py', usemodules="_rawffi thread"),
+    RegrTest('test_curses.py'),
     RegrTest('test_datetime.py'),
     RegrTest('test_dbm.py'),
     RegrTest('test_decimal.py'),
     RegrTest('test_decorators.py', core=True),
+    RegrTest('test_defaultdict.py', usemodules='_collections'),
     RegrTest('test_deque.py', core=True, usemodules='_collections'),
     RegrTest('test_descr.py', core=True, usemodules='_weakref'),
     RegrTest('test_descrtut.py', core=True),
     RegrTest('test_dircache.py', core=True),
     RegrTest('test_dis.py'),
     RegrTest('test_distutils.py', skip=True),
-    RegrTest('test_dl.py', skip=True),
+    RegrTest('test_dl.py'),
     RegrTest('test_doctest.py', usemodules="thread"),
     RegrTest('test_doctest2.py'),
     RegrTest('test_docxmlrpc.py'),
     RegrTest('test_dummy_thread.py', core=True),
     RegrTest('test_dummy_threading.py', core=True),
     RegrTest('test_email.py'),
-
     RegrTest('test_email_codecs.py'),
+    RegrTest('test_email_renamed.py'),
     RegrTest('test_enumerate.py', core=True),
     RegrTest('test_eof.py', core=True),
     RegrTest('test_epoll.py'),
     RegrTest('test_errno.py', usemodules="errno"),
+    RegrTest('test_exception_variations.py'),
     RegrTest('test_exceptions.py', core=True),
     RegrTest('test_extcall.py', core=True),
-    RegrTest('test_fcntl.py', usemodules='fcntl', skip=skip_win32),
+    RegrTest('test_fcntl.py', usemodules='fcntl'),
     RegrTest('test_file.py', usemodules="posix", core=True),
     RegrTest('test_file2k.py', usemodules="posix", core=True),
     RegrTest('test_filecmp.py', core=True),
     RegrTest('test_fileinput.py', core=True),
     RegrTest('test_fileio.py'),
+    RegrTest('test_float.py', core=True),
     RegrTest('test_fnmatch.py', core=True),
     RegrTest('test_fork1.py', usemodules="thread"),
     RegrTest('test_format.py', core=True),
     RegrTest('test_frozen.py', skip="unsupported extension module"),
     RegrTest('test_ftplib.py'),
     RegrTest('test_funcattrs.py', core=True),
+    RegrTest('test_functools.py'),
     RegrTest('test_future.py', core=True),
     RegrTest('test_future1.py', core=True),
     RegrTest('test_future2.py', core=True),
     RegrTest('test_future_builtins.py'),
     RegrTest('test_gc.py', usemodules='_weakref', skip="implementation detail"),
     RegrTest('test_gdb.py', skip="not applicable"),
-    RegrTest('test_gdbm.py', skip="unsupported extension module"),
+    RegrTest('test_gdbm.py'),
     RegrTest('test_generators.py', core=True, usemodules='thread _weakref'),
     RegrTest('test_genericpath.py'),
     RegrTest('test_genexps.py', core=True, usemodules='_weakref'),
-    RegrTest('test_getargs.py', skip="unsupported extension module"),
-    RegrTest('test_getargs2.py', skip="unsupported extension module"),
-
+    RegrTest('test_getargs.py'),
+    RegrTest('test_getargs2.py', usemodules='binascii', skip=True),
     RegrTest('test_getopt.py', core=True),
     RegrTest('test_gettext.py'),
-
-    RegrTest('test_gl.py', skip=True),
+    RegrTest('test_gl.py'),
     RegrTest('test_glob.py', core=True),
     RegrTest('test_global.py', core=True),
     RegrTest('test_grammar.py', core=True),
-    RegrTest('test_grp.py', skip=skip_win32),
-
-    RegrTest('test_gzip.py'),
+    RegrTest('test_grp.py'),
+    RegrTest('test_gzip.py', usemodules='zlib'),
     RegrTest('test_hash.py', core=True),
     RegrTest('test_hashlib.py', core=True),
-    
     RegrTest('test_heapq.py', core=True),
     RegrTest('test_hmac.py'),
     RegrTest('test_hotshot.py', skip="unsupported extension module"),
-
     RegrTest('test_htmllib.py'),
     RegrTest('test_htmlparser.py'),
     RegrTest('test_httplib.py'),
     RegrTest('test_httpservers.py'),
-    RegrTest('test_imageop.py', skip="unsupported extension module"),
+    RegrTest('test_imageop.py'),
     RegrTest('test_imaplib.py'),
-    RegrTest('test_imgfile.py', skip="unsupported extension module"),
+    RegrTest('test_imgfile.py'),
     RegrTest('test_imp.py', core=True, usemodules='thread'),
     RegrTest('test_import.py', core=True),
     RegrTest('test_importhooks.py', core=True),
     RegrTest('test_importlib.py'),
+    RegrTest('test_index.py'),
     RegrTest('test_inspect.py'),
     RegrTest('test_int.py', core=True),
     RegrTest('test_int_literal.py', core=True),
     RegrTest('test_long_future.py', core=True),
     RegrTest('test_longexp.py', core=True),
     RegrTest('test_macos.py'),
-    RegrTest('test_macostools.py', skip=True),
+    RegrTest('test_macostools.py'),
     RegrTest('test_macpath.py'),
     RegrTest('test_mailbox.py'),
     RegrTest('test_marshal.py', core=True),
     RegrTest('test_mhlib.py'),
     RegrTest('test_mimetools.py'),
     RegrTest('test_mimetypes.py'),
-    RegrTest('test_MimeWriter.py', core=False),
+    RegrTest('test_MimeWriter.py', core=False, usemodules='binascii'),
     RegrTest('test_minidom.py'),
     RegrTest('test_mmap.py', usemodules="mmap"),
     RegrTest('test_module.py', core=True),
     RegrTest('test_modulefinder.py'),
-    RegrTest('test_msilib.py', skip=only_win32),
+    RegrTest('test_msilib.py'),
     RegrTest('test_multibytecodec.py', usemodules='_multibytecodec'),
-    RegrTest('test_multibytecodec_support.py', skip="not a test"),
     RegrTest('test_multifile.py'),
-    RegrTest('test_multiprocessing.py', skip="FIXME leaves subprocesses"),
+    RegrTest('test_multiprocessing.py'),
     RegrTest('test_mutants.py', core="possibly"),
     RegrTest('test_mutex.py'),
     RegrTest('test_netrc.py'),
     RegrTest('test_new.py', core=True),
-    RegrTest('test_nis.py', skip="unsupported extension module"),
+    RegrTest('test_nis.py'),
     RegrTest('test_normalization.py'),
     RegrTest('test_ntpath.py'),
+    RegrTest('test_old_mailbox.py'),
     RegrTest('test_opcodes.py', core=True),
     RegrTest('test_openpty.py'),
     RegrTest('test_operator.py', core=True),
     RegrTest('test_optparse.py'),
-
     RegrTest('test_os.py', core=True),
-    RegrTest('test_ossaudiodev.py', skip="unsupported extension module"),
+    RegrTest('test_ossaudiodev.py'),
     RegrTest('test_parser.py', skip="slowly deprecating compiler"),
     RegrTest('test_pdb.py'),
     RegrTest('test_peepholer.py'),
     RegrTest('test_pep263.py'),
     RegrTest('test_pep277.py'),
     RegrTest('test_pep292.py'),
+    RegrTest('test_pep352.py'),
     RegrTest('test_pickle.py', core=True),
     RegrTest('test_pickletools.py', core=False),
     RegrTest('test_pipes.py'),
     RegrTest('test_pkg.py', core=True),
     RegrTest('test_pkgimport.py', core=True),
     RegrTest('test_pkgutil.py'),
-    RegrTest('test_plistlib.py', skip="unsupported module"),
-    RegrTest('test_poll.py', skip=skip_win32),
+    RegrTest('test_platform.py'),
+    RegrTest('test_plistlib.py'),
+    RegrTest('test_poll.py'),
     RegrTest('test_popen.py'),
     RegrTest('test_popen2.py'),
     RegrTest('test_poplib.py'),
     RegrTest('test_profile.py'),
     RegrTest('test_property.py', core=True),
     RegrTest('test_pstats.py'),
-    RegrTest('test_pty.py', skip="unsupported extension module"),
-    RegrTest('test_pwd.py', usemodules="pwd", skip=skip_win32),
+    RegrTest('test_pty.py', usemodules='fcntl termios select'),
+    RegrTest('test_pwd.py', usemodules="pwd"),
     RegrTest('test_py3kwarn.py'),
     RegrTest('test_py_compile.py'),
     RegrTest('test_pyclbr.py'),
     RegrTest('test_re.py', core=True),
     RegrTest('test_readline.py'),
     RegrTest('test_repr.py', core=True),
-    RegrTest('test_resource.py', skip=skip_win32),
+    RegrTest('test_resource.py'),
     RegrTest('test_rfc822.py'),
     RegrTest('test_richcmp.py', core=True),
     RegrTest('test_rlcompleter.py'),
-
     RegrTest('test_robotparser.py'),
+    RegrTest('test_runpy.py'),
     RegrTest('test_sax.py'),
     RegrTest('test_scope.py', core=True),
-    RegrTest('test_scriptpackages.py', skip="unsupported extension module"),
+    RegrTest('test_scriptpackages.py'),
     RegrTest('test_select.py'),
     RegrTest('test_set.py', core=True),
     RegrTest('test_sets.py'),
     RegrTest('test_shlex.py'),
     RegrTest('test_shutil.py'),
     RegrTest('test_signal.py'),
-    RegrTest('test_SimpleHTTPServer.py'),
+    RegrTest('test_SimpleHTTPServer.py', usemodules='binascii'),
     RegrTest('test_site.py', core=False),
     RegrTest('test_slice.py', core=True),
     RegrTest('test_smtplib.py'),
     RegrTest('test_smtpnet.py'),
     RegrTest('test_socket.py', usemodules='thread _weakref'),
-
     RegrTest('test_socketserver.py', usemodules='thread'),
-
     RegrTest('test_softspace.py', core=True),
     RegrTest('test_sort.py', core=True),
+    RegrTest('test_sqlite.py', usemodules="thread _rawffi zlib"),
     RegrTest('test_ssl.py', usemodules='_ssl _socket select'),
+    RegrTest('test_startfile.py'),
     RegrTest('test_str.py', core=True),
-
     RegrTest('test_strftime.py'),
     RegrTest('test_string.py', core=True),
-    RegrTest('test_StringIO.py', core=True, usemodules='cStringIO'),
+    RegrTest('test_StringIO.py', core=True, usemodules='cStringIO array'),
     RegrTest('test_stringprep.py'),
     RegrTest('test_strop.py', skip="deprecated"),
-
     RegrTest('test_strptime.py'),
     RegrTest('test_strtod.py'),
     RegrTest('test_struct.py', usemodules='struct'),
     RegrTest('test_structmembers.py', skip="CPython specific"),
     RegrTest('test_structseq.py'),
     RegrTest('test_subprocess.py', usemodules='signal'),
-    RegrTest('test_sunaudiodev.py', skip=True),
+    RegrTest('test_sunaudiodev.py'),
     RegrTest('test_sundry.py'),
     RegrTest('test_symtable.py', skip="implementation detail"),
     RegrTest('test_syntax.py', core=True),
     RegrTest('test_sys.py', core=True, usemodules='struct'),
+    RegrTest('test_sys_setprofile.py', core=True),
     RegrTest('test_sys_settrace.py', core=True),
-    RegrTest('test_sys_setprofile.py', core=True),
     RegrTest('test_sysconfig.py'),
-    RegrTest('test_tcl.py', skip="unsupported extension module"),
     RegrTest('test_tarfile.py'),
+    RegrTest('test_tcl.py'),
     RegrTest('test_telnetlib.py'),
     RegrTest('test_tempfile.py'),
-
     RegrTest('test_textwrap.py'),
     RegrTest('test_thread.py', usemodules="thread", core=True),
     RegrTest('test_threaded_import.py', usemodules="thread", core=True),
     RegrTest('test_threadedtempfile.py', 
              usemodules="thread", core=False),
-
     RegrTest('test_threading.py', usemodules="thread", core=True),
     RegrTest('test_threading_local.py', usemodules="thread", core=True),
     RegrTest('test_threadsignals.py', usemodules="thread"),
-
     RegrTest('test_time.py', core=True),
     RegrTest('test_timeout.py'),
     RegrTest('test_tk.py'),
-    RegrTest('test_ttk_guionly.py'),
-    RegrTest('test_ttk_textonly.py'),
     RegrTest('test_tokenize.py'),
     RegrTest('test_trace.py'),
     RegrTest('test_traceback.py', core=True),
     RegrTest('test_transformer.py', core=True),
+    RegrTest('test_ttk_guionly.py'),
+    RegrTest('test_ttk_textonly.py'),
     RegrTest('test_tuple.py', core=True),
     RegrTest('test_typechecks.py'),
     RegrTest('test_types.py', core=True),
     RegrTest('test_unpack.py', core=True),
     RegrTest('test_urllib.py'),
     RegrTest('test_urllib2.py'),
+    RegrTest('test_urllib2_localnet.py', usemodules="thread"),
     RegrTest('test_urllib2net.py'),
     RegrTest('test_urllibnet.py'),
     RegrTest('test_urlparse.py'),
     RegrTest('test_userlist.py', core=True),
     RegrTest('test_userstring.py', core=True),
     RegrTest('test_uu.py'),
-
-    RegrTest('test_warnings.py', core=True),
-    RegrTest('test_wave.py', skip="unsupported extension module"),
-    RegrTest('test_weakref.py', core=True, usemodules='_weakref'),
-    RegrTest('test_weakset.py'),
-
-    RegrTest('test_whichdb.py'),
-    RegrTest('test_winreg.py', skip=only_win32),
-    RegrTest('test_winsound.py', skip="unsupported extension module"),
-    RegrTest('test_xmllib.py'),
-    RegrTest('test_xmlrpc.py'),
-
-    RegrTest('test_xpickle.py'),
-    RegrTest('test_xrange.py', core=True),
-    RegrTest('test_zipfile.py'),
-    RegrTest('test_zipimport.py', usemodules='zlib zipimport'),
-    RegrTest('test_zipimport_support.py', usemodules='zlib zipimport'),
-    RegrTest('test_zlib.py', usemodules='zlib'),
-
-    RegrTest('test_bigaddrspace.py'),
-    RegrTest('test_bigmem.py'),
-    RegrTest('test_cmd_line.py'),
-    RegrTest('test_code.py'),
-    RegrTest('test_coding.py'),
-    RegrTest('test_complex_args.py'),
-    RegrTest('test_contextlib.py', usemodules="thread"),
-    RegrTest('test_ctypes.py', usemodules="_rawffi thread"),
-    RegrTest('test_defaultdict.py', usemodules='_collections'),
-    RegrTest('test_email_renamed.py'),
-    RegrTest('test_exception_variations.py'),
-    RegrTest('test_float.py'),
-    RegrTest('test_functools.py'),
-    RegrTest('test_index.py'),
-    RegrTest('test_old_mailbox.py'),
-    RegrTest('test_pep352.py'),
-    RegrTest('test_platform.py'),
-    RegrTest('test_runpy.py'),
-    RegrTest('test_sqlite.py', usemodules="thread _rawffi zlib"),
-    RegrTest('test_startfile.py', skip="bogus test"),
-    RegrTest('test_structmembers.py', skip="depends on _testcapi"),
-    RegrTest('test_urllib2_localnet.py', usemodules="thread"),
     RegrTest('test_uuid.py'),
     RegrTest('test_wait3.py', usemodules="thread"),
     RegrTest('test_wait4.py', usemodules="thread"),
+    RegrTest('test_warnings.py', core=True),
+    RegrTest('test_wave.py'),
+    RegrTest('test_weakref.py', core=True, usemodules='_weakref'),
+    RegrTest('test_weakset.py'),
+    RegrTest('test_whichdb.py'),
+    RegrTest('test_winreg.py'),
+    RegrTest('test_winsound.py'),
     RegrTest('test_with.py'),
     RegrTest('test_wsgiref.py'),
     RegrTest('test_xdrlib.py'),
     RegrTest('test_xml_etree.py'),
     RegrTest('test_xml_etree_c.py'),
+    RegrTest('test_xmllib.py'),
+    RegrTest('test_xmlrpc.py'),
+    RegrTest('test_xpickle.py'),
+    RegrTest('test_xrange.py', core=True),
+    RegrTest('test_zipfile.py'),
     RegrTest('test_zipfile64.py'),
+    RegrTest('test_zipimport.py', usemodules='zlib zipimport'),
+    RegrTest('test_zipimport_support.py', usemodules='zlib zipimport'),
+    RegrTest('test_zlib.py', usemodules='zlib'),
 ]
 
 def check_testmap_complete():
     listed_names = dict.fromkeys([regrtest.basename for regrtest in testmap])
-    listed_names['test_support.py'] = True     # ignore this
+    assert len(listed_names) == len(testmap)
+    # names to ignore
+    listed_names['test_support.py'] = True
+    listed_names['test_multibytecodec_support.py'] = True
     missing = []
     for path in testdir.listdir(fil='test_*.py'):
         name = path.basename
     def getinvocation(self, regrtest): 
         fspath = regrtest.getfspath() 
         python = sys.executable 
-        pypy_script = pypydir.join('bin', 'py.py')
+        pypy_script = pypydir.join('bin', 'pyinteractive.py')
         alarm_script = pypydir.join('tool', 'alarm.py')
         if sys.platform == 'win32':
             watchdog_name = 'watchdog_nt.py'

File lib_pypy/_ctypes_test.py

 import os, sys
 import tempfile
-import gc
 
 def compile_shared():
     """Compile '_ctypes_test.c' into an extension module, and import it
     if sys.platform == 'win32':
         ccflags = ['-D_CRT_SECURE_NO_WARNINGS']
     else:
-        ccflags = ['-fPIC']
+        ccflags = ['-fPIC', '-Wimplicit-function-declaration']
     res = compiler.compile([os.path.join(thisdir, '_ctypes_test.c')],
                            include_dirs=[include_dir],
                            extra_preargs=ccflags)
             library = os.path.join(thisdir, '..', 'include', 'python27')
         if not os.path.exists(library + '.lib'):
             # For a local translation
-            library = os.path.join(thisdir, '..', 'pypy', 'translator',
-                    'goal', 'libpypy-c')
+            library = os.path.join(thisdir, '..', 'pypy', 'goal', 'libpypy-c')
         libraries = [library, 'oleaut32']
-        extra_ldargs = ['/MANIFEST'] # needed for VC10
+        extra_ldargs = ['/MANIFEST',  # needed for VC10
+                        '/EXPORT:init_ctypes_test']
     else:
         libraries = []
         extra_ldargs = []

File lib_pypy/_testcapi.py

             library = os.path.join(thisdir, '..', 'include', 'python27')
         if not os.path.exists(library + '.lib'):
             # For a local translation
-            library = os.path.join(thisdir, '..', 'pypy', 'translator',
-                    'goal', 'libpypy-c')
+            library = os.path.join(thisdir, '..', 'pypy', 'goal', 'libpypy-c')
         libraries = [library, 'oleaut32']
         extra_ldargs = ['/MANIFEST',  # needed for VC10
                         '/EXPORT:init_testcapi']

File pypy/bin/checkmodule.py

 """
 import sys, os
 
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
+
 from pypy.objspace.fake.checkmodule import checkmodule
 
 def main(argv):

File pypy/doc/cpython_differences.rst

   type and vice versa. For builtin types, a dictionary will be returned that
   cannot be changed (but still looks and behaves like a normal dictionary).
 
-* the ``__len__`` or ``__length_hint__`` special methods are sometimes
-  called by CPython to get a length estimate to preallocate internal arrays.
-  So far, PyPy never calls ``__len__`` for this purpose, and never calls
-  ``__length_hint__`` at all.
-
 
 .. include:: _ref.txt

File pypy/doc/discussion/improve-rpython.rst

     from pypy.interpreter.typedef import interp_attrproperty, interp_attrproperty_w
     from pypy.interpreter.gateway import interp2app
     from pypy.interpreter.error import OperationError
-    from pypy.rpython.lltypesystem import rffi, lltype
+    from rpython.rtyper.lltypesystem import rffi, lltype
 
 - A more direct declarative way to write Typedef::
 

File pypy/doc/faq.rst

 Do I have to rewrite my programs in RPython?
 --------------------------------------------
 
-No.  And you shouldn't try.  PyPy always runs your code in its own interpreter, which is a
-full and compliant Python 2.7 interpreter.  RPython is only the
-language in which parts of PyPy itself are written and extension
-modules for it.  Not only is it not necessary for you to rewrite your
-code in RPython, it probably won't give you any speed improvements if you 
-try.
+No.  And you shouldn't try.  First and foremost, RPython is a language
+that is designed to write interpreters in.  It is a restricted subset of
+Python.  If you program is not an interpreter but tries to do "real
+things", like use *any* part of the standard Python library or *any*
+3rd-party library, then it is not RPython to start with.  You should
+only look at RPython if you try to `write your own interpreter`__.
+
+.. __: `how do I compile my own interpreters`_
+
+If your goal is to speed up Python code, then look at the regular PyPy,
+which is a full and compliant Python 2.7 interpreter (which happens to
+be written in RPython).  Not only is it not necessary for you to rewrite
+your code in RPython, it might not give you any speed improvements even
+if you manage to.
+
+Yes, it is possible with enough effort to compile small self-contained
+pieces of RPython code doing a few performance-sensitive things.  But
+this case is not interesting for us.  If you needed to rewrite the code
+in RPython, you could as well have rewritten it in C for example.  The
+latter is a much more supported, much more documented language `:-)`
 
 ---------------------------------------------------
 Which backends are there for the RPython toolchain?

File pypy/doc/rffi.rst

 lltype.Signed or lltype.Array) and memory management must be done
 by hand. To declare a function, we write::
 
-  from pypy.rpython.lltypesystem import rffi
+  from rpython.rtyper.lltypesystem import rffi
 
   external_function = rffi.llexternal(name, args, result)
 
 libraries and sources by passing in the optional ``compilation_info``
 parameter::
 
-  from pypy.rpython.lltypesystem import rffi
+  from rpython.rtyper.lltypesystem import rffi
   from rpython.translator.tool.cbuild import ExternalCompilationInfo
 
   info = ExternalCompilationInfo(includes=[], libraries=[])

File pypy/doc/test/test_whatsnew.py

File contents unchanged.

File pypy/interpreter/baseobjspace.py

                     )
                 raise
             w_fd = self.call_function(w_fileno)
-            if not self.isinstance_w(w_fd, self.w_int):
+            if (not self.isinstance_w(w_fd, self.w_int) and
+                not self.isinstance_w(w_fd, self.w_long)):
                 raise OperationError(self.w_TypeError,
-                    self.wrap("fileno() must return an integer")
+                    self.wrap("fileno() returned a non-integer")
                 )
         fd = self.int_w(w_fd)
         if fd < 0:

File pypy/interpreter/executioncontext.py

     def gettopframe(self):
         return self.topframeref()
 
+    @jit.unroll_safe
     def gettopframe_nohidden(self):
         frame = self.topframeref()
         while frame and frame.hide():

File pypy/interpreter/miscutils.py

     def setvalue(self, value):
         self._value = value
 
-    def getmainthreadvalue(self):
-        return self._value
+    def ismainthread(self):
+        return True
 
     def getallvalues(self):
         return {0: self._value}
-

File pypy/module/__pypy__/interp_identitydict.py

         except KeyError:
             raise OperationError(space.w_KeyError, w_key)
 
+    def descr_iter(self, space):
+        raise OperationError(space.w_TypeError,
+            space.wrap("'identity_dict' object does not support iteration; "
+                       "iterate over x.keys()"))
+
     def get(self, space, w_key, w_default=None):
         if w_default is None:
             w_default = space.w_None
 W_IdentityDict.typedef = TypeDef("identity_dict",
     __doc__="""\
 A dictionary that considers keys by object identity.
-Distinct objects that compare equal will have separate entries.
-All objects can be used as keys, even non-hashable ones.
+Distinct objects will have separate entries even if they
+compare equal.  All objects can be used as keys, even
+non-hashable ones --- but avoid using immutable objects
+like integers: two int objects 42 may or may not be
+internally the same object.
 """,
     __new__ = interp2app(W_IdentityDict.descr_new.im_func),
     __len__ = interp2app(W_IdentityDict.descr_len),
     __setitem__ = interp2app(W_IdentityDict.descr_setitem),
     __getitem__ = interp2app(W_IdentityDict.descr_getitem),
     __delitem__ = interp2app(W_IdentityDict.descr_delitem),
+    __iter__ = interp2app(W_IdentityDict.descr_iter),
     get = interp2app(W_IdentityDict.get),
     keys = interp2app(W_IdentityDict.keys),
     values = interp2app(W_IdentityDict.values),

File pypy/module/__pypy__/test/test_identitydict.py

 
         assert None in d
         assert [] not in d
+
+    def test_iterate(self):
+        from __pypy__ import identity_dict
+        d = identity_dict()
+        d[None] = 1
+        raises(TypeError, iter, d)
+        raises(TypeError, list, d)

File pypy/module/_bisect/interp_bisect.py

 from pypy.interpreter.error import OperationError
 from pypy.interpreter.gateway import unwrap_spec
+from rpython.rlib.rarithmetic import intmask, r_uint
 
 
 @unwrap_spec(lo=int, hi=int)
     if hi == -1:
         hi = space.len_w(w_a)
     while lo < hi:
-        mid = (lo + hi) >> 1
+        mid = intmask((r_uint(lo) + r_uint(hi)) >> 1)
         w_litem = space.getitem(w_a, space.wrap(mid))
         if space.is_true(space.lt(w_litem, w_x)):
             lo = mid + 1
     if hi == -1:
         hi = space.len_w(w_a)
     while lo < hi:
-        mid = (lo + hi) >> 1
+        mid = intmask((r_uint(lo) + r_uint(hi)) >> 1)
         w_litem = space.getitem(w_a, space.wrap(mid))
         if space.is_true(space.lt(w_x, w_litem)):
             hi = mid

File pypy/module/_bisect/test/test_bisect.py

         insort_right(a, 6.0)
         assert a == [0, 5, 6, 6, 6, 6.0, 7]
         assert map(type, a) == [int, int, int, int, int, float, int]
+
+    def test_bisect_overflow(self):
+        from _bisect import bisect_left, bisect_right
+        import sys
+
+        size = sys.maxsize
+        data = xrange(size - 1)
+        assert bisect_left(data, size - 3) == size - 3
+        assert bisect_right(data, size - 3) == size - 2

File pypy/module/_io/interp_fileio.py

 
         self.readable, self.writable, append, flags = decode_mode(space, mode)
 
-        if fd >= 0:
-            verify_fd(fd)
-            try:
-                os.fstat(fd)
-            except OSError, e:
-                if e.errno == errno.EBADF:
-                    raise wrap_oserror(space, e)
-                # else: pass
-            self.fd = fd
-            self.closefd = bool(closefd)
-        else:
-            if not closefd:
-                raise OperationError(space.w_ValueError, space.wrap(
-                    "Cannot use closefd=False with file name"))
-            self.closefd = True
+        fd_is_own = False
+        try:
+            if fd >= 0:
+                verify_fd(fd)
+                try:
+                    os.fstat(fd)
+                except OSError, e:
+                    if e.errno == errno.EBADF:
+                        raise wrap_oserror(space, e)
+                    # else: pass
+                self.fd = fd
+                self.closefd = bool(closefd)
+            else:
+                self.closefd = True
+                if not closefd:
+                    raise OperationError(space.w_ValueError, space.wrap(
+                        "Cannot use closefd=False with file name"))
 
-            from pypy.module.posix.interp_posix import (
-                dispatch_filename, rposix)
-            try:
-                self.fd = dispatch_filename(rposix.open)(
-                    space, w_name, flags, 0666)
-            except OSError, e:
-                raise wrap_oserror2(space, e, w_name,
-                                    exception_name='w_IOError')
+                from pypy.module.posix.interp_posix import (
+                    dispatch_filename, rposix)
+                try:
+                    self.fd = dispatch_filename(rposix.open)(
+                        space, w_name, flags, 0666)
+                except OSError, e:
+                    raise wrap_oserror2(space, e, w_name,
+                                        exception_name='w_IOError')
+                finally:
+                    fd_is_own = True
 
             self._dircheck(space, w_name)
-        self.w_name = w_name
+            self.w_name = w_name
 
-        if append:
-            # For consistent behaviour, we explicitly seek to the end of file
-            # (otherwise, it might be done only on the first write()).
-            try:
-                os.lseek(self.fd, 0, os.SEEK_END)
-            except OSError, e:
-                raise wrap_oserror(space, e, exception_name='w_IOError')
+            if append:
+                # For consistent behaviour, we explicitly seek to the end of file
+                # (otherwise, it might be done only on the first write()).
+                try:
+                    os.lseek(self.fd, 0, os.SEEK_END)
+                except OSError, e:
+                    raise wrap_oserror(space, e, exception_name='w_IOError')
+        except:
+            if not fd_is_own:
+                self.fd = -1
+            raise
 
     def _mode(self):
         if self.readable:
         except OSError:
             return
         if stat.S_ISDIR(st.st_mode):
-            self._close(space)
             raise wrap_oserror2(space, OSError(errno.EISDIR, "fstat"),
                                 w_filename, exception_name='w_IOError')
 

File pypy/module/_io/test/test_fileio.py

 
     def test_open_directory(self):
         import _io
+        import os
         raises(IOError, _io.FileIO, self.tmpdir, "rb")
+        if os.name != 'nt':
+            fd = os.open(self.tmpdir, os.O_RDONLY)
+            raises(IOError, _io.FileIO, fd, "rb")
+            os.close(fd)
 
     def test_readline(self):
         import _io

File pypy/module/_multiprocessing/test/test_connection.py

         assert rhandle.readable
 
 class AppTestWinpipeConnection(BaseConnectionTest):
-    spaceconfig = dict(usemodules=('_multiprocessing', 'thread'))
+    spaceconfig = dict(usemodules=('_multiprocessing', 'thread', 'signal'))
 
     def setup_class(cls):
         if sys.platform != "win32":

File pypy/module/_socket/interp_socket.py

         try:
             self.close()
         except SocketError, e:
-            raise converted_error(space, e)
+            # cpython doesn't return any errors on close
+            pass
 
     def connect_w(self, space, w_addr):
         """connect(address)
                 w_addr = space.w_None
             return space.newtuple([space.wrap(readlgt), w_addr])
         except SocketError, e:
-            raise converted_error(space, e)        
+            raise converted_error(space, e)
 
     @unwrap_spec(cmd=int)
     def ioctl_w(self, space, cmd, w_option):

File pypy/module/_socket/test/test_sock_app.py

         assert isinstance(s.fileno(), int)
 
     def test_socket_close(self):
-        import _socket
+        import _socket, os
         s = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM, 0)
         fileno = s.fileno()
         assert s.fileno() >= 0
         s.close()
         assert s.fileno() < 0
         s.close()
+        if os.name != 'nt':
+            raises(OSError, os.close, fileno)
 
     def test_socket_close_error(self):
         import _socket, os
             skip("Windows sockets are not files")
         s = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM, 0)
         os.close(s.fileno())
-        raises(_socket.error, s.close)
+        s.close()
 
     def test_socket_connect(self):
         import _socket, os

File pypy/module/cpyext/api.py

             kwds["link_extra"] = ["msvcrt.lib"]
         elif sys.platform.startswith('linux'):
             compile_extra.append("-Werror=implicit-function-declaration")
+            compile_extra.append('-g')
         export_symbols_eci.append('pypyAPI')
-        compile_extra.append('-g')
     else:
         kwds["includes"] = ['Python.h'] # this is our Python.h
 

File pypy/module/cpyext/longobject.py

     Return a C unsigned long representation of the contents of pylong.
     If pylong is greater than ULONG_MAX, an OverflowError is
     raised."""
-    return rffi.cast(rffi.ULONG, space.uint_w(w_long))
+    try:
+        return rffi.cast(rffi.ULONG, space.uint_w(w_long))
+    except OperationError, e:
+        if e.match(space, space.w_ValueError):
+            e.w_type = space.w_OverflowError
+        raise
 
 @cpython_api([PyObject], rffi.ULONG, error=-1)
 def PyLong_AsUnsignedLongMask(space, w_long):
     Return a C unsigned long representation of the contents of pylong.
     If pylong is greater than ULONG_MAX, an OverflowError is
     raised."""
-    return rffi.cast(rffi.ULONGLONG, space.r_ulonglong_w(w_long))
+    try:
+        return rffi.cast(rffi.ULONGLONG, space.r_ulonglong_w(w_long))
+    except OperationError, e:
+        if e.match(space, space.w_ValueError):
+            e.w_type = space.w_OverflowError
+        raise
 
 @cpython_api([PyObject], rffi.ULONGLONG, error=-1)
 def PyLong_AsUnsignedLongLongMask(space, w_long):

File pypy/module/cpyext/object.py

 
 @cpython_api([PyObject], PyObject)
 def PyObject_Str(space, w_obj):
+    if w_obj is None:
+        return space.wrap("<NULL>")
     return space.str(w_obj)
 
 @cpython_api([PyObject], PyObject)
     representation on success, NULL on failure.  This is the equivalent of the
     Python expression repr(o).  Called by the repr() built-in function and
     by reverse quotes."""
+    if w_obj is None:
+        return space.wrap("<NULL>")
     return space.repr(w_obj)
 
 @cpython_api([PyObject], PyObject)
     string representation on success, NULL on failure. This is the equivalent of
     the Python expression unicode(o).  Called by the unicode() built-in
     function."""
+    if w_obj is None:
+        return space.wrap(u"<NULL>")
     return space.call_function(space.w_unicode, w_obj)
 
 @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)

File pypy/module/cpyext/test/test_longobject.py

         value = api.PyLong_AsUnsignedLong(w_value)
         assert value == (sys.maxint - 1) * 2
 
+        self.raises(space, api, OverflowError, api.PyLong_AsUnsignedLong, space.wrap(-1))
+
     def test_as_ssize_t(self, space, api):
         w_value = space.newlong(2)
         value = api.PyLong_AsSsize_t(w_value)
         w_l = space.wrap(sys.maxint + 1)
         assert api.PyLong_Check(w_l)
         assert api.PyLong_CheckExact(w_l)
-        
+
         w_i = space.wrap(sys.maxint)
         assert not api.PyLong_Check(w_i)
         assert not api.PyLong_CheckExact(w_i)
-        
+
         L = space.appexec([], """():
             class L(long):
                 pass
         assert api.PyLong_AsUnsignedLongLongMask(
             space.wrap(1<<64)) == 0
 
+        self.raises(space, api, OverflowError, api.PyLong_AsUnsignedLongLong, space.wrap(-1))
+
     def test_as_long_and_overflow(self, space, api):
         overflow = lltype.malloc(rffi.CArrayPtr(rffi.INT_real).TO, 1, flavor='raw')
         assert api.PyLong_AsLongAndOverflow(

File pypy/module/cpyext/test/test_object.py

 
     def test_size(self, space, api):
         assert api.PyObject_Size(space.newlist([space.w_None])) == 1
-        
+
+    def test_str(self, space, api):
+        w_list = space.newlist([space.w_None, space.wrap(42)])
+        assert space.str_w(api.PyObject_Str(None)) == "<NULL>"
+        assert space.str_w(api.PyObject_Str(w_list)) == "[None, 42]"
+        assert space.str_w(api.PyObject_Str(space.wrap("a"))) == "a"
+
     def test_repr(self, space, api):
         w_list = space.newlist([space.w_None, space.wrap(42)])
+        assert space.str_w(api.PyObject_Repr(None)) == "<NULL>"
         assert space.str_w(api.PyObject_Repr(w_list)) == "[None, 42]"
         assert space.str_w(api.PyObject_Repr(space.wrap("a"))) == "'a'"
-        
-        w_list = space.newlist([space.w_None, space.wrap(42)])
-        assert space.str_w(api.PyObject_Str(w_list)) == "[None, 42]"
-        assert space.str_w(api.PyObject_Str(space.wrap("a"))) == "a"
-        
+
     def test_RichCompare(self, space, api):
         def compare(w_o1, w_o2, opid):
             res = api.PyObject_RichCompareBool(w_o1, w_o2, opid)
             w_res = api.PyObject_RichCompare(w_o1, w_o2, opid)
             assert space.is_true(w_res) == res
             return res
-        
+
         def test_compare(o1, o2):
             w_o1 = space.wrap(o1)
             w_o2 = space.wrap(o2)
-            
+
             for opid, expected in [
                     (Py_LT, o1 <  o2), (Py_LE, o1 <= o2),
                     (Py_NE, o1 != o2), (Py_EQ, o1 == o2),
             api.PyErr_Clear()
 
     def test_unicode(self, space, api):
+        assert space.unwrap(api.PyObject_Unicode(None)) == u"<NULL>"
         assert space.unwrap(api.PyObject_Unicode(space.wrap([]))) == u"[]"
         assert space.unwrap(api.PyObject_Unicode(space.wrap("e"))) == u"e"
         assert api.PyObject_Unicode(space.wrap("\xe9")) is None

File pypy/module/crypt/test/test_crypt.py

+import os
+import py
+
+if os.name != 'posix':
+    py.test.skip('crypt module only available on unix')
+
 class AppTestCrypt: 
     spaceconfig = dict(usemodules=['crypt'])
- 
+
     def test_crypt(self):
         import crypt 
         res = crypt.crypt("pass", "ab")

File pypy/module/fcntl/test/test_fcntl.py

 import os
+import py
 from rpython.tool.udir import udir
 
-if os.name == "nt":
-    from py.test import skip
-    skip("fcntl module is not available on Windows")
+if os.name != 'posix':
+    py.test.skip("fcntl module only available on unix")
 
 def teardown_module(mod):
     for i in "abcde":
         import sys
         import struct
 
+        class F:
+            def __init__(self, fn):
+                self.fn = fn
+            def fileno(self):
+                return self.fn
+
         f = open(self.tmp + "b", "w+")
 
         fcntl.fcntl(f, 1, 0)
         fcntl.fcntl(f, 1)
+        fcntl.fcntl(F(long(f.fileno())), 1)
         raises(TypeError, fcntl.fcntl, "foo")
         raises(TypeError, fcntl.fcntl, f, "foo")
-        raises((IOError, ValueError), fcntl.fcntl, -1, 1, 0)
+        raises(TypeError, fcntl.fcntl, F("foo"), 1)
+        raises(ValueError, fcntl.fcntl, -1, 1, 0)
+        raises(ValueError, fcntl.fcntl, F(-1), 1, 0)
+        raises(ValueError, fcntl.fcntl, F(long(-1)), 1, 0)
         assert fcntl.fcntl(f, 1, 0) == 0
         assert fcntl.fcntl(f, 2, "foo") == "foo"
         assert fcntl.fcntl(f, 2, buffer("foo")) == "foo"

File pypy/module/posix/test/test_posix2.py

 
     if hasattr(os, 'chmod'):
         def test_chmod(self):
+            import sys
             os = self.posix
             os.unlink(self.path)
             raises(OSError, os.chmod, self.path, 0600)
             f = open(self.path, "w")
             f.write("this is a test")
             f.close()
-            os.chmod(self.path, 0200)
-            assert (os.stat(self.path).st_mode & 0777) == 0200
+            if sys.platform == 'win32':
+                os.chmod(self.path, 0400)
+                assert (os.stat(self.path).st_mode & 0600) == 0400
+            else:
+                os.chmod(self.path, 0200)
+                assert (os.stat(self.path).st_mode & 0777) == 0200
 
     if hasattr(os, 'fchmod'):
         def test_fchmod(self):

File pypy/module/pwd/test/test_pwd.py

+import os
+import py
+
+if os.name != 'posix':
+    py.test.skip('pwd module only available on unix')
+
 class AppTestPwd:
     spaceconfig = dict(usemodules=['pwd'])
 

File pypy/module/signal/interp_signal.py

     def __init__(self, space):
         "NOT_RPYTHON"
         AsyncAction.__init__(self, space)
-        self.handlers_w = {}
         self.pending_signal = -1
         self.fire_in_main_thread = False
         if self.space.config.objspace.usemodules.thread:
                 # If we are in the main thread, report the signal now,
                 # and poll more
                 self.pending_signal = -1
-                self._report_signal(n)
+                report_signal(self.space, n)
                 n = self.pending_signal
                 if n < 0: n = pypysig_poll()
             else:
             pypysig_pushback(cpy_signal.SIGINT)
         self.fire_in_main_thread = True
 
-    def _report_signal(self, n):
-        try:
-            w_handler = self.handlers_w[n]
-        except KeyError:
-            return    # no handler, ignore signal
-        space = self.space
-        if not space.is_true(space.callable(w_handler)):
-            return    # w_handler is SIG_IGN or SIG_DFL?
-        # re-install signal handler, for OSes that clear it
-        pypysig_reinstall(n)
-        # invoke the app-level handler
-        ec = space.getexecutioncontext()
-        w_frame = space.wrap(ec.gettopframe_nohidden())
-        space.call_function(w_handler, space.wrap(n), w_frame)
+# ____________________________________________________________
+
+
+class Handlers:
+    def __init__(self, space):
+        self.handlers_w = {}
+
+def _get_handlers(space):
+    return space.fromcache(Handlers).handlers_w
+
+
+def report_signal(space, n):
+    handlers_w = _get_handlers(space)
+    try:
+        w_handler = handlers_w[n]
+    except KeyError:
+        return    # no handler, ignore signal
+    if not space.is_true(space.callable(w_handler)):
+        return    # w_handler is SIG_IGN or SIG_DFL?
+    # re-install signal handler, for OSes that clear it
+    pypysig_reinstall(n)
+    # invoke the app-level handler
+    ec = space.getexecutioncontext()
+    w_frame = space.wrap(ec.gettopframe_nohidden())
+    space.call_function(w_handler, space.wrap(n), w_frame)
 
 
 @unwrap_spec(signum=int)
         check_signum_exists(space, signum)
     else:
         check_signum_in_range(space, signum)
-    action = space.check_signal_action
-    if signum in action.handlers_w:
-        return action.handlers_w[signum]
+    handlers_w = _get_handlers(space)
+    if signum in handlers_w:
+        return handlers_w[signum]
     return space.wrap(SIG_DFL)
 
 
     A signal handler function is called with two arguments:
     the first is the signal number, the second is the interrupted stack frame.
     """
-    ec = space.getexecutioncontext()
-    main_ec = space.threadlocals.getmainthreadvalue()
-
-    old_handler = getsignal(space, signum)
-
-    if ec is not main_ec:
+    if not space.threadlocals.ismainthread():
         raise OperationError(space.w_ValueError,
                              space.wrap("signal() must be called from the "
                                         "main thread"))
-    action = space.check_signal_action
+    old_handler = getsignal(space, signum)
+
     if space.eq_w(w_handler, space.wrap(SIG_DFL)):
         pypysig_default(signum)
     elif space.eq_w(w_handler, space.wrap(SIG_IGN)):
                                  space.wrap("'handler' must be a callable "
                                             "or SIG_DFL or SIG_IGN"))
         pypysig_setflag(signum)
-    action.handlers_w[signum] = w_handler
+    handlers_w = _get_handlers(space)
+    handlers_w[signum] = w_handler
     return old_handler
 
 
 
     The fd must be non-blocking.
     """
-    if space.config.objspace.usemodules.thread:
-        main_ec = space.threadlocals.getmainthreadvalue()
-        ec = space.getexecutioncontext()
-        if ec is not main_ec:
-            raise OperationError(
-                space.w_ValueError,
-                space.wrap("set_wakeup_fd only works in main thread"))
+    if not space.threadlocals.ismainthread():
+        raise OperationError(
+            space.w_ValueError,
+            space.wrap("set_wakeup_fd only works in main thread"))
     old_fd = pypysig_set_wakeup_fd(fd)
     return space.wrap(intmask(old_fd))
 

File pypy/module/termios/test/test_termios.py

-
+import os
+import sys
 import py
-import sys
 from pypy.conftest import pypydir
 from rpython.tool.udir import udir
 
+if os.name != 'posix':
+    py.test.skip('termios module only available on unix')
+
 class TestTermios(object):
     def setup_class(cls):
         try:

File pypy/module/thread/os_lock.py

 
     @unwrap_spec(waitflag=int)
     def descr_lock_acquire(self, space, waitflag=1):
-        """Lock the lock.  Without argument, this blocks if the lock is already
-locked (even by the same thread), waiting for another thread to release
-the lock, and return None once the lock is acquired.
-With an argument, this will only block if the argument is true,
+        """Lock the lock.  With the default argument of True, this blocks
+if the lock is already locked (even by the same thread), waiting for
+another thread to release the lock, and returns True once the lock is
+acquired.  With an argument of False, this will always return immediately
 and the return value reflects whether the lock is acquired.
 The blocking operation is not interruptible."""
         mylock = self.lock
 def allocate_lock(space):
     """Create a new lock object.  (allocate() is an obsolete synonym.)
 See LockType.__doc__ for information about locks."""
-    return space.wrap(Lock(space))
+    return space.wrap(Lock(space))

File pypy/module/thread/test/support.py

 import time
 import thread
 import os
+import errno
 
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.module.thread import gil
     def kill():
         for x in range(delay * 10):
             time.sleep(0.1)
-            os.kill(pid, 0)
+            try:
+                os.kill(pid, 0)
+            except OSError, e:
+                if e.errno == errno.ESRCH: # no such process
+                    return
+                raise
         os.kill(pid, 9)
         print "process %s killed!" % (pid,)
     thread.start_new_thread(kill, ())

File pypy/module/thread/test/test_fork.py

 from pypy.module.thread.test.support import GenericTestThread
 
 class AppTestFork(GenericTestThread):
-    def test_fork(self):
+    def test_fork_with_thread(self):
         # XXX This test depends on a multicore machine, as busy_thread must
         # aquire the GIL the instant that the main thread releases it.
         # It will incorrectly pass if the GIL is not grabbed in time.
         if not hasattr(os, 'fork'):
             skip("No fork on this platform")
 
-        run = True
-        done = []
         def busy_thread():
             while run:
                 time.sleep(0)
             done.append(None)
 
-        try:
-            thread.start_new(busy_thread, ())
+        for i in range(1):
+            run = True
+            done = []
+            try:
+                thread.start_new(busy_thread, ())
+                print 'sleep'
 
-            pid = os.fork()
-
-            if pid == 0:
-                os._exit(0)
-
-            else:
-                time.sleep(1)
-                spid, status = os.waitpid(pid, os.WNOHANG)
-                assert spid == pid
-        finally:
-            run = False
-            self.waitfor(lambda: done)
+                pid = os.fork()
+                if pid == 0:
+                    os._exit(0)
+                else:
+                    self.timeout_killer(pid, 5)
+                    exitcode = os.waitpid(pid, 0)[1]
+                    assert exitcode == 0 # if 9, process was killed by timer!
+            finally:
+                run = False
+                self.waitfor(lambda: done)
+                assert done
 
     def test_forked_can_thread(self):
         "Checks that a forked interpreter can start a thread"
-        import os, thread, time
+        import thread
+        import os
 
         if not hasattr(os, 'fork'):
             skip("No fork on this platform")
 
-        # pre-allocate some locks
-        thread.start_new_thread(lambda: None, ())
+        for i in range(10):
+            # pre-allocate some locks
+            thread.start_new_thread(lambda: None, ())
+            print 'sleep'
 
-        pid = os.fork()
-        if pid == 0:
-            print 'in child'
-            thread.start_new_thread(lambda: None, ())
-            os._exit(0)
-        else:
-            self.timeout_killer(pid, 5)
-            exitcode = os.waitpid(pid, 0)[1]
-            assert exitcode == 0 # if 9, process was killed by timer!
+            pid = os.fork()
+            if pid == 0:
+                thread.start_new_thread(lambda: None, ())
+                os._exit(0)
+            else:
+                self.timeout_killer(pid, 5)
+                exitcode = os.waitpid(pid, 0)[1]
+                assert exitcode == 0 # if 9, process was killed by timer!

File pypy/module/thread/test/test_lock.py

         assert lock.locked() is False
         raises(thread.error, lock.release)
         assert lock.locked() is False
-        lock.acquire()
+        r = lock.acquire()
+        assert r is True
+        r = lock.acquire(False)
+        assert r is False
         assert lock.locked() is True
         lock.release()
         assert lock.locked() is False

File pypy/module/thread/threadlocals.py

         self._mostrecentkey = ident
         self._mostrecentvalue = value
 
-    def getmainthreadvalue(self):
-        ident = self._mainthreadident
-        return self._valuedict.get(ident, None)
-
     def ismainthread(self):
         return thread.get_ident() == self._mainthreadident
 

File pypy/objspace/std/tupleobject.py

     start, stop = normalize_simple_slice(space, length, w_start, w_stop)
     return space.newtuple(w_tuple.wrappeditems[start:stop])
 
+THRESHOLD = 7
+
+def unroll_tuple_contains(space, w_tuple, w_obj):
+    if (jit.isconstant(w_tuple) or jit.isvirtual(w_tuple) and
+        len(w_tuple.wrappeditems) < THRESHOLD):
+        return True
+    return False
+
+@jit.look_inside_iff(unroll_tuple_contains)
 def contains__Tuple_ANY(space, w_tuple, w_obj):
     for w_item in w_tuple.wrappeditems:
         if space.eq_w(w_item, w_obj):

File pypy/tool/clean_old_branches.py

File contents unchanged.

File rpython/annotator/annrpython.py

         if policy is None:
             from rpython.annotator.policy import AnnotatorPolicy
             policy = AnnotatorPolicy()
+            # XXX hack
+            annmodel.TLS.check_str_without_nul = (
+                self.translator.config.translation.check_str_without_nul)
         graph, inputcells = self.get_call_parameters(function, args_s, policy)
         self.build_graph_types(graph, inputcells, complete_now=False)
         self.complete_helpers(policy)

File rpython/annotator/binaryop.py

 class __extend__(pairtype(SomeChar, SomeChar)):