Commits

Antonio Cuni  committed b5db96b Merge

merge heads

  • Participants
  • Parent commits 7a5aa50, 63e875c

Comments (0)

Files changed (141)

 pypy/doc/*.html
 pypy/doc/config/*.html
 pypy/doc/discussion/*.html
+pypy/module/test_lib_pypy/ctypes_tests/*.o
 pypy/translator/c/src/dtoa.o
 pypy/translator/goal/pypy-c
 pypy/translator/goal/target*-c
 ^pypy/module/cpyext/test/.+\.o$
 ^pypy/module/cpyext/test/.+\.obj$
 ^pypy/module/cpyext/test/.+\.manifest$
+^pypy/module/test_lib_pypy/ctypes_tests/.+\.o$
 ^pypy/doc/.+\.html$
 ^pypy/doc/basicblock\.asc$
 ^pypy/doc/.+\.svninfo$

File _pytest/genscript.py

 """ generate a single-file self-contained version of py.test """
 import py
-import pickle
-import zlib
-import base64
 
 def find_toplevel(name):
     for syspath in py.std.sys.path:
     return name2src
 
 def compress_mapping(mapping):
-    data = pickle.dumps(mapping, 2)
-    data = zlib.compress(data, 9)
-    data = base64.encodestring(data)
+    data = py.std.pickle.dumps(mapping, 2)
+    data = py.std.zlib.compress(data, 9)
+    data = py.std.base64.encodestring(data)
     data = data.decode('ascii')
     return data
 
         mapping.update(pkg_to_mapping(name))
     return compress_mapping(mapping)
 
-
 def generate_script(entry, packages):
     data = compress_packages(packages)
     tmpl = py.path.local(__file__).dirpath().join('standalonetemplate.py')

File _pytest/runner.py

             longrepr = excinfo
         elif excinfo.errisinstance(py.test.skip.Exception):
             outcome = "skipped"
-            r = item._repr_failure_py(excinfo, "line").reprcrash
+            r = excinfo._getreprcrash()
             longrepr = (str(r.path), r.lineno, r.message)
         else:
             outcome = "failed"

File lib-python/conftest.py

 def pytest_addoption(parser):
     group = parser.getgroup("complicance testing options") 
     group.addoption('-T', '--timeout', action="store", type="string", 
-       default="100", dest="timeout", 
+       default="1000", dest="timeout", 
        help="fail a test module after the given timeout. "
             "specify in seconds or 'NUMmp' aka Mega-Pystones")
     group.addoption('--pypy', action="store", type="string",

File lib-python/modified-2.7.0/ctypes/__init__.py

             self._handle = handle
 
     def __repr__(self):
-        return "<%s '%s', handle %x at %x>" % \
+        return "<%s '%s', handle %r at %x>" % \
                (self.__class__.__name__, self._name,
-                (self._handle & (_sys.maxint*2 + 1)),
+                (self._handle),
                 id(self) & (_sys.maxint*2 + 1))
 
+
     def __getattr__(self, name):
         if name.startswith('__') and name.endswith('__'):
             raise AttributeError(name)

File lib-python/modified-2.7.0/ctypes/test/test_macholib.py

                                  '/usr/lib/libSystem.B.dylib')
 
             result = find_lib('z')
-            self.assertTrue(result.startswith('/usr/lib/libz.1'))
             self.assertTrue(result.endswith('.dylib'))
 
             self.assertEqual(find_lib('IOKit'),

File lib-python/modified-2.7.0/ctypes/test/test_objects.py

 
 >>> array[4] = 'foo bar'
 >>> array._objects
-{'4': 'foo bar'}
+{'4': <CArgObject 'foo bar'>}
 >>> array[4]
 'foo bar'
 >>>
 
 >>> x.array[0] = 'spam spam spam'
 >>> x._objects
-{'0:2': 'spam spam spam'}
+{'0:2': <CArgObject 'spam spam spam'>}
 >>> x.array._b_base_._objects
-{'0:2': 'spam spam spam'}
+{'0:2': <CArgObject 'spam spam spam'>}
 >>>
 
 '''

File lib-python/modified-2.7.0/ctypes/test/test_prototypes.py

         func.restype = c_long
         func.argtypes = None
 
-    @xfail
     def test_paramflags(self):
         # function returns c_void_p result,
         # and has a required parameter named 'input'

File lib-python/modified-2.7.0/test/test_cmd_line_script.py

+# Tests command line execution of scripts
+
+import unittest
+import os
+import os.path
+import test.test_support
+from test.script_helper import (run_python,
+                                temp_dir, make_script, compile_script,
+                                make_pkg, make_zip_script, make_zip_pkg)
+
+verbose = test.test_support.verbose
+
+
+test_source = """\
+# Script may be run with optimisation enabled, so don't rely on assert
+# statements being executed
+def assertEqual(lhs, rhs):
+    if lhs != rhs:
+        raise AssertionError('%r != %r' % (lhs, rhs))
+def assertIdentical(lhs, rhs):
+    if lhs is not rhs:
+        raise AssertionError('%r is not %r' % (lhs, rhs))
+# Check basic code execution
+result = ['Top level assignment']
+def f():
+    result.append('Lower level reference')
+f()
+assertEqual(result, ['Top level assignment', 'Lower level reference'])
+# Check population of magic variables
+assertEqual(__name__, '__main__')
+print '__file__==%r' % __file__
+print '__package__==%r' % __package__
+# Check the sys module
+import sys
+assertIdentical(globals(), sys.modules[__name__].__dict__)
+print 'sys.argv[0]==%r' % sys.argv[0]
+"""
+
+def _make_test_script(script_dir, script_basename, source=test_source):
+    return make_script(script_dir, script_basename, source)
+
+def _make_test_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename,
+                       source=test_source, depth=1):
+    return make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename,
+                        source, depth)
+
+# There's no easy way to pass the script directory in to get
+# -m to work (avoiding that is the whole point of making
+# directories and zipfiles executable!)
+# So we fake it for testing purposes with a custom launch script
+launch_source = """\
+import sys, os.path, runpy
+sys.path.insert(0, %s)
+runpy._run_module_as_main(%r)
+"""
+
+def _make_launch_script(script_dir, script_basename, module_name, path=None):
+    if path is None:
+        path = "os.path.dirname(__file__)"
+    else:
+        path = repr(path)
+    source = launch_source % (path, module_name)
+    return make_script(script_dir, script_basename, source)
+
+class CmdLineTest(unittest.TestCase):
+    def _check_script(self, script_name, expected_file,
+                            expected_argv0, expected_package,
+                            *cmd_line_switches):
+        run_args = cmd_line_switches + (script_name,)
+        exit_code, data = run_python(*run_args)
+        if verbose:
+            print 'Output from test script %r:' % script_name
+            print data
+        self.assertEqual(exit_code, 0)
+        printed_file = '__file__==%r' % expected_file
+        printed_argv0 = 'sys.argv[0]==%r' % expected_argv0
+        printed_package = '__package__==%r' % expected_package
+        if verbose:
+            print 'Expected output:'
+            print printed_file
+            print printed_package
+            print printed_argv0
+        self.assertIn(printed_file, data)
+        self.assertIn(printed_package, data)
+        self.assertIn(printed_argv0, data)
+
+    def _check_import_error(self, script_name, expected_msg,
+                            *cmd_line_switches):
+        run_args = cmd_line_switches + (script_name,)
+        exit_code, data = run_python(*run_args)
+        if verbose:
+            print 'Output from test script %r:' % script_name
+            print data
+            print 'Expected output: %r' % expected_msg
+        self.assertIn(expected_msg, data)
+
+    def test_basic_script(self):
+        with temp_dir() as script_dir:
+            script_name = _make_test_script(script_dir, 'script')
+            self._check_script(script_name, script_name, script_name, None)
+
+    def test_script_compiled(self):
+        with temp_dir() as script_dir:
+            script_name = _make_test_script(script_dir, 'script')
+            compiled_name = compile_script(script_name)
+            os.remove(script_name)
+            self._check_script(compiled_name, compiled_name, compiled_name, None)
+
+    def test_directory(self):
+        with temp_dir() as script_dir:
+            script_name = _make_test_script(script_dir, '__main__')
+            self._check_script(script_dir, script_name, script_dir, '')
+
+    def test_directory_compiled(self):
+        if test.test_support.check_impl_detail(pypy=True):
+            raise unittest.SkipTest("pypy won't load lone .pyc files")
+        with temp_dir() as script_dir:
+            script_name = _make_test_script(script_dir, '__main__')
+            compiled_name = compile_script(script_name)
+            os.remove(script_name)
+            self._check_script(script_dir, compiled_name, script_dir, '')
+
+    def test_directory_error(self):
+        with temp_dir() as script_dir:
+            msg = "can't find '__main__' module in %r" % script_dir
+            self._check_import_error(script_dir, msg)
+
+    def test_zipfile(self):
+        with temp_dir() as script_dir:
+            script_name = _make_test_script(script_dir, '__main__')
+            zip_name, run_name = make_zip_script(script_dir, 'test_zip', script_name)
+            self._check_script(zip_name, run_name, zip_name, '')
+
+    def test_zipfile_compiled(self):
+        with temp_dir() as script_dir:
+            script_name = _make_test_script(script_dir, '__main__')
+            compiled_name = compile_script(script_name)
+            zip_name, run_name = make_zip_script(script_dir, 'test_zip', compiled_name)
+            self._check_script(zip_name, run_name, zip_name, '')
+
+    def test_zipfile_error(self):
+        with temp_dir() as script_dir:
+            script_name = _make_test_script(script_dir, 'not_main')
+            zip_name, run_name = make_zip_script(script_dir, 'test_zip', script_name)
+            msg = "can't find '__main__' module in %r" % zip_name
+            self._check_import_error(zip_name, msg)
+
+    def test_module_in_package(self):
+        with temp_dir() as script_dir:
+            pkg_dir = os.path.join(script_dir, 'test_pkg')
+            make_pkg(pkg_dir)
+            script_name = _make_test_script(pkg_dir, 'script')
+            launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.script')
+            self._check_script(launch_name, script_name, script_name, 'test_pkg')
+
+    def test_module_in_package_in_zipfile(self):
+        with temp_dir() as script_dir:
+            zip_name, run_name = _make_test_zip_pkg(script_dir, 'test_zip', 'test_pkg', 'script')
+            launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.script', zip_name)
+            self._check_script(launch_name, run_name, run_name, 'test_pkg')
+
+    def test_module_in_subpackage_in_zipfile(self):
+        with temp_dir() as script_dir:
+            zip_name, run_name = _make_test_zip_pkg(script_dir, 'test_zip', 'test_pkg', 'script', depth=2)
+            launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.test_pkg.script', zip_name)
+            self._check_script(launch_name, run_name, run_name, 'test_pkg.test_pkg')
+
+    def test_package(self):
+        with temp_dir() as script_dir:
+            pkg_dir = os.path.join(script_dir, 'test_pkg')
+            make_pkg(pkg_dir)
+            script_name = _make_test_script(pkg_dir, '__main__')
+            launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
+            self._check_script(launch_name, script_name,
+                               script_name, 'test_pkg')
+
+    def test_package_compiled(self):
+        if test.test_support.check_impl_detail(pypy=True):
+            raise unittest.SkipTest("pypy won't load lone .pyc files")
+        with temp_dir() as script_dir:
+            pkg_dir = os.path.join(script_dir, 'test_pkg')
+            make_pkg(pkg_dir)
+            script_name = _make_test_script(pkg_dir, '__main__')
+            compiled_name = compile_script(script_name)
+            os.remove(script_name)
+            launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
+            self._check_script(launch_name, compiled_name,
+                               compiled_name, 'test_pkg')
+
+    def test_package_error(self):
+        with temp_dir() as script_dir:
+            pkg_dir = os.path.join(script_dir, 'test_pkg')
+            make_pkg(pkg_dir)
+            msg = ("'test_pkg' is a package and cannot "
+                   "be directly executed")
+            launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
+            self._check_import_error(launch_name, msg)
+
+    def test_package_recursion(self):
+        with temp_dir() as script_dir:
+            pkg_dir = os.path.join(script_dir, 'test_pkg')
+            make_pkg(pkg_dir)
+            main_dir = os.path.join(pkg_dir, '__main__')
+            make_pkg(main_dir)
+            msg = ("Cannot use package as __main__ module; "
+                   "'test_pkg' is a package and cannot "
+                   "be directly executed")
+            launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
+            self._check_import_error(launch_name, msg)
+
+
+def test_main():
+    test.test_support.run_unittest(CmdLineTest)
+    test.test_support.reap_children()
+
+if __name__ == '__main__':
+    test_main()

File lib_pypy/_ctypes/function.py

-
-from _ctypes.basics import _CData, _CDataMeta, cdata_from_address
-from _ctypes.primitive import SimpleType
-from _ctypes.basics import ArgumentError, keepalive_key
-from _ctypes.builtin import set_errno, set_last_error
 import _rawffi
 import sys
 import traceback
 
+from _ctypes.basics import ArgumentError, keepalive_key
+from _ctypes.basics import _CData, _CDataMeta, cdata_from_address
+from _ctypes.builtin import set_errno, set_last_error
+from _ctypes.primitive import SimpleType
+
 # XXX this file needs huge refactoring I fear
 
 PARAMFLAG_FIN   = 0x1
 PARAMFLAG_FOUT  = 0x2
 PARAMFLAG_FLCID = 0x4
+PARAMFLAG_COMBINED = PARAMFLAG_FIN | PARAMFLAG_FOUT | PARAMFLAG_FLCID
+
+VALID_PARAMFLAGS = (
+    0,
+    PARAMFLAG_FIN,
+    PARAMFLAG_FIN | PARAMFLAG_FOUT,
+    PARAMFLAG_FIN | PARAMFLAG_FLCID
+    )
+
+WIN64 = sys.platform == 'win32' and sys.maxint == 2**63 - 1
+
 def get_com_error(errcode, riid, pIunk):
     "Win32 specific: build a COM Error exception"
     # XXX need C support code
 
     def _getargtypes(self):
         return self._argtypes_
+
     def _setargtypes(self, argtypes):
         self._ptr = None
         if argtypes is None:
-            self._argtypes_ = None
+            self._argtypes_ = ()
         else:
             for i, argtype in enumerate(argtypes):
                 if not hasattr(argtype, 'from_param'):
                         "item %d in _argtypes_ has no from_param method" % (
                             i + 1,))
             self._argtypes_ = argtypes
+
     argtypes = property(_getargtypes, _setargtypes)
 
+    def _getparamflags(self):
+        return self._paramflags
+
+    def _setparamflags(self, paramflags):
+        if paramflags is None or not self._argtypes_:
+            self._paramflags = None
+            return
+        if not isinstance(paramflags, tuple):
+            raise TypeError("paramflags must be a tuple or None")
+        if len(paramflags) != len(self._argtypes_):
+            raise ValueError("paramflags must have the same length as argtypes")
+        for idx, paramflag in enumerate(paramflags):
+            paramlen = len(paramflag)
+            name = default = None
+            if paramlen == 1:
+                flag = paramflag[0]
+            elif paramlen == 2:
+                flag, name = paramflag
+            elif paramlen == 3:
+                flag, name, default = paramflag
+            else:
+                raise TypeError(
+                    "paramflags must be a sequence of (int [,string [,value]]) "
+                    "tuples"
+                    )
+            if not isinstance(flag, int):
+                raise TypeError(
+                    "paramflags must be a sequence of (int [,string [,value]]) "
+                    "tuples"
+                    )
+            _flag = flag & PARAMFLAG_COMBINED
+            if _flag == PARAMFLAG_FOUT:
+                typ = self._argtypes_[idx]
+                if getattr(typ, '_ffiargshape', None) not in ('P', 'z', 'Z'):
+                    raise TypeError(
+                        "'out' parameter %d must be a pointer type, not %s"
+                        % (idx+1, type(typ).__name__)
+                        )
+            elif _flag not in VALID_PARAMFLAGS:
+                raise TypeError("paramflag value %d not supported" % flag)
+        self._paramflags = paramflags
+
+    paramflags = property(_getparamflags, _setparamflags)
+
     def _getrestype(self):
         return self._restype_
+
     def _setrestype(self, restype):
         self._ptr = None
         if restype is int:
             from ctypes import c_int
             restype = c_int
-        if not isinstance(restype, _CDataMeta) and not restype is None and \
-               not callable(restype):
-            raise TypeError("Expected ctypes type, got %s" % (restype,))
+        if not (isinstance(restype, _CDataMeta) or restype is None or
+                callable(restype)):
+            raise TypeError("restype must be a type, a callable, or None")
         self._restype_ = restype
+
     def _delrestype(self):
         self._ptr = None
         del self._restype_
+
     restype = property(_getrestype, _setrestype, _delrestype)
 
     def _geterrcheck(self):
         return getattr(self, '_errcheck_', None)
+
     def _seterrcheck(self, errcheck):
         if not callable(errcheck):
             raise TypeError("The errcheck attribute must be callable")
         self._errcheck_ = errcheck
+
     def _delerrcheck(self):
         try:
             del self._errcheck_
         except AttributeError:
             pass
+
     errcheck = property(_geterrcheck, _seterrcheck, _delerrcheck)
 
     def _ffishapes(self, args, restype):
         self.name = None
         self._objects = {keepalive_key(0):self}
         self._needs_free = True
-        argument = None
-        if len(args) == 1:
-            argument = args[0]
 
-        if isinstance(argument, (int, long)):
-            # direct construction from raw address
+        # Empty function object -- this is needed for casts
+        if not args:
+            self._buffer = _rawffi.Array('P')(1)
+            return
+
+        argsl = list(args)
+        argument = argsl.pop(0)
+
+        # Direct construction from raw address
+        if isinstance(argument, (int, long)) and not argsl:
             ffiargs, ffires = self._ffishapes(self._argtypes_, self._restype_)
-            self._ptr = _rawffi.FuncPtr(argument, ffiargs, ffires,
-                                        self._flags_)
+            self._ptr = _rawffi.FuncPtr(argument, ffiargs, ffires, self._flags_)
             self._buffer = self._ptr.byptr()
-        elif callable(argument):
-            # A callback into python
+            return
+
+        # A callback into Python
+        if callable(argument) and not argsl:
             self.callable = argument
             ffiargs, ffires = self._ffishapes(self._argtypes_, self._restype_)
             if self._restype_ is None:
                 ffires = None
-            self._ptr = _rawffi.CallbackPtr(self._wrap_callable(argument,
-                                                                self.argtypes),
-                                            ffiargs, ffires, self._flags_)
+            self._ptr = _rawffi.CallbackPtr(self._wrap_callable(
+                argument, self.argtypes
+                ), ffiargs, ffires, self._flags_)
             self._buffer = self._ptr.byptr()
-        elif isinstance(argument, tuple) and len(argument) == 2:
-            # function exported from a shared library
+            return
+
+        # Function exported from a shared library
+        if isinstance(argument, tuple) and len(argument) == 2:
             import ctypes
-            self.name, self.dll = argument
-            if isinstance(self.dll, str):
-                self.dll = ctypes.CDLL(self.dll)
-            # we need to check dll anyway
+            self.name, dll = argument
+            if isinstance(dll, str):
+                self.dll = ctypes.CDLL(dll)
+            else:
+                self.dll = dll
+            if argsl:
+                self.paramflags = argsl.pop(0)
+                if argsl:
+                    raise TypeError("Unknown constructor %s" % (args,))
+            # We need to check dll anyway
             ptr = self._getfuncptr([], ctypes.c_int)
             self._buffer = ptr.byptr()
+            return
 
-        elif (sys.platform == 'win32' and
-              len(args) >= 2 and isinstance(args[0], (int, long))):
-            # A COM function call, by index
+        # A COM function call, by index
+        if (sys.platform == 'win32' and isinstance(argument, (int, long))
+            and argsl):
             ffiargs, ffires = self._ffishapes(self._argtypes_, self._restype_)
-            self._com_index =  args[0] + 0x1000
-            self.name = args[1]
-            if len(args) > 2:
-                self._paramflags = args[2]
-            # XXX ignored iid = args[3]
+            self._com_index =  argument + 0x1000
+            self.name = argsl.pop(0)
+            if argsl:
+                self.paramflags = argsl.pop(0)
+                if argsl:
+                    self._com_iid = argsl.pop(0)
+                    if argsl:
+                        raise TypeError("Unknown constructor %s" % (args,))
+            return
 
-        elif len(args) == 0:
-            # Empty function object.
-            # this is needed for casts
-            self._buffer = _rawffi.Array('P')(1)
-            return
-        else:
-            raise TypeError("Unknown constructor %s" % (args,))
+        raise TypeError("Unknown constructor %s" % (args,))
 
     def _wrap_callable(self, to_call, argtypes):
         def f(*args):
             return to_call(*args)
         return f
     
-    def __call__(self, *args):
+    def __call__(self, *args, **kwargs):
+        argtypes = self._argtypes_
         if self.callable is not None:
-            if len(args) == len(self._argtypes_):
+            if len(args) == len(argtypes):
                 pass
             elif self._flags_ & _rawffi.FUNCFLAG_CDECL:
-                if len(args) < len(self._argtypes_):
-                    plural = len(self._argtypes_) > 1 and "s" or ""
+                if len(args) < len(argtypes):
+                    plural = len(argtypes) > 1 and "s" or ""
                     raise TypeError(
                         "This function takes at least %d argument%s (%s given)"
-                        % (len(self._argtypes_), plural, len(args)))
+                        % (len(argtypes), plural, len(args)))
                 else:
                     # For cdecl functions, we allow more actual arguments
                     # than the length of the argtypes tuple.
                     args = args[:len(self._argtypes_)]
             else:
-                plural = len(self._argtypes_) > 1 and "s" or ""
+                plural = len(argtypes) > 1 and "s" or ""
                 raise TypeError(
                     "This function takes %d argument%s (%s given)"
-                    % (len(self._argtypes_), plural, len(args)))
+                    % (len(argtypes), plural, len(args)))
 
             # check that arguments are convertible
             ## XXX Not as long as ctypes.cast is a callback function with
             ## py_object arguments...
-            ## self._convert_args(self._argtypes_, args)
+            ## self._convert_args(argtypes, args, {})
 
             try:
                 res = self.callable(*args)
             if self._restype_ is not None:
                 return res
             return
-        argtypes = self._argtypes_
+
+        if argtypes is None:
+            argtypes = []
 
         if self._com_index:
             from ctypes import cast, c_void_p, POINTER
+            if not args:
+                raise ValueError(
+                    "native COM method call without 'this' parameter"
+                    )
             thisarg = cast(args[0], POINTER(POINTER(c_void_p))).contents
             argtypes = [c_void_p] + list(argtypes)
             args = list(args)
             args[0] = args[0].value
         else:
             thisarg = None
-            
-        if argtypes is None:
-            argtypes = []
-        args = self._convert_args(argtypes, args)
+
+        args, outargs = self._convert_args(argtypes, args, kwargs)
         argtypes = [type(arg) for arg in args]
-        
+
         restype = self._restype_
         funcptr = self._getfuncptr(argtypes, restype, thisarg)
         if self._flags_ & _rawffi.FUNCFLAG_USE_ERRNO:
                 set_errno(_rawffi.get_errno())
             if self._flags_ & _rawffi.FUNCFLAG_USE_LASTERROR:
                 set_last_error(_rawffi.get_last_error())
-        result = self._build_result(restype, resbuffer, argtypes, args)
+
+        result = None
+        if self._com_index:
+            if resbuffer[0] & 0x80000000:
+                raise get_com_error(resbuffer[0],
+                                    self._com_iid, args[0])
+            else:
+                result = int(resbuffer[0])
+        elif restype is not None:
+            checker = getattr(self.restype, '_check_retval_', None)
+            if checker:
+                val = restype(resbuffer[0])
+                # the original ctypes seems to make the distinction between
+                # classes defining a new type, and their subclasses
+                if '_type_' in restype.__dict__:
+                    val = val.value
+                result = checker(val)
+            elif not isinstance(restype, _CDataMeta):
+                result = restype(resbuffer[0])
+            else:
+                result = restype._CData_retval(resbuffer)
 
         # The 'errcheck' protocol
         if self._errcheck_:
             if v is not args:
                 result = v
 
-        return result
+        if not outargs:
+            return result
 
+        if len(outargs) == 1:
+            return outargs[0]
+
+        return tuple(outargs)
 
     def _getfuncptr(self, argtypes, restype, thisarg=None):
         if self._ptr is not None and argtypes is self._argtypes_:
                 raise ValueError("COM method call without VTable")
             ptr = thisarg[self._com_index - 0x1000]
             return _rawffi.FuncPtr(ptr, argshapes, resshape, self._flags_)
-        
+
         cdll = self.dll._handle
         try:
             return cdll.ptr(self.name, argshapes, resshape, self._flags_)
         except AttributeError:
             if self._flags_ & _rawffi.FUNCFLAG_CDECL:
                 raise
-
+            # Win64 has no stdcall calling conv, so it should also not have the
+            # name mangling of it.
+            if WIN64:
+                raise
             # For stdcall, try mangled names:
             # funcname -> _funcname@<n>
             # where n is 0, 4, 8, 12, ..., 128
             raise
 
     @staticmethod
-    def _conv_param(argtype, arg, index):
+    def _conv_param(argtype, arg):
         from ctypes import c_char_p, c_wchar_p, c_void_p, c_int
         if argtype is not None:
             arg = argtype.from_param(arg)
         if hasattr(arg, '_as_parameter_'):
             arg = arg._as_parameter_
-
         if isinstance(arg, _CData):
             # The usual case when argtype is defined
             cobj = arg
             cobj = c_int(arg)
         else:
             raise TypeError("Don't know how to handle %s" % (arg,))
-
         return cobj
 
-    def _convert_args(self, argtypes, args):
-        wrapped_args = []
-        consumed = 0
+    def _convert_args(self, argtypes, args, kwargs, marker=object()):
+        callargs = []
+        outargs = []
+        total = len(args)
+        paramflags = self._paramflags
+
+        if self._com_index:
+            inargs_idx = 1
+        else:
+            inargs_idx = 0
+
+        if not paramflags and total < len(argtypes):
+            raise TypeError("not enough arguments")
 
         for i, argtype in enumerate(argtypes):
-            defaultvalue = None
-            if i > 0 and self._paramflags is not None:
-                paramflag = self._paramflags[i-1]
-                if len(paramflag) == 2:
-                    idlflag, name = paramflag
-                elif len(paramflag) == 3:
-                    idlflag, name, defaultvalue = paramflag
+            flag = 0
+            name = None
+            defval = marker
+            if paramflags:
+                paramflag = paramflags[i]
+                paramlen = len(paramflag)
+                name = None
+                if paramlen == 1:
+                    flag = paramflag[0]
+                elif paramlen == 2:
+                    flag, name = paramflag
+                elif paramlen == 3:
+                    flag, name, defval = paramflag
+                flag = flag & PARAMFLAG_COMBINED
+                if flag == PARAMFLAG_FIN | PARAMFLAG_FLCID:
+                    val = defval
+                    if val is marker:
+                        val = 0
+                    wrapped = self._conv_param(argtype, val)
+                    callargs.append(wrapped)
+                elif flag in (0, PARAMFLAG_FIN):
+                    if inargs_idx < total:
+                        val = args[inargs_idx]
+                        inargs_idx += 1
+                    elif kwargs and name in kwargs:
+                        val = kwargs[name]
+                        inargs_idx += 1
+                    elif defval is not marker:
+                        val = defval
+                    elif name:
+                        raise TypeError("required argument '%s' missing" % name)
+                    else:
+                        raise TypeError("not enough arguments")
+                    wrapped = self._conv_param(argtype, val)
+                    callargs.append(wrapped)
+                elif flag == PARAMFLAG_FOUT:
+                    if defval is not marker:
+                        outargs.append(defval)
+                        wrapped = self._conv_param(argtype, defval)
+                    else:
+                        import ctypes
+                        val = argtype._type_()
+                        outargs.append(val)
+                        wrapped = ctypes.byref(val)
+                    callargs.append(wrapped)
                 else:
-                    idlflag = 0
-                idlflag &= (PARAMFLAG_FIN | PARAMFLAG_FOUT | PARAMFLAG_FLCID)
+                    raise ValueError("paramflag %d not yet implemented" % flag)
+            else:
+                try:
+                    wrapped = self._conv_param(argtype, args[i])
+                except (UnicodeError, TypeError, ValueError), e:
+                    raise ArgumentError(str(e))
+                callargs.append(wrapped)
+                inargs_idx += 1
 
-                if idlflag in (0, PARAMFLAG_FIN):
-                    pass
-                elif idlflag == PARAMFLAG_FOUT:
-                    import ctypes
-                    val = argtype._type_()
-                    wrapped = (val, ctypes.byref(val))
-                    wrapped_args.append(wrapped)
-                    continue
-                elif idlflag == PARAMFLAG_FIN | PARAMFLAG_FLCID:
-                    # Always taken from defaultvalue if given,
-                    # else the integer 0.
-                    val = defaultvalue
-                    if val is None:
-                        val = 0
-                    wrapped = self._conv_param(argtype, val, consumed)
-                    wrapped_args.append(wrapped)
-                    continue
-                else:
-                    raise NotImplementedError(
-                        "paramflags = %s" % (self._paramflags[i-1],))
-
-            if consumed < len(args):
-                arg = args[consumed]
-            elif defaultvalue is not None:
-                arg = defaultvalue
-            else:
-                raise TypeError("Not enough arguments")
-
-            try:
-                wrapped = self._conv_param(argtype, arg, consumed)
-            except (UnicodeError, TypeError, ValueError), e:
-                raise ArgumentError(str(e))
-            wrapped_args.append(wrapped)
-            consumed += 1
-
-        if len(wrapped_args) < len(args):
-            extra = args[len(wrapped_args):]
-            argtypes = list(argtypes)
+        if len(callargs) < total:
+            extra = args[len(callargs):]
             for i, arg in enumerate(extra):
                 try:
-                    wrapped = self._conv_param(None, arg, i)
+                    wrapped = self._conv_param(None, arg)
                 except (UnicodeError, TypeError, ValueError), e:
                     raise ArgumentError(str(e))
-                wrapped_args.append(wrapped)
-        return wrapped_args
+                callargs.append(wrapped)
 
-    def _build_result(self, restype, resbuffer, argtypes, argsandobjs):
-        """Build the function result:
-           If there is no OUT parameter, return the actual function result
-           If there is one OUT parameter, return it
-           If there are many OUT parameters, return a tuple"""
-
-        retval = None
-
-        if self._com_index:
-            if resbuffer[0] & 0x80000000:
-                raise get_com_error(resbuffer[0],
-                                    self._com_iid, argsandobjs[0])
-            else:
-                retval = int(resbuffer[0])
-        elif restype is not None:
-            checker = getattr(self.restype, '_check_retval_', None)
-            if checker:
-                val = restype(resbuffer[0])
-                # the original ctypes seems to make the distinction between
-                # classes defining a new type, and their subclasses
-                if '_type_' in restype.__dict__:
-                    val = val.value
-                retval = checker(val)
-            elif not isinstance(restype, _CDataMeta):
-                retval = restype(resbuffer[0])
-            else:
-                retval = restype._CData_retval(resbuffer)
-
-        results = []
-        if self._paramflags:
-            for argtype, obj, paramflag in zip(argtypes[1:], argsandobjs[1:],
-                                               self._paramflags):
-                if len(paramflag) == 2:
-                    idlflag, name = paramflag
-                elif len(paramflag) == 3:
-                    idlflag, name, defaultvalue = paramflag
-                else:
-                    idlflag = 0
-                idlflag &= (PARAMFLAG_FIN | PARAMFLAG_FOUT | PARAMFLAG_FLCID)
-
-                if idlflag in (0, PARAMFLAG_FIN):
-                    pass
-                elif idlflag == PARAMFLAG_FOUT:
-                    val = obj.__ctypes_from_outparam__()
-                    results.append(val)
-                elif idlflag == PARAMFLAG_FIN | PARAMFLAG_FLCID:
-                    pass
-                else:
-                    raise NotImplementedError(
-                        "paramflags = %s" % (paramflag,))
-
-        if results:
-            if len(results) == 1:
-                return results[0]
-            else:
-                return tuple(results)
-
-        # No output parameter, return the actual function result.
-        return retval
+        return callargs, outargs
 
     def __nonzero__(self):
         return bool(self._buffer[0])

File lib_pypy/_scproxy.py

+"""Helper methods for urllib to fetch the proxy configuration settings using
+the SystemConfiguration framework.
+
+"""
+import sys
+if sys.platform != 'darwin':
+    raise ImportError('Requires Mac OS X')
+
+from ctypes import c_int32, c_int64, c_void_p, c_char_p, c_int, cdll
+from ctypes import pointer, create_string_buffer
+from ctypes.util import find_library
+
+kCFNumberSInt32Type = 3
+kCFStringEncodingUTF8 = 134217984
+
+def _CFSetup():
+    sc = cdll.LoadLibrary(find_library("SystemConfiguration"))
+    cf = cdll.LoadLibrary(find_library("CoreFoundation"))
+    sctable = [
+        ('SCDynamicStoreCopyProxies', [c_void_p], c_void_p),
+    ]
+    cftable = [
+        ('CFArrayGetCount', [c_void_p], c_int64),
+        ('CFArrayGetValueAtIndex', [c_void_p, c_int64], c_void_p),
+        ('CFDictionaryGetValue', [c_void_p, c_void_p], c_void_p),
+        ('CFStringCreateWithCString', [c_void_p, c_char_p, c_int32], c_void_p),
+        ('CFStringGetLength', [c_void_p], c_int32),
+        ('CFStringGetCString', [c_void_p, c_char_p, c_int32, c_int32], c_int32),
+        ('CFNumberGetValue', [c_void_p, c_int, c_void_p], c_int32),
+        ('CFRelease', [c_void_p], None),
+    ]
+    scconst = [
+        'kSCPropNetProxiesExceptionsList',
+        'kSCPropNetProxiesExcludeSimpleHostnames',
+        'kSCPropNetProxiesHTTPEnable',
+        'kSCPropNetProxiesHTTPProxy',
+        'kSCPropNetProxiesHTTPPort',
+        'kSCPropNetProxiesHTTPSEnable',
+        'kSCPropNetProxiesHTTPSProxy',
+        'kSCPropNetProxiesHTTPSPort',
+        'kSCPropNetProxiesFTPEnable',
+        'kSCPropNetProxiesFTPProxy',
+        'kSCPropNetProxiesFTPPort',
+        'kSCPropNetProxiesGopherEnable',
+        'kSCPropNetProxiesGopherProxy',
+        'kSCPropNetProxiesGopherPort',
+    ]
+    class CFProxy(object):
+        def __init__(self):
+            for mod, table in [(sc, sctable), (cf, cftable)]:
+                for fname, argtypes, restype in table:
+                    func = getattr(mod, fname)
+                    func.argtypes = argtypes
+                    func.restype = restype
+                    setattr(self, fname, func)
+            for k in scconst:
+                v = None
+                try:
+                    v = c_void_p.in_dll(sc, k)
+                except ValueError:
+                    v = None
+                setattr(self, k, v)
+    return CFProxy()
+ffi = _CFSetup()
+
+def cfstring_to_pystring(value):
+    length = (ffi.CFStringGetLength(value) * 4) + 1
+    buff = create_string_buffer(length)
+    ffi.CFStringGetCString(value, buff, length * 4, kCFStringEncodingUTF8)
+    return unicode(buff.value, 'utf8')
+
+def cfnum_to_int32(num):
+    result_ptr = pointer(c_int32(0))
+    ffi.CFNumberGetValue(num, kCFNumberSInt32Type, result_ptr)
+    return result_ptr[0]
+
+def _get_proxy_settings():
+    result = {'exclude_simple': False}
+    cfdct = ffi.SCDynamicStoreCopyProxies(None)
+    if not cfdct:
+        return result
+    try:
+        k = ffi.kSCPropNetProxiesExcludeSimpleHostnames
+        if k:
+            cfnum = ffi.CFDictionaryGetValue(cfdct, k)
+            if cfnum:
+                result['exclude_simple'] = bool(cfnum_to_int32(cfnum))
+        k = ffi.kSCPropNetProxiesExceptionsList
+        if k:
+            cfarr = ffi.CFDictionaryGetValue(cfdct, k)
+            if cfarr:
+                lst = []
+                for i in range(ffi.CFArrayGetCount(cfarr)):
+                    cfstr = ffi.CFArrayGetValueAtIndex(cfarr, i)
+                    if cfstr:
+                        v = cfstring_to_pystring(cfstr)
+                    else:
+                        v = None
+                    lst.append(v)
+                result['exceptions'] = lst
+        return result
+    finally:
+        ffi.CFRelease(cfdct)
+
+def _get_proxies():
+    result = {}
+    cfdct = ffi.SCDynamicStoreCopyProxies(None)
+    if not cfdct:
+        return result
+    try:
+        for proto in 'HTTP', 'HTTPS', 'FTP', 'Gopher':
+            enabled_key = getattr(ffi, 'kSCPropNetProxies' + proto + 'Enable')
+            proxy_key = getattr(ffi, 'kSCPropNetProxies' + proto + 'Proxy')
+            port_key = getattr(ffi, 'kSCPropNetProxies' + proto + 'Port')
+            cfnum = ffi.CFDictionaryGetValue(cfdct, enabled_key)
+            if cfnum and cfnum_to_int32(cfnum):
+                cfhoststr = ffi.CFDictionaryGetValue(cfdct, proxy_key)
+                cfportnum = ffi.CFDictionaryGetValue(cfdct, port_key)
+                if cfhoststr:
+                    host = cfstring_to_pystring(cfhoststr)
+                    if host:
+                        if cfportnum:
+                            port = cfnum_to_int32(cfportnum)
+                            v = u'http://%s:%d' % (host, port)
+                        else:
+                            v = u'http://%s' % (host,)
+                        result[proto.lower()] = v
+        return result
+    finally:
+        ffi.CFRelease(cfdct)

File py/__init__.py

 
 (c) Holger Krekel and others, 2004-2010
 """
-__version__ = '1.4.2'
+__version__ = '1.4.3.dev0'
 
 from py import _apipkg
 

File py/_io/terminalwriter.py

                     attr |= FOREGROUND_BLUE
                 elif kw.pop('green', False):
                     attr |= FOREGROUND_GREEN
+                elif kw.pop('yellow', False):
+                    attr |= FOREGROUND_GREEN|FOREGROUND_RED
                 else:
-                    attr |= FOREGROUND_BLACK # (oldcolors & 0x0007)
+                    attr |= oldcolors & 0x0007
 
                 SetConsoleTextAttribute(handle, attr)
             if not isinstance(self._file, WriteFile):
                 SetConsoleTextAttribute(handle, oldcolors)
 
     def line(self, s="", **kw):
-        self.write(s+"\n", **kw)
+        self.write(s, **kw) # works better for resetting colors
+        self.write("\n")
 
 class WriteFile(object):
     def __init__(self, writemethod, encoding=None):

File py/bin/py.test

 #!/usr/bin/env python
 from _findpy import pytest
-pytest.main()
+raise SystemExit(pytest.main())

File pypy/annotation/description.py

         else:
             # call to multiple classes: specialization not supported
             classdefs = [desc.getuniqueclassdef() for desc in descs]
+            # If some of the classes have an __init__ and others not, then
+            # we complain, even though in theory it could work if all the
+            # __init__s take no argument.  But it's messy to implement, so
+            # let's just say it is not RPython and you have to add an empty
+            # __init__ to your base class.
+            has_init = False
+            for desc in descs:
+                s_init = desc.s_read_attribute('__init__')
+                has_init |= isinstance(s_init, SomePBC)
+            basedesc = ClassDesc.getcommonbase(descs)
+            s_init = basedesc.s_read_attribute('__init__')
+            parent_has_init = isinstance(s_init, SomePBC)
+            if has_init and not parent_has_init:
+                raise Exception("some subclasses among %r declare __init__(),"
+                                " but not the common parent class" % (descs,))
         # make a PBC of MethodDescs, one for the __init__ of each class
         initdescs = []
         for desc, classdef in zip(descs, classdefs):
                                           args, s_None)
     consider_call_site = staticmethod(consider_call_site)
 
+    def getallbases(self):
+        desc = self
+        while desc is not None:
+            yield desc
+            desc = desc.basedesc
+
+    def getcommonbase(descs):
+        commondesc = descs[0]
+        for desc in descs[1:]:
+            allbases = set(commondesc.getallbases())
+            while desc not in allbases:
+                assert desc is not None, "no common base for %r" % (descs,)
+                desc = desc.basedesc
+            commondesc = desc
+        return commondesc
+    getcommonbase = staticmethod(getcommonbase)
+
     def rowkey(self):
         return self
 

File pypy/annotation/test/test_annrpython.py

         assert s.const == True
 
     def test_alloc_like(self):
-        class C1(object):
+        class Base(object):
             pass
-        class C2(object):
+        class C1(Base):
+            pass
+        class C2(Base):
             pass
 
         def inst(cls):
         a = self.RPythonAnnotator()
         a.build_types(f, [int])
 
+    def test_call_classes_with_noarg_init(self):
+        class A:
+            foo = 21
+        class B(A):
+            foo = 22
+        class C(A):
+            def __init__(self):
+                self.foo = 42
+        class D(A):
+            def __init__(self):
+                self.foo = 43
+        def f(i):
+            if i == 1:
+                cls = B
+            elif i == 2:
+                cls = D
+            else:
+                cls = C
+            return cls().foo
+        a = self.RPythonAnnotator()
+        raises(Exception, a.build_types, f, [int])
+
 
 def g(n):
     return [0,1,2,n]

File pypy/annotation/test/test_description.py

+from pypy.annotation.description import ClassDesc
+
+class FakeBookkeeper:
+    def __init__(self):
+        self.seen = {}
+    def getdesc(self, cls):
+        if cls not in self.seen:
+            self.seen[cls] = ClassDesc(self, cls)
+        return self.seen[cls]
+
+def test_getcommonbase():
+    class Base(object): pass
+    class A(Base):      pass
+    class B(A):         pass
+    class C(B):         pass
+    class D(A):         pass
+    bk = FakeBookkeeper()
+    dA = bk.getdesc(A)
+    dB = bk.getdesc(B)
+    dC = bk.getdesc(C)
+    dD = bk.getdesc(D)
+    assert ClassDesc.getcommonbase([dC, dD]) is dA

File pypy/config/translationoption.py

     ChoiceOption("jit_profiler", "integrate profiler support into the JIT",
                  ["off", "oprofile"],
                  default="off"),
-    BoolOption("jit_ffi", "optimize libffi calls", default=False),
 
     # misc
     BoolOption("verbose", "Print extra information", default=False),

File pypy/conftest.py

                 py.test.skip("cannot runappdirect test: space needs %s = %s, "\
                     "while pypy-c was built with %s" % (key, value, has))
 
-        for name in ('int', 'long', 'str', 'unicode'):
+        for name in ('int', 'long', 'str', 'unicode', 'None'):
             setattr(self, 'w_' + name, eval(name))
 
 

File pypy/interpreter/astcompiler/ast.py

 
 class AST(Wrappable):
 
-    __slots__ = ("initialization_state",)
+    w_dict = None
 
     __metaclass__ = extendabletype
 
     def sync_app_attrs(self, space):
         raise NotImplementedError
 
+    def getdict(self, space):
+        if self.w_dict is None:
+            self.w_dict = space.newdict(instance=True)
+        return self.w_dict
+
+    def reduce_w(self, space):
+        w_dict = self.w_dict
+        if w_dict is None:
+            w_dict = space.newdict()
+        w_type = space.type(self)
+        w_fields = w_type.getdictvalue(space, "_fields")
+        for w_name in space.fixedview(w_fields):
+            space.setitem(w_dict, w_name,
+                          space.getattr(self, w_name))
+        w_attrs = space.findattr(w_type, space.wrap("_attributes"))
+        if w_attrs:
+            for w_name in space.fixedview(w_attrs):
+                space.setitem(w_dict, w_name,
+                              space.getattr(self, w_name))
+        return space.newtuple([space.type(self),
+                               space.newtuple([]),
+                               w_dict])
+
+    def setstate_w(self, space, w_state):
+        for w_name in space.unpackiterable(w_state):
+            space.setattr(self, w_name,
+                          space.getitem(w_state, w_name))
+
 
 class NodeVisitorNotImplemented(Exception):
     pass
 AST.typedef = typedef.TypeDef("AST",
     _fields=_FieldsWrapper([]),
     _attributes=_FieldsWrapper([]),
+    __module__='_ast',
+    __reduce__=interp2app(AST.reduce_w),
+    __setstate__=interp2app(AST.setstate_w),
+    __dict__ = typedef.GetSetProperty(typedef.descr_get_dict,
+                                      typedef.descr_set_dict, cls=AST),
 )
 AST.typedef.acceptable_as_base_class = False
 
         if not (state >> i) & 1:
             missing = required[i]
             if missing is not None:
-                 err = "required attribute '%s' missing from %s"
+                 err = "required field \"%s\" missing from %s"
                  err = err % (missing, host)
                  w_err = space.wrap(err)
                  raise OperationError(space.w_TypeError, w_err)
 
 
 class mod(AST):
-
-    __slots__ = ()
+    pass
 
 class Module(mod):
 
-    __slots__ = ('body', 'w_body')
-
 
     def __init__(self, body):
         self.body = body
 
 class Interactive(mod):
 
-    __slots__ = ('body', 'w_body')
-
 
     def __init__(self, body):
         self.body = body
 
 class Expression(mod):
 
-    __slots__ = ('body')
-
 
     def __init__(self, body):
         self.body = body
 
 class Suite(mod):
 
-    __slots__ = ('body', 'w_body')
-
 
     def __init__(self, body):
         self.body = body
 
 
 class stmt(AST):
-
-    __slots__ = ('lineno', 'col_offset')
-
     def __init__(self, lineno, col_offset):
         self.lineno = lineno
         self.col_offset = col_offset
 
 class FunctionDef(stmt):
 
-    __slots__ = ('name', 'args', 'body', 'w_body', 'decorator_list', 'w_decorator_list')
-
     _lineno_mask = 16
     _col_offset_mask = 32
 
 
 class ClassDef(stmt):
 
-    __slots__ = ('name', 'bases', 'w_bases', 'body', 'w_body', 'decorator_list', 'w_decorator_list')
-
     _lineno_mask = 16
     _col_offset_mask = 32
 
 
 class Return(stmt):
 
-    __slots__ = ('value')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Delete(stmt):
 
-    __slots__ = ('targets', 'w_targets')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Assign(stmt):
 
-    __slots__ = ('targets', 'w_targets', 'value')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class AugAssign(stmt):
 
-    __slots__ = ('target', 'op', 'value')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Print(stmt):
 
-    __slots__ = ('dest', 'values', 'w_values', 'nl')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class For(stmt):
 
-    __slots__ = ('target', 'iter', 'body', 'w_body', 'orelse', 'w_orelse')
-
     _lineno_mask = 16
     _col_offset_mask = 32
 
 
 class While(stmt):
 
-    __slots__ = ('test', 'body', 'w_body', 'orelse', 'w_orelse')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class If(stmt):
 
-    __slots__ = ('test', 'body', 'w_body', 'orelse', 'w_orelse')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class With(stmt):
 
-    __slots__ = ('context_expr', 'optional_vars', 'body', 'w_body')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Raise(stmt):
 
-    __slots__ = ('type', 'inst', 'tback')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class TryExcept(stmt):
 
-    __slots__ = ('body', 'w_body', 'handlers', 'w_handlers', 'orelse', 'w_orelse')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class TryFinally(stmt):
 
-    __slots__ = ('body', 'w_body', 'finalbody', 'w_finalbody')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class Assert(stmt):
 
-    __slots__ = ('test', 'msg')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class Import(stmt):
 
-    __slots__ = ('names', 'w_names')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class ImportFrom(stmt):
 
-    __slots__ = ('module', 'names', 'w_names', 'level')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Exec(stmt):
 
-    __slots__ = ('body', 'globals', 'locals')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Global(stmt):
 
-    __slots__ = ('names', 'w_names')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Expr(stmt):
 
-    __slots__ = ('value')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Pass(stmt):
 
-    __slots__ = ()
-
     _lineno_mask = 1
     _col_offset_mask = 2
 
 
 class Break(stmt):
 
-    __slots__ = ()
-
     _lineno_mask = 1
     _col_offset_mask = 2
 
 
 class Continue(stmt):
 
-    __slots__ = ()
-
     _lineno_mask = 1
     _col_offset_mask = 2
 
 
 
 class expr(AST):
-
-    __slots__ = ('lineno', 'col_offset')
-
     def __init__(self, lineno, col_offset):
         self.lineno = lineno
         self.col_offset = col_offset
 
 class BoolOp(expr):
 
-    __slots__ = ('op', 'values', 'w_values')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class BinOp(expr):
 
-    __slots__ = ('left', 'op', 'right')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class UnaryOp(expr):
 
-    __slots__ = ('op', 'operand')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class Lambda(expr):
 
-    __slots__ = ('args', 'body')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class IfExp(expr):
 
-    __slots__ = ('test', 'body', 'orelse')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Dict(expr):
 
-    __slots__ = ('keys', 'w_keys', 'values', 'w_values')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class Set(expr):
 
-    __slots__ = ('elts', 'w_elts')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class ListComp(expr):
 
-    __slots__ = ('elt', 'generators', 'w_generators')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class SetComp(expr):
 
-    __slots__ = ('elt', 'generators', 'w_generators')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class DictComp(expr):
 
-    __slots__ = ('key', 'value', 'generators', 'w_generators')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class GeneratorExp(expr):
 
-    __slots__ = ('elt', 'generators', 'w_generators')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class Yield(expr):
 
-    __slots__ = ('value')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Compare(expr):
 
-    __slots__ = ('left', 'ops', 'w_ops', 'comparators', 'w_comparators')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Call(expr):
 
-    __slots__ = ('func', 'args', 'w_args', 'keywords', 'w_keywords', 'starargs', 'kwargs')
-
     _lineno_mask = 32
     _col_offset_mask = 64
 
 
 class Repr(expr):
 
-    __slots__ = ('value')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Num(expr):
 
-    __slots__ = ('n')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Str(expr):
 
-    __slots__ = ('s')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 
 class Attribute(expr):
 
-    __slots__ = ('value', 'attr', 'ctx')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Subscript(expr):
 
-    __slots__ = ('value', 'slice', 'ctx')
-
     _lineno_mask = 8
     _col_offset_mask = 16
 
 
 class Name(expr):
 
-    __slots__ = ('id', 'ctx')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class List(expr):
 
-    __slots__ = ('elts', 'w_elts', 'ctx')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class Tuple(expr):
 
-    __slots__ = ('elts', 'w_elts', 'ctx')
-
     _lineno_mask = 4
     _col_offset_mask = 8
 
 
 class Const(expr):
 
-    __slots__ = ('value')
-
     _lineno_mask = 2
     _col_offset_mask = 4
 
 ]
 
 class slice(AST):
-
-    __slots__ = ()
+    pass
 
 class Ellipsis(slice):
 
-    __slots__ = ()
-
 
     def __init__(self):
         self.initialization_state = 0
 
 class Slice(slice):
 
-    __slots__ = ('lower', 'upper', 'step')
-
 
     def __init__(self, lower, upper, step):
         self.lower = lower
 
 class ExtSlice(slice):
 
-    __slots__ = ('dims', 'w_dims')
-
 
     def __init__(self, dims):