Author: Ronan Lamy <[email protected]>
Branch: py3tests
Changeset: r94356:543e3bec6299
Date: 2018-04-17 00:39 +0100
http://bitbucket.org/pypy/pypy/changeset/543e3bec6299/

Log:    Move all pypy/module/*/__init__.py to pypy/module/*/moduledef.py
        (breaks the world a little)

        This will allow py3 to import the tests. The moves were done through
        the rename_moduledef.py script, committed here.

diff too long, truncating to 2000 out of 3849 lines

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -487,7 +487,7 @@
             fullname = importname
             importname = fullname.rsplit('.', 1)[1]
         else:
-            fullname = "pypy.module.%s" % importname
+            fullname = "pypy.module.%s.moduledef" % importname
 
         Module = __import__(fullname,
                             None, None, ["Module"]).Module
diff --git a/pypy/module/__builtin__/__init__.py 
b/pypy/module/__builtin__/__init__.py
--- a/pypy/module/__builtin__/__init__.py
+++ b/pypy/module/__builtin__/__init__.py
@@ -1,114 +0,0 @@
-from pypy.interpreter.error import OperationError
-from pypy.interpreter import module
-from pypy.interpreter.mixedmodule import MixedModule
-import pypy.module.imp.importing
-
-# put builtins here that should be optimized somehow
-
-class Module(MixedModule):
-    """Built-in functions, exceptions, and other objects."""
-    applevel_name = 'builtins'
-
-    appleveldefs = {
-        'input'         : 'app_io.input',
-        'print'         : 'app_io.print_',
-
-        'sorted'        : 'app_functional.sorted',
-        'any'           : 'app_functional.any',
-        'all'           : 'app_functional.all',
-        'sum'           : 'app_functional.sum',
-        'vars'          : 'app_inspect.vars',
-        'dir'           : 'app_inspect.dir',
-
-        'bin'           : 'app_operation.bin',
-        'oct'           : 'app_operation.oct',
-        'hex'           : 'app_operation.hex',
-    }
-
-    interpleveldefs = {
-        # constants
-        '__debug__'     : '(space.w_True)',
-        'None'          : '(space.w_None)',
-        'False'         : '(space.w_False)',
-        'True'          : '(space.w_True)',
-        'open'          : 'state.get(space).w_open',
-
-        # interp-level function definitions
-        'abs'           : 'operation.abs',
-        'ascii'         : 'operation.ascii',
-        'chr'           : 'operation.chr',
-        'len'           : 'operation.len',
-        'ord'           : 'operation.ord',
-        'pow'           : 'operation.pow',
-        'repr'          : 'operation.repr',
-        'hash'          : 'operation.hash',
-        'round'         : 'operation.round',
-        'divmod'        : 'operation.divmod',
-        'format'        : 'operation.format',
-        'issubclass'    : 'abstractinst.app_issubclass',
-        'isinstance'    : 'abstractinst.app_isinstance',
-        'getattr'       : 'operation.getattr',
-        'setattr'       : 'operation.setattr',
-        'delattr'       : 'operation.delattr',
-        'hasattr'       : 'operation.hasattr',
-        'iter'          : 'operation.iter',
-        'next'          : 'operation.next',
-        'id'            : 'operation.id',
-        'callable'      : 'operation.callable',
-
-        'compile'       : 'compiling.compile',
-        'eval'          : 'compiling.eval',
-        'exec'          : 'compiling.exec_',
-        '__build_class__': 'compiling.build_class',
-
-        '__import__'    : 'pypy.module.imp.importing.importhook',
-
-        'range'         : 'functional.W_Range',
-        'enumerate'     : 'functional.W_Enumerate',
-        'map'           : 'functional.W_Map',
-        'filter'        : 'functional.W_Filter',
-        'zip'           : 'functional.W_Zip',
-        'min'           : 'functional.min',
-        'max'           : 'functional.max',
-        'reversed'      : 'functional.W_ReversedIterator',
-        'super'         : 'descriptor.W_Super',
-        'staticmethod'  : 'pypy.interpreter.function.StaticMethod',
-        'classmethod'   : 'pypy.interpreter.function.ClassMethod',
-        'property'      : 'descriptor.W_Property',
-
-        'globals'       : 'interp_inspect.globals',
-        'locals'        : 'interp_inspect.locals',
-
-    }
-
-    def pick_builtin(self, w_globals):
-        "Look up the builtin module to use from the __builtins__ global"
-        # pick the __builtins__ roughly in the same way CPython does it
-        # this is obscure and slow
-        space = self.space
-        try:
-            w_builtin = space.getitem(w_globals, space.newtext('__builtins__'))
-        except OperationError as e:
-            if not e.match(space, space.w_KeyError):
-                raise
-        else:
-            if w_builtin is space.builtin:   # common case
-                return space.builtin
-            if space.isinstance_w(w_builtin, space.w_dict):
-                return module.Module(space, None, w_builtin)
-            if isinstance(w_builtin, module.Module):
-                return w_builtin
-        # no builtin! make a default one.  Give them None, at least.
-        builtin = module.Module(space, None)
-        space.setitem(builtin.w_dict, space.newtext('None'), space.w_None)
-        return builtin
-
-    def setup_after_space_initialization(self):
-        """NOT_RPYTHON"""
-        space = self.space
-        # install the more general version of isinstance() & co. in the space
-        from pypy.module.__builtin__ import abstractinst as ab
-        space.abstract_isinstance_w = ab.abstract_isinstance_w.__get__(space)
-        space.abstract_issubclass_w = ab.abstract_issubclass_w.__get__(space)
-        space.abstract_isclass_w = ab.abstract_isclass_w.__get__(space)
-        space.abstract_getclass = ab.abstract_getclass.__get__(space)
diff --git a/pypy/module/__builtin__/__init__.py 
b/pypy/module/__builtin__/moduledef.py
copy from pypy/module/__builtin__/__init__.py
copy to pypy/module/__builtin__/moduledef.py
diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py
--- a/pypy/module/__pypy__/__init__.py
+++ b/pypy/module/__pypy__/__init__.py
@@ -1,144 +0,0 @@
-import sys
-
-from pypy.interpreter.mixedmodule import MixedModule
-from pypy.module.imp.importing import get_pyc_magic
-from rpython.rlib import rtime
-
-
-class BuildersModule(MixedModule):
-    """ Module containing string and unicode builders """
-
-    appleveldefs = {}
-
-    interpleveldefs = {
-        "StringBuilder": "interp_builders.W_StringBuilder",
-        "BytesBuilder": "interp_builders.W_BytesBuilder",
-    }
-
-class TimeModule(MixedModule):
-    appleveldefs = {}
-    interpleveldefs = {}
-    if rtime.HAS_CLOCK_GETTIME:
-        interpleveldefs["clock_gettime"] = "interp_time.clock_gettime"
-        interpleveldefs["clock_getres"] = "interp_time.clock_getres"
-        for name in rtime.ALL_DEFINED_CLOCKS:
-            interpleveldefs[name] = "space.wrap(%d)" % getattr(rtime, name)
-
-
-class ThreadModule(MixedModule):
-    appleveldefs = {
-        'signals_enabled': 'app_signal.signals_enabled',
-    }
-    interpleveldefs = {
-        '_signals_enter':  'interp_signal.signals_enter',
-        '_signals_exit':   'interp_signal.signals_exit',
-    }
-
-
-class IntOpModule(MixedModule):
-    """ Module for integer operations that have two-complement overflow
-    behaviour instead of overflowing to longs """
-    appleveldefs = {}
-    interpleveldefs = {
-        'int_add':         'interp_intop.int_add',
-        'int_sub':         'interp_intop.int_sub',
-        'int_mul':         'interp_intop.int_mul',
-        'int_floordiv':    'interp_intop.int_floordiv',
-        'int_mod':         'interp_intop.int_mod',
-        'int_lshift':      'interp_intop.int_lshift',
-        'int_rshift':      'interp_intop.int_rshift',
-        'uint_rshift':     'interp_intop.uint_rshift',
-    }
-
-
-class OsModule(MixedModule):
-    appleveldefs = {}
-    interpleveldefs = {
-        'real_getenv': 'interp_os.real_getenv'
-    }
-
-
-class PyPyDateTime(MixedModule):
-    appleveldefs = {}
-    interpleveldefs = {
-        'dateinterop': 'interp_pypydatetime.W_DateTime_Date',
-        'timeinterop'    : 'interp_pypydatetime.W_DateTime_Time',
-        'deltainterop'   : 'interp_pypydatetime.W_DateTime_Delta',
-    }
-
-class Module(MixedModule):
-    """ PyPy specific "magic" functions. A lot of them are experimental and
-    subject to change, many are internal. """
-    appleveldefs = {
-    }
-
-    interpleveldefs = {
-        'attach_gdb'                : 'interp_magic.attach_gdb',
-        'internal_repr'             : 'interp_magic.internal_repr',
-        'objects_in_repr'           : 'interp_magic.objects_in_repr',
-        'bytebuffer'                : 'bytebuffer.bytebuffer',
-        'identity_dict'             : 'interp_identitydict.W_IdentityDict',
-        'debug_start'               : 'interp_debug.debug_start',
-        'debug_print'               : 'interp_debug.debug_print',
-        'debug_stop'                : 'interp_debug.debug_stop',
-        'debug_print_once'          : 'interp_debug.debug_print_once',
-        'debug_flush'               : 'interp_debug.debug_flush',
-        'builtinify'                : 'interp_magic.builtinify',
-        'hidden_applevel'           : 'interp_magic.hidden_applevel',
-        'lookup_special'            : 'interp_magic.lookup_special',
-        'do_what_I_mean'            : 'interp_magic.do_what_I_mean',
-        'resizelist_hint'           : 'interp_magic.resizelist_hint',
-        'newlist_hint'              : 'interp_magic.newlist_hint',
-        'add_memory_pressure'       : 'interp_magic.add_memory_pressure',
-        'newdict'                   : 'interp_dict.newdict',
-        'reversed_dict'             : 'interp_dict.reversed_dict',
-        'dict_popitem_first'        : 'interp_dict.dict_popitem_first',
-        'delitem_if_value_is'       : 'interp_dict.delitem_if_value_is',
-        'move_to_end'               : 'interp_dict.move_to_end',
-        'strategy'                  : 'interp_magic.strategy',  # dict,set,list
-        'set_debug'                 : 'interp_magic.set_debug',
-        'locals_to_fast'            : 'interp_magic.locals_to_fast',
-        'set_code_callback'         : 'interp_magic.set_code_callback',
-        'decode_long'               : 'interp_magic.decode_long',
-        '_promote'                   : 'interp_magic._promote',
-        'normalize_exc'             : 'interp_magic.normalize_exc',
-        'StdErrPrinter'             : 'interp_stderrprinter.W_StdErrPrinter',
-        'stack_almost_full'         : 'interp_magic.stack_almost_full',
-        'fsencode'                  : 'interp_magic.fsencode',
-        'fsdecode'                  : 'interp_magic.fsdecode',
-    }
-
-    submodules = {
-        "builders": BuildersModule,
-        "time": TimeModule,
-        "thread": ThreadModule,
-        "intop": IntOpModule,
-        "os": OsModule,
-        '_pypydatetime': PyPyDateTime,
-    }
-
-    def setup_after_space_initialization(self):
-        """NOT_RPYTHON"""
-        if self.space.config.objspace.std.withmethodcachecounter:
-            self.extra_interpdef('method_cache_counter',
-                                 'interp_magic.method_cache_counter')
-            self.extra_interpdef('reset_method_cache_counter',
-                                 'interp_magic.reset_method_cache_counter')
-            self.extra_interpdef('mapdict_cache_counter',
-                                 'interp_magic.mapdict_cache_counter')
-        PYC_MAGIC = get_pyc_magic(self.space)
-        self.extra_interpdef('PYC_MAGIC', 'space.wrap(%d)' % PYC_MAGIC)
-        try:
-            from rpython.jit.backend import detect_cpu
-            model = detect_cpu.autodetect()
-            self.extra_interpdef('cpumodel', 'space.wrap(%r)' % model)
-        except Exception:
-            if self.space.config.translation.jit:
-                raise
-            else:
-                pass   # ok fine to ignore in this case
-
-        if self.space.config.translation.jit:
-            features = detect_cpu.getcpufeatures(model)
-            self.extra_interpdef('jit_backend_features',
-                                    'space.wrap(%r)' % features)
diff --git a/pypy/module/__pypy__/__init__.py 
b/pypy/module/__pypy__/moduledef.py
copy from pypy/module/__pypy__/__init__.py
copy to pypy/module/__pypy__/moduledef.py
diff --git a/pypy/module/_ast/__init__.py b/pypy/module/_ast/__init__.py
--- a/pypy/module/_ast/__init__.py
+++ b/pypy/module/_ast/__init__.py
@@ -1,21 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-from pypy.interpreter.astcompiler import ast, consts
-
-
-class Module(MixedModule):
-
-    interpleveldefs = {
-        "PyCF_ONLY_AST" : "space.wrap(%s)" % consts.PyCF_ONLY_AST,
-        "PyCF_ACCEPT_NULL_BYTES":
-                          "space.wrap(%s)" % consts.PyCF_ACCEPT_NULL_BYTES,
-        "__version__"   : "space.wrap('82160')",  # from CPython's svn.
-        }
-    appleveldefs = {}
-
-
-def _setup():
-    defs = Module.interpleveldefs
-    defs['AST'] = "pypy.interpreter.astcompiler.ast.get(space).w_AST"
-    for (name, base, fields, attributes) in ast.State.AST_TYPES:
-        defs[name] = "pypy.interpreter.astcompiler.ast.get(space).w_" + name
-_setup()
diff --git a/pypy/module/_ast/__init__.py b/pypy/module/_ast/moduledef.py
copy from pypy/module/_ast/__init__.py
copy to pypy/module/_ast/moduledef.py
diff --git a/pypy/module/_cffi_backend/__init__.py 
b/pypy/module/_cffi_backend/__init__.py
--- a/pypy/module/_cffi_backend/__init__.py
+++ b/pypy/module/_cffi_backend/__init__.py
@@ -1,92 +0,0 @@
-import sys
-from pypy.interpreter.mixedmodule import MixedModule
-from rpython.rlib import rdynload, clibffi
-from rpython.rtyper.lltypesystem import rffi
-
-VERSION = "1.11.5"
-
-FFI_DEFAULT_ABI = clibffi.FFI_DEFAULT_ABI
-try:
-    FFI_STDCALL = clibffi.FFI_STDCALL
-    has_stdcall = True
-except AttributeError:
-    has_stdcall = False
-
-
-class Module(MixedModule):
-
-    appleveldefs = {
-        }
-    interpleveldefs = {
-        '__version__': 'space.wrap("%s")' % VERSION,
-
-        'load_library': 'libraryobj.load_library',
-
-        'new_primitive_type': 'newtype.new_primitive_type',
-        'new_pointer_type': 'newtype.new_pointer_type',
-        'new_array_type': 'newtype.new_array_type',
-        'new_struct_type': 'newtype.new_struct_type',
-        'new_union_type': 'newtype.new_union_type',
-        'complete_struct_or_union': 'newtype.complete_struct_or_union',
-        'new_void_type': 'newtype.new_void_type',
-        'new_enum_type': 'newtype.new_enum_type',
-        'new_function_type': 'newtype.new_function_type',
-
-        'newp': 'func.newp',
-        'cast': 'func.cast',
-        'callback': 'func.callback',
-        'alignof': 'func.alignof',
-        'sizeof': 'func.sizeof',
-        'typeof': 'func.typeof',
-        'typeoffsetof': 'func.typeoffsetof',
-        'rawaddressof': 'func.rawaddressof',
-        'getcname': 'func.getcname',
-        'newp_handle': 'handle.newp_handle',
-        'from_handle': 'handle.from_handle',
-        '_get_types': 'func._get_types',
-        '_get_common_types': 'func._get_common_types',
-        'from_buffer': 'func.from_buffer',
-        'gcp': 'func.gcp',
-
-        'string': 'func.string',
-        'unpack': 'func.unpack',
-        'buffer': 'cbuffer.MiniBuffer',
-        'memmove': 'func.memmove',
-
-        'get_errno': 'cerrno.get_errno',
-        'set_errno': 'cerrno.set_errno',
-
-        'FFI_DEFAULT_ABI': 'space.wrap(%d)' % FFI_DEFAULT_ABI,
-        'FFI_CDECL':       'space.wrap(%d)' % FFI_DEFAULT_ABI,  # win32 name
-
-        # CFFI 1.0
-        'FFI': 'ffi_obj.W_FFIObject',
-        }
-    if sys.platform == 'win32':
-        interpleveldefs['getwinerror'] = 'cerrno.getwinerror'
-
-    if has_stdcall:
-        interpleveldefs['FFI_STDCALL'] = 'space.wrap(%d)' % FFI_STDCALL
-
-    def __init__(self, space, *args):
-        MixedModule.__init__(self, space, *args)
-        #
-        if not space.config.objspace.disable_entrypoints:
-            # import 'embedding', which has the side-effect of registering
-            # the 'pypy_init_embedded_cffi_module' entry point
-            from pypy.module._cffi_backend import embedding
-            embedding.glob.space = space
-
-
-def get_dict_rtld_constants():
-    found = {}
-    for name in ["RTLD_LAZY", "RTLD_NOW", "RTLD_GLOBAL", "RTLD_LOCAL",
-                 "RTLD_NODELETE", "RTLD_NOLOAD", "RTLD_DEEPBIND"]:
-        if getattr(rdynload.cConfig, name) is not None:
-            found[name] = getattr(rdynload.cConfig, name)
-    for name in ["RTLD_LAZY", "RTLD_NOW", "RTLD_GLOBAL", "RTLD_LOCAL"]:
-        found.setdefault(name, 0)
-    return found
-
-for _name, _value in get_dict_rtld_constants().items():
-    Module.interpleveldefs[_name] = 'space.wrap(%d)' % _value
diff --git a/pypy/module/_cffi_backend/__init__.py 
b/pypy/module/_cffi_backend/moduledef.py
copy from pypy/module/_cffi_backend/__init__.py
copy to pypy/module/_cffi_backend/moduledef.py
diff --git a/pypy/module/_codecs/__init__.py b/pypy/module/_codecs/__init__.py
--- a/pypy/module/_codecs/__init__.py
+++ b/pypy/module/_codecs/__init__.py
@@ -1,98 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-from rpython.rlib import runicode
-from rpython.rlib.objectmodel import not_rpython
-from pypy.module._codecs import interp_codecs
-
-class Module(MixedModule):
-    """
-   _codecs -- Provides access to the codec registry and the builtin
-              codecs.
-
-   This module should never be imported directly. The standard library
-   module "codecs" wraps this builtin module for use within Python.
-
-   The codec registry is accessible via:
-
-     register(search_function) -> None
-
-     lookup(encoding) -> (encoder, decoder, stream_reader, stream_writer)
-
-   The builtin Unicode codecs use the following interface:
-
-     <encoding>_encode(Unicode_object[,errors='strict']) ->
-         (string object, bytes consumed)
-
-     <encoding>_decode(char_buffer_obj[,errors='strict']) ->
-        (Unicode object, bytes consumed)
-
-   <encoding>_encode() interfaces also accept non-Unicode object as
-   input. The objects are then converted to Unicode using
-   PyUnicode_FromObject() prior to applying the conversion.
-
-   These <encoding>s are available: utf_8, unicode_escape,
-   raw_unicode_escape, unicode_internal, latin_1, ascii (7-bit),
-   mbcs (on win32).
-
-
-Written by Marc-Andre Lemburg ([email protected]).
-
-Copyright (c) Corporation for National Research Initiatives.
-"""
-
-    appleveldefs = {}
-
-    interpleveldefs = {
-         'encode':         'interp_codecs.encode',
-         'decode':         'interp_codecs.decode',
-         'lookup':         'interp_codecs.lookup_codec',
-         'lookup_error':   'interp_codecs.lookup_error',
-         'register':       'interp_codecs.register_codec',
-         'register_error': 'interp_codecs.register_error',
-         'charmap_build' : 'interp_codecs.charmap_build',
-
-         # encoders and decoders
-         'ascii_decode'     : 'interp_codecs.ascii_decode',
-         'ascii_encode'     : 'interp_codecs.ascii_encode',
-         'latin_1_decode'   : 'interp_codecs.latin_1_decode',
-         'latin_1_encode'   : 'interp_codecs.latin_1_encode',
-         'utf_7_decode'     : 'interp_codecs.utf_7_decode',
-         'utf_7_encode'     : 'interp_codecs.utf_7_encode',
-         'utf_8_decode'     : 'interp_codecs.utf_8_decode',
-         'utf_8_encode'     : 'interp_codecs.utf_8_encode',
-         'utf_16_be_decode' : 'interp_codecs.utf_16_be_decode',
-         'utf_16_be_encode' : 'interp_codecs.utf_16_be_encode',
-         'utf_16_decode'    : 'interp_codecs.utf_16_decode',
-         'utf_16_encode'    : 'interp_codecs.utf_16_encode',
-         'utf_16_le_decode' : 'interp_codecs.utf_16_le_decode',
-         'utf_16_le_encode' : 'interp_codecs.utf_16_le_encode',
-         'utf_16_ex_decode' : 'interp_codecs.utf_16_ex_decode',
-         'utf_32_decode'    : 'interp_codecs.utf_32_decode',
-         'utf_32_encode'    : 'interp_codecs.utf_32_encode',
-         'utf_32_be_decode' : 'interp_codecs.utf_32_be_decode',
-         'utf_32_be_encode' : 'interp_codecs.utf_32_be_encode',
-         'utf_32_le_decode' : 'interp_codecs.utf_32_le_decode',
-         'utf_32_le_encode' : 'interp_codecs.utf_32_le_encode',
-         'utf_32_ex_decode' : 'interp_codecs.utf_32_ex_decode',
-         'readbuffer_encode': 'interp_codecs.readbuffer_encode',
-         'charmap_decode'   : 'interp_codecs.charmap_decode',
-         'charmap_encode'   : 'interp_codecs.charmap_encode',
-         'escape_encode'    : 'interp_codecs.escape_encode',
-         'escape_decode'    : 'interp_codecs.escape_decode',
-         'unicode_escape_decode'     :  'interp_codecs.unicode_escape_decode',
-         'unicode_escape_encode'     :  'interp_codecs.unicode_escape_encode',
-         'raw_unicode_escape_decode' :  
'interp_codecs.raw_unicode_escape_decode',
-         'raw_unicode_escape_encode' :  
'interp_codecs.raw_unicode_escape_encode',
-         'unicode_internal_decode'   :  
'interp_codecs.unicode_internal_decode',
-         'unicode_internal_encode'   :  
'interp_codecs.unicode_internal_encode',
-    }
-
-    @not_rpython
-    def __init__(self, space, *args):
-        # mbcs codec is Windows specific, and based on rffi.
-        if (hasattr(runicode, 'str_decode_mbcs')):
-            self.interpleveldefs['mbcs_encode'] = 'interp_codecs.mbcs_encode'
-            self.interpleveldefs['mbcs_decode'] = 'interp_codecs.mbcs_decode'
-
-        MixedModule.__init__(self, space, *args)
-
-        interp_codecs.register_builtin_error_handlers(space)
diff --git a/pypy/module/_codecs/__init__.py b/pypy/module/_codecs/moduledef.py
copy from pypy/module/_codecs/__init__.py
copy to pypy/module/_codecs/moduledef.py
diff --git a/pypy/module/_collections/__init__.py 
b/pypy/module/_collections/__init__.py
--- a/pypy/module/_collections/__init__.py
+++ b/pypy/module/_collections/__init__.py
@@ -1,39 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-    """High performance data structures.
-- deque:        ordered collection accessible from endpoints only
-- defaultdict:  dict subclass with a default value factory
-"""
-
-    appleveldefs = {
-        'defaultdict': 'app_defaultdict.defaultdict',
-        }
-
-    interpleveldefs = {
-        'deque' : 'interp_deque.W_Deque',
-        'deque_iterator' : 'interp_deque.W_DequeIter',
-        'deque_reverse_iterator' : 'interp_deque.W_DequeRevIter',
-        '__missing__': 'interp_defaultdict.missing',
-        }
-
-    def setup_after_space_initialization(self):
-        """NOT_RPYTHON"""
-        # must remove the interp-level name '__missing__' after it has
-        # been used...  otherwise, some code is not happy about seeing
-        # this code object twice
-        space = self.space
-        space.getattr(self, space.newtext('defaultdict'))  # force importing
-        space.delattr(self, space.newtext('__missing__'))
-
-    def startup(self, space):
-        # OrderedDict is normally present, but in some cases the line
-        # "from __pypy__ import reversed_dict, move_to_end" from
-        # _pypy_collections.py raises
-        space.appexec([self], """(mod):
-            try:
-                from _pypy_collections import OrderedDict
-                mod.OrderedDict = OrderedDict
-            except ImportError:
-                pass
-        """)
diff --git a/pypy/module/_collections/__init__.py 
b/pypy/module/_collections/moduledef.py
copy from pypy/module/_collections/__init__.py
copy to pypy/module/_collections/moduledef.py
diff --git a/pypy/module/_continuation/__init__.py 
b/pypy/module/_continuation/__init__.py
--- a/pypy/module/_continuation/__init__.py
+++ b/pypy/module/_continuation/__init__.py
@@ -1,41 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-
-
-class Module(MixedModule):
-    """This module exposes 'one-shot continuation containers'.
-
-A 'continulet' object from this module is a container that stores a
-one-shot continuation.  It is similar in purpose to the 'f_back'
-attribute of frames, which points to where execution should continue
-after this frame finishes.  The difference is that it will be changed
-(often repeatedly) before the frame actually returns.
-
-To make a continulet object, call 'continulet' with a callable and
-optional extra arguments.  Later, the first time you switch() to the
-continulet, the callable is invoked with the same continulet object as
-the extra first argument.
-
-At this point, the one-shot continuation stored in the continulet points
-to the caller of switch().  When switch() is called again, this one-shot
-continuation is exchanged with the current one; it means that the caller
-of switch() is suspended, its continuation stored in the container, and
-the old continuation from the continulet object is resumed.
-
-Continulets are internally implemented using stacklets.  Stacklets
-are a bit more primitive (they are really one-shot continuations), but
-that idea only works in C, not in Python, notably because of exceptions.
-
-The most primitive API is actually 'permute()', which just permutes the
-one-shot continuation stored in two (or more) continulets.
-"""
-
-    appleveldefs = {
-        'error': 'app_continuation.error',
-        'generator': 'app_continuation.generator',
-    }
-
-    interpleveldefs = {
-        'continulet': 'interp_continuation.W_Continulet',
-        'permute': 'interp_continuation.permute',
-        '_p': 'interp_continuation.unpickle',      # pickle support
-    }
diff --git a/pypy/module/_continuation/__init__.py 
b/pypy/module/_continuation/moduledef.py
copy from pypy/module/_continuation/__init__.py
copy to pypy/module/_continuation/moduledef.py
diff --git a/pypy/module/_cppyy/__init__.py b/pypy/module/_cppyy/__init__.py
--- a/pypy/module/_cppyy/__init__.py
+++ b/pypy/module/_cppyy/__init__.py
@@ -1,42 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-    "This module brigdes the cppyy frontend with its backend, through PyPy.\n\
-    See http://cppyy.readthedocs.io/en/latest for full details."
-
-    interpleveldefs = {
-        '_resolve_name'          : 'interp_cppyy.resolve_name',
-        '_scope_byname'          : 'interp_cppyy.scope_byname',
-        '_is_template'           : 'interp_cppyy.is_template',
-        '_std_string_name'       : 'interp_cppyy.std_string_name',
-        '_set_class_generator'   : 'interp_cppyy.set_class_generator',
-        '_set_function_generator': 'interp_cppyy.set_function_generator',
-        '_register_class'        : 'interp_cppyy.register_class',
-        '_get_nullptr'           : 'interp_cppyy.get_nullptr',
-        'CPPClassBase'           : 'interp_cppyy.W_CPPClass',
-        'addressof'              : 'interp_cppyy.addressof',
-        '_bind_object'           : 'interp_cppyy._bind_object',
-        'bind_object'            : 'interp_cppyy.bind_object',
-        'move'                   : 'interp_cppyy.move',
-    }
-
-    appleveldefs = {
-        '_init_pythonify'        : 'pythonify._init_pythonify',
-        'add_pythonization'      : 'pythonify.add_pythonization',
-        'Template'               : 'pythonify.CPPTemplate',
-    }
-
-    def __init__(self, space, *args):
-        "NOT_RPYTHON"
-        MixedModule.__init__(self, space, *args)
-
-        # pythonization functions may be written in RPython, but the interp2app
-        # code generation is not, so give it a chance to run now
-        from pypy.module._cppyy import capi
-        capi.register_pythonizations(space)
-
-    def startup(self, space):
-        from pypy.module._cppyy import capi
-        capi.verify_backend(space)      # may raise ImportError
-
-        space.call_method(self, '_init_pythonify')
diff --git a/pypy/module/_cppyy/__init__.py b/pypy/module/_cppyy/moduledef.py
copy from pypy/module/_cppyy/__init__.py
copy to pypy/module/_cppyy/moduledef.py
diff --git a/pypy/module/_csv/__init__.py b/pypy/module/_csv/__init__.py
--- a/pypy/module/_csv/__init__.py
+++ b/pypy/module/_csv/__init__.py
@@ -1,87 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-
-
-class Module(MixedModule):
-    """CSV parsing and writing.
-
-This module provides classes that assist in the reading and writing
-of Comma Separated Value (CSV) files, and implements the interface
-described by PEP 305.  Although many CSV files are simple to parse,
-the format is not formally defined by a stable specification and
-is subtle enough that parsing lines of a CSV file with something
-like line.split(\",\") is bound to fail.  The module supports three
-basic APIs: reading, writing, and registration of dialects.
-
-
-DIALECT REGISTRATION:
-
-Readers and writers support a dialect argument, which is a convenient
-handle on a group of settings.  When the dialect argument is a string,
-it identifies one of the dialects previously registered with the module.
-If it is a class or instance, the attributes of the argument are used as
-the settings for the reader or writer:
-
-    class excel:
-        delimiter = ','
-        quotechar = '\"'
-        escapechar = None
-        doublequote = True
-        skipinitialspace = False
-        lineterminator = '\\r\\n'
-        quoting = QUOTE_MINIMAL
-
-SETTINGS:
-
-    * quotechar - specifies a one-character string to use as the 
-        quoting character.  It defaults to '\"'.
-    * delimiter - specifies a one-character string to use as the 
-        field separator.  It defaults to ','.
-    * skipinitialspace - specifies how to interpret whitespace which
-        immediately follows a delimiter.  It defaults to False, which
-        means that whitespace immediately following a delimiter is part
-        of the following field.
-    * lineterminator -  specifies the character sequence which should 
-        terminate rows.
-    * quoting - controls when quotes should be generated by the writer.
-        It can take on any of the following module constants:
-
-        csv.QUOTE_MINIMAL means only when required, for example, when a
-            field contains either the quotechar or the delimiter
-        csv.QUOTE_ALL means that quotes are always placed around fields.
-        csv.QUOTE_NONNUMERIC means that quotes are always placed around
-            fields which do not parse as integers or floating point
-            numbers.
-        csv.QUOTE_NONE means that quotes are never placed around fields.
-    * escapechar - specifies a one-character string used to escape 
-        the delimiter when quoting is set to QUOTE_NONE.
-    * doublequote - controls the handling of quotes inside fields.  When
-        True, two consecutive quotes are interpreted as one during read,
-        and when writing, each quote character embedded in the data is
-        written as two quotes.
-"""
-
-    appleveldefs = {
-        'register_dialect':   'app_csv.register_dialect',
-        'unregister_dialect': 'app_csv.unregister_dialect',
-        'get_dialect':        'app_csv.get_dialect',
-        'list_dialects':      'app_csv.list_dialects',
-        '_dialects':          'app_csv._dialects',
-
-        'Error':              'app_csv.Error',
-        }
-
-    interpleveldefs = {
-        '__version__':      'space.wrap("1.0")',
-
-        'QUOTE_MINIMAL':    'space.wrap(interp_csv.QUOTE_MINIMAL)',
-        'QUOTE_ALL':        'space.wrap(interp_csv.QUOTE_ALL)',
-        'QUOTE_NONNUMERIC': 'space.wrap(interp_csv.QUOTE_NONNUMERIC)',
-        'QUOTE_NONE':       'space.wrap(interp_csv.QUOTE_NONE)',
-
-        'Dialect': 'interp_csv.W_Dialect',
-
-        'reader': 'interp_reader.csv_reader',
-        'field_size_limit': 'interp_reader.csv_field_size_limit',
-
-        'writer': 'interp_writer.csv_writer',
-        }
diff --git a/pypy/module/_csv/__init__.py b/pypy/module/_csv/moduledef.py
copy from pypy/module/_csv/__init__.py
copy to pypy/module/_csv/moduledef.py
diff --git a/pypy/module/_demo/__init__.py b/pypy/module/_demo/__init__.py
--- a/pypy/module/_demo/__init__.py
+++ b/pypy/module/_demo/__init__.py
@@ -1,24 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule 
-
-class Module(MixedModule):
-    """A demo built-in module based on ctypes."""
-
-    interpleveldefs = {
-        'measuretime'      : 'demo.measuretime',
-        'sieve'            : 'demo.sieve',
-        'MyType'           : 'demo.W_MyType',
-    }
-
-    appleveldefs = {
-        'DemoError'        : 'app_demo.DemoError',
-    }
-
-    # Used in tests
-    demo_events = []
-    def setup_after_space_initialization(self):
-        Module.demo_events.append('setup')
-    def startup(self, space):
-        Module.demo_events.append('startup')
-    def shutdown(self, space):
-        Module.demo_events.append('shutdown')
-
diff --git a/pypy/module/_demo/__init__.py b/pypy/module/_demo/moduledef.py
copy from pypy/module/_demo/__init__.py
copy to pypy/module/_demo/moduledef.py
diff --git a/pypy/module/_frozen_importlib/__init__.py 
b/pypy/module/_frozen_importlib/__init__.py
--- a/pypy/module/_frozen_importlib/__init__.py
+++ b/pypy/module/_frozen_importlib/__init__.py
@@ -1,84 +0,0 @@
-import os
-from pypy.interpreter.mixedmodule import MixedModule
-from pypy.module.sys import initpath
-from pypy.module._frozen_importlib import interp_import
-
-lib_python = os.path.join(os.path.dirname(__file__),
-                          '..', '..', '..', 'lib-python', '3')
-
-class Module(MixedModule):
-    interpleveldefs = {
-        }
-
-    appleveldefs = {
-        }
-
-    @staticmethod
-    def _compile_bootstrap_module(space, name, w_name, w_dict):
-        """NOT_RPYTHON"""
-        with open(os.path.join(lib_python, 'importlib', name + '.py')) as fp:
-            source = fp.read()
-        pathname = "<frozen importlib.%s>" % name
-        code_w = Module._cached_compile(space, name, source,
-                                        pathname, 'exec', 0)
-        space.setitem(w_dict, space.wrap('__name__'), w_name)
-        space.setitem(w_dict, space.wrap('__builtins__'),
-                      space.wrap(space.builtin))
-        code_w.exec_code(space, w_dict, w_dict)
-
-    def install(self):
-        """NOT_RPYTHON"""
-        from pypy.module.imp import interp_imp
-
-        super(Module, self).install()
-        space = self.space
-        # "import importlib/_boostrap_external.py"
-        w_mod = Module(space, space.wrap("_frozen_importlib_external"))
-        # hack: inject MAGIC_NUMBER into this module's dict
-        space.setattr(w_mod, space.wrap('MAGIC_NUMBER'),
-                      interp_imp.get_magic(space))
-        self._compile_bootstrap_module(
-            space, '_bootstrap_external', w_mod.w_name, w_mod.w_dict)
-        space.sys.setmodule(w_mod)
-        # "from importlib/_boostrap.py import *"
-        # It's not a plain "import importlib._boostrap", because we
-        # don't want to freeze importlib.__init__.
-        self._compile_bootstrap_module(
-            space, '_bootstrap', self.w_name, self.w_dict)
-
-        self.w_import = space.wrap(interp_import.import_with_frames_removed)
-
-    @staticmethod
-    def _cached_compile(space, name, source, *args):
-        from rpython.config.translationoption import CACHE_DIR
-        from pypy.module.marshal import interp_marshal
-        from pypy.interpreter.pycode import default_magic
-
-        cachename = os.path.join(CACHE_DIR, 'frozen_importlib_%d%s' % (
-            default_magic, name))
-        try:
-            if space.config.translating:
-                raise IOError("don't use the cache when translating pypy")
-            with open(cachename, 'rb') as f:
-                previous = f.read(len(source) + 1)
-                if previous != source + '\x00':
-                    raise IOError("source changed")
-                w_bin = space.newbytes(f.read())
-                code_w = interp_marshal.loads(space, w_bin)
-        except IOError:
-            # must (re)compile the source
-            ec = space.getexecutioncontext()
-            code_w = ec.compiler.compile(source, *args)
-            w_bin = interp_marshal.dumps(space, code_w, space.wrap(2))
-            content = source + '\x00' + space.bytes_w(w_bin)
-            with open(cachename, 'wb') as f:
-                f.write(content)
-        return code_w
-
-    def startup(self, space):
-        """Copy our __import__ to builtins."""
-        w_install = self.getdictvalue(space, '_install')
-        space.call_function(w_install,
-                            space.getbuiltinmodule('sys'),
-                            space.getbuiltinmodule('_imp'))
-        self.space.builtin.setdictvalue(space, '__import__', self.w_import)
diff --git a/pypy/module/_frozen_importlib/__init__.py 
b/pypy/module/_frozen_importlib/moduledef.py
copy from pypy/module/_frozen_importlib/__init__.py
copy to pypy/module/_frozen_importlib/moduledef.py
diff --git a/pypy/module/_io/__init__.py b/pypy/module/_io/__init__.py
--- a/pypy/module/_io/__init__.py
+++ b/pypy/module/_io/__init__.py
@@ -1,34 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-
-    appleveldefs = {
-    }
-
-    interpleveldefs = {
-        'DEFAULT_BUFFER_SIZE': 'space.wrap(interp_iobase.DEFAULT_BUFFER_SIZE)',
-        'BlockingIOError': 'space.w_BlockingIOError',
-        'UnsupportedOperation':
-            'space.fromcache(interp_io.Cache).w_unsupportedoperation',
-        '_IOBase': 'interp_iobase.W_IOBase',
-        '_RawIOBase': 'interp_iobase.W_RawIOBase',
-        '_BufferedIOBase': 'interp_bufferedio.W_BufferedIOBase',
-        '_TextIOBase': 'interp_textio.W_TextIOBase',
-
-        'FileIO': 'interp_fileio.W_FileIO',
-        'BytesIO': 'interp_bytesio.W_BytesIO',
-        'StringIO': 'interp_stringio.W_StringIO',
-        'BufferedReader': 'interp_bufferedio.W_BufferedReader',
-        'BufferedWriter': 'interp_bufferedio.W_BufferedWriter',
-        'BufferedRWPair': 'interp_bufferedio.W_BufferedRWPair',
-        'BufferedRandom': 'interp_bufferedio.W_BufferedRandom',
-        'TextIOWrapper': 'interp_textio.W_TextIOWrapper',
-
-        'open': 'interp_io.open',
-        'IncrementalNewlineDecoder': 
'interp_textio.W_IncrementalNewlineDecoder',
-    }
-
-    def shutdown(self, space):
-        # at shutdown, flush all open streams.  Ignore I/O errors.
-        from pypy.module._io.interp_iobase import get_autoflusher
-        get_autoflusher(space).flush_all(space)
diff --git a/pypy/module/_io/__init__.py b/pypy/module/_io/moduledef.py
copy from pypy/module/_io/__init__.py
copy to pypy/module/_io/moduledef.py
diff --git a/pypy/module/_jitlog/__init__.py b/pypy/module/_jitlog/__init__.py
--- a/pypy/module/_jitlog/__init__.py
+++ b/pypy/module/_jitlog/__init__.py
@@ -1,13 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-from rpython.rlib.rvmprof import VMProfPlatformUnsupported
-
-class Module(MixedModule):
-    """ JitLog the new logging facility """
-    appleveldefs = {
-    }
-
-    interpleveldefs = {
-        'enable': 'interp_jitlog.enable',
-        'disable': 'interp_jitlog.disable',
-        'JitlogError': 'space.fromcache(interp_jitlog.Cache).w_JitlogError',
-    }
diff --git a/pypy/module/_jitlog/__init__.py b/pypy/module/_jitlog/moduledef.py
copy from pypy/module/_jitlog/__init__.py
copy to pypy/module/_jitlog/moduledef.py
diff --git a/pypy/module/_locale/__init__.py b/pypy/module/_locale/__init__.py
--- a/pypy/module/_locale/__init__.py
+++ b/pypy/module/_locale/__init__.py
@@ -1,45 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-from rpython.rlib import rlocale
-import sys
-
-class Module(MixedModule):
-    """Support for POSIX locales."""
-
-    interpleveldefs  = {
-        'setlocale':  'interp_locale.setlocale',
-        'localeconv': 'interp_locale.localeconv',
-        'strcoll':    'interp_locale.strcoll',
-        'strxfrm':    'interp_locale.strxfrm',
-        'Error':      'interp_locale.W_Error',
-    }
-
-    if sys.platform == 'win32':
-        interpleveldefs.update({
-            '_getdefaultlocale':        'interp_locale.getdefaultlocale',
-            })
-
-    if rlocale.HAVE_LANGINFO:
-        interpleveldefs.update({
-            'nl_langinfo':              'interp_locale.nl_langinfo',
-            })
-    if rlocale.HAVE_LIBINTL:
-        interpleveldefs.update({
-            'gettext':                  'interp_locale.gettext',
-            'dgettext':                 'interp_locale.dgettext',
-            'dcgettext':                'interp_locale.dcgettext',
-            'textdomain':               'interp_locale.textdomain',
-            'bindtextdomain':           'interp_locale.bindtextdomain',
-            })
-        if rlocale.HAVE_BIND_TEXTDOMAIN_CODESET:
-            interpleveldefs.update({
-            'bind_textdomain_codeset':'interp_locale.bind_textdomain_codeset',
-            })
-
-    appleveldefs  = {
-            }
-
-    def buildloaders(cls):
-        for constant, value in rlocale.constants.iteritems():
-            Module.interpleveldefs[constant] = "space.wrap(%r)" % value
-        super(Module, cls).buildloaders()
-    buildloaders = classmethod(buildloaders)
diff --git a/pypy/module/_locale/__init__.py b/pypy/module/_locale/moduledef.py
copy from pypy/module/_locale/__init__.py
copy to pypy/module/_locale/moduledef.py
diff --git a/pypy/module/_lsprof/__init__.py b/pypy/module/_lsprof/__init__.py
--- a/pypy/module/_lsprof/__init__.py
+++ b/pypy/module/_lsprof/__init__.py
@@ -1,10 +0,0 @@
-
-""" _lsprof module
-"""
-
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-    interpleveldefs = {'Profiler':'interp_lsprof.W_Profiler'}
-
-    appleveldefs = {}
diff --git a/pypy/module/_lsprof/__init__.py b/pypy/module/_lsprof/moduledef.py
copy from pypy/module/_lsprof/__init__.py
copy to pypy/module/_lsprof/moduledef.py
diff --git a/pypy/module/_md5/__init__.py b/pypy/module/_md5/__init__.py
--- a/pypy/module/_md5/__init__.py
+++ b/pypy/module/_md5/__init__.py
@@ -1,26 +0,0 @@
-
-"""
-Mixed-module definition for the md5 module.
-Note that there is also a pure Python implementation in pypy/lib/md5.py;
-the present mixed-module version of md5 takes precedence if it is enabled.
-"""
-
-from pypy.interpreter.mixedmodule import MixedModule
-
-
-class Module(MixedModule):
-    """\
-This module implements the interface to RSA's MD5 message digest
-algorithm (see also Internet RFC 1321). Its use is quite
-straightforward: use new() to create an md5 object. You can now feed
-this object with arbitrary strings using the update() method, and at any
-point you can ask it for the digest (a strong kind of 128-bit checksum,
-a.k.a. ``fingerprint'') of the concatenation of the strings fed to it so
-far using the digest() method."""
-
-    interpleveldefs = {
-        'md5': 'interp_md5.W_MD5',
-        }
-
-    appleveldefs = {
-        }
diff --git a/pypy/module/_md5/__init__.py b/pypy/module/_md5/moduledef.py
copy from pypy/module/_md5/__init__.py
copy to pypy/module/_md5/moduledef.py
diff --git a/pypy/module/_minimal_curses/__init__.py 
b/pypy/module/_minimal_curses/__init__.py
--- a/pypy/module/_minimal_curses/__init__.py
+++ b/pypy/module/_minimal_curses/__init__.py
@@ -1,34 +0,0 @@
-try:
-    import _curses
-except Exception:   # probably ImportError or cffi's VerificationError
-    try:
-        # when running on top of pypy before it had _curses, settle for minimal
-        # we prefer _curses so any constants added make it into _minimal_curses
-        import _minimal_curses as _curses
-    except ImportError:
-        import py
-        py.test.skip("no _curses or _minimal_curses module")  # no _curses at 
all
-
-from pypy.interpreter.mixedmodule import MixedModule
-
-
-class Module(MixedModule):
-    """ Low-level interface for curses module,
-    not meant to be used directly
-    """
-
-    appleveldefs = {
-        'error'          : 'app_curses.error',
-    }
-
-    interpleveldefs = {
-        'setupterm'      : 'interp_curses.setupterm',
-        'tigetstr'       : 'interp_curses.tigetstr',
-        'tparm'          : 'interp_curses.tparm',
-    }
-
-for i in dir(_curses):
-    i = str(i)     # workaround for pypy 2.0-beta2
-    val = getattr(_curses, i)
-    if i.isupper() and type(val) is int:
-        Module.interpleveldefs[i] = "space.wrap(%s)" % val
diff --git a/pypy/module/_minimal_curses/__init__.py 
b/pypy/module/_minimal_curses/moduledef.py
copy from pypy/module/_minimal_curses/__init__.py
copy to pypy/module/_minimal_curses/moduledef.py
diff --git a/pypy/module/_multibytecodec/__init__.py 
b/pypy/module/_multibytecodec/__init__.py
--- a/pypy/module/_multibytecodec/__init__.py
+++ b/pypy/module/_multibytecodec/__init__.py
@@ -1,22 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule 
-
-
-class Module(MixedModule):
-
-    interpleveldefs = {
-        # for compatibility this name is obscured, and should be called
-        # via the _codecs_*.py modules written in lib_pypy.
-        '__getcodec': 'interp_multibytecodec.getcodec',
-
-        'MultibyteIncrementalDecoder':
-            'interp_incremental.MultibyteIncrementalDecoder',
-        'MultibyteIncrementalEncoder':
-            'interp_incremental.MultibyteIncrementalEncoder',
-    }
-
-    appleveldefs = {
-        'MultibyteStreamReader':
-            'app_multibytecodec.MultibyteStreamReader',
-        'MultibyteStreamWriter':
-            'app_multibytecodec.MultibyteStreamWriter',
-    }
diff --git a/pypy/module/_multibytecodec/__init__.py 
b/pypy/module/_multibytecodec/moduledef.py
copy from pypy/module/_multibytecodec/__init__.py
copy to pypy/module/_multibytecodec/moduledef.py
diff --git a/pypy/module/_multiprocessing/__init__.py 
b/pypy/module/_multiprocessing/__init__.py
--- a/pypy/module/_multiprocessing/__init__.py
+++ b/pypy/module/_multiprocessing/__init__.py
@@ -1,19 +0,0 @@
-import sys
-
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-
-    interpleveldefs = {
-        'SemLock'         : 'interp_semaphore.W_SemLock',
-    }
-
-    appleveldefs = {
-    }
-
-    if sys.platform == 'win32':
-        interpleveldefs['closesocket'] = 
'interp_win32_py3.multiprocessing_closesocket'
-        interpleveldefs['recv'] = 'interp_win32_py3.multiprocessing_recv'
-        interpleveldefs['send'] = 'interp_win32_py3.multiprocessing_send'
-    else:
-        interpleveldefs['sem_unlink'] = 'interp_semaphore.semaphore_unlink'
diff --git a/pypy/module/_multiprocessing/__init__.py 
b/pypy/module/_multiprocessing/moduledef.py
copy from pypy/module/_multiprocessing/__init__.py
copy to pypy/module/_multiprocessing/moduledef.py
diff --git a/pypy/module/_pickle_support/__init__.py 
b/pypy/module/_pickle_support/__init__.py
--- a/pypy/module/_pickle_support/__init__.py
+++ b/pypy/module/_pickle_support/__init__.py
@@ -1,25 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule 
-
-class Module(MixedModule):
-    """Built-in functions, exceptions, and other objects."""
-
-    appleveldefs = {
-    }
-
-    interpleveldefs = {
-        'cell_new'     : 'maker.cell_new',
-        'code_new'     : 'maker.code_new',
-        'func_new'     : 'maker.func_new',
-        'module_new'   : 'maker.module_new',
-        'method_new'   : 'maker.method_new',
-        'builtin_method_new'   : 'maker.builtin_method_new',
-        'dictiter_surrogate_new' : 'maker.dictiter_surrogate_new',
-        'frame_new'    : 'maker.frame_new',
-        'traceback_new' : 'maker.traceback_new',
-        'generator_new' : 'maker.generator_new',
-        'coroutine_new' : 'maker.coroutine_new',
-        'longrangeiter_new': 'maker.longrangeiter_new',
-        'intrangeiter_new': 'maker.intrangeiter_new',
-        'builtin_code': 'maker.builtin_code',
-        'builtin_function' : 'maker.builtin_function',
-    }
diff --git a/pypy/module/_pickle_support/__init__.py 
b/pypy/module/_pickle_support/moduledef.py
copy from pypy/module/_pickle_support/__init__.py
copy to pypy/module/_pickle_support/moduledef.py
diff --git a/pypy/module/_posixsubprocess/__init__.py 
b/pypy/module/_posixsubprocess/__init__.py
--- a/pypy/module/_posixsubprocess/__init__.py
+++ b/pypy/module/_posixsubprocess/__init__.py
@@ -1,16 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-    applevel_name = '_posixsubprocess'
-
-    appleveldefs = {
-        }
-    
-    interpleveldefs = {
-        'fork_exec': 'interp_subprocess.fork_exec',
-        'cloexec_pipe': 'interp_subprocess.cloexec_pipe',
-        }
-
-    def startup(self, space):
-        from interp_subprocess import c_init
-        c_init()
diff --git a/pypy/module/_posixsubprocess/__init__.py 
b/pypy/module/_posixsubprocess/moduledef.py
copy from pypy/module/_posixsubprocess/__init__.py
copy to pypy/module/_posixsubprocess/moduledef.py
diff --git a/pypy/module/_pypyjson/__init__.py 
b/pypy/module/_pypyjson/__init__.py
--- a/pypy/module/_pypyjson/__init__.py
+++ b/pypy/module/_pypyjson/__init__.py
@@ -1,12 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-    """fast json implementation"""
-
-    appleveldefs = {}
-
-    interpleveldefs = {
-        'loads' : 'interp_decoder.loads',
-        'raw_encode_basestring_ascii':
-            'interp_encoder.raw_encode_basestring_ascii',
-        }
diff --git a/pypy/module/_pypyjson/__init__.py 
b/pypy/module/_pypyjson/moduledef.py
copy from pypy/module/_pypyjson/__init__.py
copy to pypy/module/_pypyjson/moduledef.py
diff --git a/pypy/module/_random/__init__.py b/pypy/module/_random/__init__.py
--- a/pypy/module/_random/__init__.py
+++ b/pypy/module/_random/__init__.py
@@ -1,8 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-    appleveldefs = {}
-
-    interpleveldefs = {
-        'Random'          : 'interp_random.W_Random',
-    }
diff --git a/pypy/module/_random/__init__.py b/pypy/module/_random/moduledef.py
copy from pypy/module/_random/__init__.py
copy to pypy/module/_random/moduledef.py
diff --git a/pypy/module/_rawffi/__init__.py b/pypy/module/_rawffi/__init__.py
--- a/pypy/module/_rawffi/__init__.py
+++ b/pypy/module/_rawffi/__init__.py
@@ -1,58 +0,0 @@
-""" Low-level interface to clibffi
-"""
-
-from pypy.interpreter.mixedmodule import MixedModule
-from pypy.module._rawffi import alt
-
-class Module(MixedModule):
-    interpleveldefs = {
-        'CDLL'               : 'interp_rawffi.W_CDLL',
-        'FuncPtr'            : 'interp_rawffi.W_FuncPtr',
-        'Structure'          : 'structure.W_Structure',
-        'StructureInstance'  : 'structure.W_StructureInstance',
-        'StructureInstanceAutoFree' : 'structure.W_StructureInstanceAutoFree',
-        'Array'              : 'array.W_Array',
-        'ArrayInstance'      : 'array.W_ArrayInstance',
-        'ArrayInstanceAutoFree' : 'array.W_ArrayInstanceAutoFree',
-        'sizeof'             : 'interp_rawffi.sizeof',
-        'alignment'          : 'interp_rawffi.alignment',
-        'charp2string'       : 'interp_rawffi.charp2string',
-        'wcharp2unicode'     : 'interp_rawffi.wcharp2unicode',
-        'charp2rawstring'    : 'interp_rawffi.charp2rawstring',
-        'wcharp2rawunicode'  : 'interp_rawffi.wcharp2rawunicode',
-        'rawstring2charp'    : 'interp_rawffi.rawstring2charp',
-        'CallbackPtr'        : 'callback.W_CallbackPtr',
-        '_num_of_allocated_objects' : 'tracker.num_of_allocated_objects',
-        'get_libc'           : 'interp_rawffi.get_libc',
-        'get_errno'          : 'interp_rawffi.get_errno',
-        'set_errno'          : 'interp_rawffi.set_errno',
-        'get_last_error'     : 'interp_rawffi.get_last_error',
-        'set_last_error'     : 'interp_rawffi.set_last_error',
-        'SegfaultException'  : 
'space.new_exception_class("_rawffi.SegfaultException")',
-        'exit'               : 'interp_exit.exit',
-    }
-
-    appleveldefs = {
-    }
-
-    submodules = {
-        'alt': alt.Module,
-    }
-
-    def buildloaders(cls):
-        from pypy.module._rawffi import interp_rawffi
-
-        if hasattr(interp_rawffi, 'FormatError'):
-            Module.interpleveldefs['FormatError'] = 'interp_rawffi.FormatError'
-        if hasattr(interp_rawffi, 'check_HRESULT'):
-            Module.interpleveldefs['check_HRESULT'] = 
'interp_rawffi.check_HRESULT'
-
-        from rpython.rlib import clibffi
-        for name in ['FUNCFLAG_STDCALL', 'FUNCFLAG_CDECL', 
'FUNCFLAG_PYTHONAPI',
-                     'FUNCFLAG_USE_ERRNO', 'FUNCFLAG_USE_LASTERROR',
-                     ]:
-            if hasattr(clibffi, name):
-                Module.interpleveldefs[name] = "space.wrap(%r)" % 
getattr(clibffi, name)
-
-        super(Module, cls).buildloaders()
-    buildloaders = classmethod(buildloaders)
diff --git a/pypy/module/_rawffi/__init__.py b/pypy/module/_rawffi/moduledef.py
copy from pypy/module/_rawffi/__init__.py
copy to pypy/module/_rawffi/moduledef.py
diff --git a/pypy/module/_socket/__init__.py b/pypy/module/_socket/__init__.py
--- a/pypy/module/_socket/__init__.py
+++ b/pypy/module/_socket/__init__.py
@@ -1,52 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-from rpython.rlib.rsocket import SOMAXCONN
-
-
-class Module(MixedModule):
-
-    appleveldefs = {
-    }
-
-    interpleveldefs = {
-        'SocketType':  'interp_socket.W_Socket',
-        'socket'    :  'interp_socket.W_Socket',
-        'error'     :  'interp_socket.get_error(space, "error")',
-        'herror'    :  'interp_socket.get_error(space, "herror")',
-        'gaierror'  :  'interp_socket.get_error(space, "gaierror")',
-        'timeout'   :  'interp_socket.get_error(space, "timeout")',
-        'SOMAXCONN' :  'space.wrap(%d)' % SOMAXCONN,
-    }
-
-    def startup(self, space):
-        from rpython.rlib.rsocket import rsocket_startup
-        rsocket_startup()
-
-    def shutdown(self, space):
-        from pypy.module._socket.interp_socket import close_all_sockets
-        close_all_sockets(space)
-
-    def buildloaders(cls):
-        from rpython.rlib import rsocket
-        for name in """
-            gethostbyname gethostbyname_ex gethostbyaddr gethostname
-            getservbyname getservbyport getprotobyname
-            dup socketpair
-            ntohs ntohl htons htonl inet_aton inet_ntoa inet_pton inet_ntop
-            getaddrinfo getnameinfo
-            getdefaulttimeout setdefaulttimeout
-            CMSG_SPACE CMSG_LEN
-            """.split():
-
-            if (name in ('inet_pton', 'inet_ntop', 'socketpair',
-                         'CMSG_SPACE', 'CMSG_LEN') and
-                not hasattr(rsocket, name)):
-                continue
-
-            Module.interpleveldefs[name] = 'interp_func.%s' % (name, )
-
-        for constant, value in rsocket.constants.iteritems():
-            Module.interpleveldefs[constant] = "space.wrap(%r)" % value
-        super(Module, cls).buildloaders()
-    buildloaders = classmethod(buildloaders)
-
-#Module.interpleveldefs['has_ipv6'] = "space.wrap(%s)" % _socket.has_ipv6
diff --git a/pypy/module/_socket/__init__.py b/pypy/module/_socket/moduledef.py
copy from pypy/module/_socket/__init__.py
copy to pypy/module/_socket/moduledef.py
diff --git a/pypy/module/_sre/__init__.py b/pypy/module/_sre/__init__.py
--- a/pypy/module/_sre/__init__.py
+++ b/pypy/module/_sre/__init__.py
@@ -1,16 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-
-    appleveldefs = {
-    }
-
-    interpleveldefs = {
-        'CODESIZE':       'space.newint(interp_sre.CODESIZE)',
-        'MAGIC':          'space.newint(20140917)',
-        'MAXREPEAT':      'space.newint(interp_sre.MAXREPEAT)',
-        'MAXGROUPS':      'space.newint(interp_sre.MAXGROUPS)',
-        'compile':        'interp_sre.W_SRE_Pattern',
-        'getlower':       'interp_sre.w_getlower',
-        'getcodesize':    'interp_sre.w_getcodesize',
-    }
diff --git a/pypy/module/_sre/__init__.py b/pypy/module/_sre/moduledef.py
copy from pypy/module/_sre/__init__.py
copy to pypy/module/_sre/moduledef.py
diff --git a/pypy/module/_string/__init__.py b/pypy/module/_string/__init__.py
--- a/pypy/module/_string/__init__.py
+++ b/pypy/module/_string/__init__.py
@@ -1,17 +0,0 @@
-"""A _string module, to export formatter_parser and
-   formatter_field_name_split to the string.Formatter class
-   implemented in Python."""
-
-
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-    "string helper module"
-
-    interpleveldefs = {
-        'formatter_field_name_split': 'formatter.formatter_field_name_split',
-        'formatter_parser': 'formatter.formatter_parser',
-    }
-
-    appleveldefs = {}
-
diff --git a/pypy/module/_string/__init__.py b/pypy/module/_string/moduledef.py
copy from pypy/module/_string/__init__.py
copy to pypy/module/_string/moduledef.py
diff --git a/pypy/module/_testing/__init__.py b/pypy/module/_testing/__init__.py
--- a/pypy/module/_testing/__init__.py
+++ b/pypy/module/_testing/__init__.py
@@ -1,17 +0,0 @@
-
-"""
-Mixed-module definition for pypy own testing purposes
-"""
-
-from pypy.interpreter.mixedmodule import MixedModule
-
-
-class Module(MixedModule):
-    """PyPy own testing"""
-
-    interpleveldefs = {
-        }
-
-    appleveldefs = {
-        'Hidden': 'app_notrpython.Hidden',
-        }
diff --git a/pypy/module/_testing/__init__.py 
b/pypy/module/_testing/moduledef.py
copy from pypy/module/_testing/__init__.py
copy to pypy/module/_testing/moduledef.py
diff --git a/pypy/module/_vmprof/__init__.py b/pypy/module/_vmprof/__init__.py
--- a/pypy/module/_vmprof/__init__.py
+++ b/pypy/module/_vmprof/__init__.py
@@ -1,39 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-from rpython.rlib.rvmprof import VMProfPlatformUnsupported
-from rpython.translator.platform import CompilationError
-
-
-class Module(MixedModule):
-    """
-    VMProf for PyPy: a statistical profiler
-    """
-    appleveldefs = {
-    }
-
-    interpleveldefs = {
-        'enable': 'interp_vmprof.enable',
-        'disable': 'interp_vmprof.disable',
-        'is_enabled': 'interp_vmprof.is_enabled',
-        'get_profile_path': 'interp_vmprof.get_profile_path',
-        'stop_sampling': 'interp_vmprof.stop_sampling',
-        'start_sampling': 'interp_vmprof.start_sampling',
-
-        'VMProfError': 'space.fromcache(interp_vmprof.Cache).w_VMProfError',
-    }
-
-
-# Force the __extend__ hacks and method replacements to occur
-# early.  Without this, for example, 'PyCode._init_ready' was
-# already found by the annotator to be the original empty
-# method, and the annotator doesn't notice that interp_vmprof.py
-# (loaded later) replaces this method.
-try:
-    import pypy.module._vmprof.interp_vmprof
-except VMProfPlatformUnsupported as e:
-    pass
-except CompilationError as e:
-    import sys
-    if sys.platform == 'win32':
-        pass
-    else:
-        raise
diff --git a/pypy/module/_vmprof/__init__.py b/pypy/module/_vmprof/moduledef.py
copy from pypy/module/_vmprof/__init__.py
copy to pypy/module/_vmprof/moduledef.py
diff --git a/pypy/module/_warnings/__init__.py 
b/pypy/module/_warnings/__init__.py
--- a/pypy/module/_warnings/__init__.py
+++ b/pypy/module/_warnings/__init__.py
@@ -1,22 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-    """provides basic warning filtering support.
-    It is a helper module to speed up interpreter start-up."""
-
-    interpleveldefs = {
-        'warn'         : 'interp_warnings.warn',
-        'warn_explicit': 'interp_warnings.warn_explicit',
-        '_filters_mutated': 'interp_warnings.filters_mutated',
-    }
-
-    appleveldefs = {
-    }
-
-    def setup_after_space_initialization(self):
-        from pypy.module._warnings.interp_warnings import State
-        state = self.space.fromcache(State)
-        self.setdictvalue(self.space, "filters", state.w_filters)
-        self.setdictvalue(self.space, "_onceregistry", state.w_once_registry)
-        self.setdictvalue(self.space, "_defaultaction", state.w_default_action)
-
diff --git a/pypy/module/_warnings/__init__.py 
b/pypy/module/_warnings/moduledef.py
copy from pypy/module/_warnings/__init__.py
copy to pypy/module/_warnings/moduledef.py
diff --git a/pypy/module/_weakref/__init__.py b/pypy/module/_weakref/__init__.py
--- a/pypy/module/_weakref/__init__.py
+++ b/pypy/module/_weakref/__init__.py
@@ -1,14 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-    
-class Module(MixedModule):
-    appleveldefs = {
-    }
-    interpleveldefs = {
-        'ref': 'interp__weakref.W_Weakref',
-        'getweakrefcount': 'interp__weakref.getweakrefcount',
-        'getweakrefs': 'interp__weakref.getweakrefs',
-        'ReferenceType': 'interp__weakref.W_Weakref',
-        'ProxyType': 'interp__weakref.W_Proxy', 
-        'CallableProxyType': 'interp__weakref.W_CallableProxy',
-        'proxy': 'interp__weakref.proxy'
-    }
diff --git a/pypy/module/_weakref/__init__.py 
b/pypy/module/_weakref/moduledef.py
copy from pypy/module/_weakref/__init__.py
copy to pypy/module/_weakref/moduledef.py
diff --git a/pypy/module/_winreg/__init__.py b/pypy/module/_winreg/__init__.py
--- a/pypy/module/_winreg/__init__.py
+++ b/pypy/module/_winreg/__init__.py
@@ -1,76 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-from rpython.rlib.rwinreg import constants
-
-class Module(MixedModule):
-    """This module provides access to the Windows registry API.
-
-Functions:
-
-CloseKey() - Closes a registry key.
-ConnectRegistry() - Establishes a connection to a predefined registry handle
-                    on another computer.
-CreateKey() - Creates the specified key, or opens it if it already exists.
-DeleteKey() - Deletes the specified key.
-DeleteValue() - Removes a named value from the specified registry key.
-EnumKey() - Enumerates subkeys of the specified open registry key.
-EnumValue() - Enumerates values of the specified open registry key.
-ExpandEnvironmentStrings() - Expand the env strings in a REG_EXPAND_SZ string.
-FlushKey() - Writes all the attributes of the specified key to the registry.
-LoadKey() - Creates a subkey under HKEY_USER or HKEY_LOCAL_MACHINE and stores
-            registration information from a specified file into that subkey.
-OpenKey() - Alias for <om win32api.RegOpenKeyEx>
-OpenKeyEx() - Opens the specified key.
-QueryValue() - Retrieves the value associated with the unnamed value for a
-               specified key in the registry.
-QueryValueEx() - Retrieves the type and data for a specified value name
-                 associated with an open registry key.
-QueryInfoKey() - Returns information about the specified key.
-SaveKey() - Saves the specified key, and all its subkeys a file.
-SetValue() - Associates a value with a specified key.
-SetValueEx() - Stores data in the value field of an open registry key.
-
-Special objects:
-
-HKEYType -- type object for HKEY objects
-error -- exception raised for Win32 errors
-
-Integer constants:
-Many constants are defined - see the documentation for each function
-to see what constants are used, and where."""
-
-    applevel_name = 'winreg'
-
-    appleveldefs = {
-    }
-    interpleveldefs = {
-        'error'          : 'space.w_WindowsError',
-        'HKEYType'       : 'interp_winreg.W_HKEY',
-        'SetValue'       : 'interp_winreg.SetValue',
-        'SetValueEx'     : 'interp_winreg.SetValueEx',
-        'QueryValue'     : 'interp_winreg.QueryValue',
-        'QueryValueEx'   : 'interp_winreg.QueryValueEx',
-        'CreateKey'      : 'interp_winreg.CreateKey',
-        'CreateKeyEx'    : 'interp_winreg.CreateKeyEx',
-        'DeleteKey'      : 'interp_winreg.DeleteKey',
-        'DeleteValue'    : 'interp_winreg.DeleteValue',
-        'OpenKey'        : 'interp_winreg.OpenKey',
-        'OpenKeyEx'      : 'interp_winreg.OpenKey',
-        'EnumValue'      : 'interp_winreg.EnumValue',
-        'EnumKey'        : 'interp_winreg.EnumKey',
-        'FlushKey'       : 'interp_winreg.FlushKey',
-        'CloseKey'       : 'interp_winreg.CloseKey',
-        'QueryInfoKey'   : 'interp_winreg.QueryInfoKey',
-        'LoadKey'        : 'interp_winreg.LoadKey',
-        'SaveKey'        : 'interp_winreg.SaveKey',
-        'ConnectRegistry': 'interp_winreg.ConnectRegistry',
-
-        'ExpandEnvironmentStrings': 'interp_winreg.ExpandEnvironmentStrings',
-
-        'DisableReflectionKey': 'interp_winreg.DisableReflectionKey',
-        'EnableReflectionKey': 'interp_winreg.EnableReflectionKey',
-        'QueryReflectionKey': 'interp_winreg.QueryReflectionKey',
-        'DeleteKeyEx': 'interp_winreg.DeleteKeyEx',
-    }
-
-    for name, value in constants.iteritems():
-        interpleveldefs[name] = "space.wrap(%s)" % (value,)
diff --git a/pypy/module/_winreg/__init__.py b/pypy/module/_winreg/moduledef.py
copy from pypy/module/_winreg/__init__.py
copy to pypy/module/_winreg/moduledef.py
diff --git a/pypy/module/array/__init__.py b/pypy/module/array/__init__.py
--- a/pypy/module/array/__init__.py
+++ b/pypy/module/array/__init__.py
@@ -1,11 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-    interpleveldefs = {
-        'array': 'interp_array.W_ArrayBase',
-        'ArrayType': 'interp_array.W_ArrayBase',
-        '_array_reconstructor': 'reconstructor.array_reconstructor',
-    }
-
-    appleveldefs = {
-    }
diff --git a/pypy/module/array/__init__.py b/pypy/module/array/moduledef.py
copy from pypy/module/array/__init__.py
copy to pypy/module/array/moduledef.py
diff --git a/pypy/module/atexit/__init__.py b/pypy/module/atexit/__init__.py
--- a/pypy/module/atexit/__init__.py
+++ b/pypy/module/atexit/__init__.py
@@ -1,20 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-    """Allow programmer to define multiple exit functions to be
-    executed upon normal program termination.
-
-    Two public functions, register and unregister, are defined.
-    """
-
-    interpleveldefs = {
-        }
-
-    appleveldefs = {
-        'register': 'app_atexit.register',
-        'unregister': 'app_atexit.unregister',
-        '_clear': 'app_atexit.clear',
-        '_run_exitfuncs': 'app_atexit.run_exitfuncs',
-        '_ncallbacks': 'app_atexit.ncallbacks',
-        }
-
diff --git a/pypy/module/atexit/__init__.py b/pypy/module/atexit/moduledef.py
copy from pypy/module/atexit/__init__.py
copy to pypy/module/atexit/moduledef.py
diff --git a/pypy/module/binascii/__init__.py b/pypy/module/binascii/__init__.py
--- a/pypy/module/binascii/__init__.py
+++ b/pypy/module/binascii/__init__.py
@@ -1,36 +0,0 @@
-
-"""
-Mixed-module definition for the binascii module.
-Note that there is also a pure Python implementation in lib_pypy/binascii.py;
-the pypy/module/binascii/ version takes precedence if it is enabled.
-"""
-
-from pypy.interpreter.mixedmodule import MixedModule
-
-
-class Module(MixedModule):
-    """binascii - Conversion between binary data and ASCII"""
-
-    appleveldefs = {
-        }
-
-    interpleveldefs = {
-        'a2b_uu': 'interp_uu.a2b_uu',
-        'b2a_uu': 'interp_uu.b2a_uu',
-        'a2b_base64': 'interp_base64.a2b_base64',
-        'b2a_base64': 'interp_base64.b2a_base64',
-        'a2b_qp': 'interp_qp.a2b_qp',
-        'b2a_qp': 'interp_qp.b2a_qp',
-        'a2b_hqx': 'interp_hqx.a2b_hqx',
-        'b2a_hqx': 'interp_hqx.b2a_hqx',
-        'rledecode_hqx': 'interp_hqx.rledecode_hqx',
-        'rlecode_hqx': 'interp_hqx.rlecode_hqx',
-        'crc_hqx': 'interp_hqx.crc_hqx',
-        'crc32': 'interp_crc32.crc32',
-        'b2a_hex': 'interp_hexlify.hexlify',
-        'hexlify': 'interp_hexlify.hexlify',
-        'a2b_hex': 'interp_hexlify.unhexlify',
-        'unhexlify': 'interp_hexlify.unhexlify',
-        'Error'     : 'space.fromcache(interp_binascii.Cache).w_error',
-        'Incomplete': 'space.fromcache(interp_binascii.Cache).w_incomplete',
-        }
diff --git a/pypy/module/binascii/__init__.py 
b/pypy/module/binascii/moduledef.py
copy from pypy/module/binascii/__init__.py
copy to pypy/module/binascii/moduledef.py
diff --git a/pypy/module/bz2/__init__.py b/pypy/module/bz2/__init__.py
--- a/pypy/module/bz2/__init__.py
+++ b/pypy/module/bz2/__init__.py
@@ -1,14 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-    # The private part of the bz2 module.
-
-    applevel_name = '_bz2'
-
-    interpleveldefs = {
-        'BZ2Compressor': 'interp_bz2.W_BZ2Compressor',
-        'BZ2Decompressor': 'interp_bz2.W_BZ2Decompressor',
-    }
-
-    appleveldefs = {
-    }
diff --git a/pypy/module/bz2/__init__.py b/pypy/module/bz2/moduledef.py
copy from pypy/module/bz2/__init__.py
copy to pypy/module/bz2/moduledef.py
diff --git a/pypy/module/cmath/__init__.py b/pypy/module/cmath/__init__.py
--- a/pypy/module/cmath/__init__.py
+++ b/pypy/module/cmath/__init__.py
@@ -1,46 +0,0 @@
-
-# Package initialisation
-from pypy.interpreter.mixedmodule import MixedModule
-
-names_and_docstrings = {
-    'sqrt': "Return the square root of x.",
-    'acos': "Return the arc cosine of x.",
-    'acosh': "Return the hyperbolic arc cosine of x.",
-    'asin': "Return the arc sine of x.",
-    'asinh': "Return the hyperbolic arc sine of x.",
-    'atan': "Return the arc tangent of x.",
-    'atanh': "Return the hyperbolic arc tangent of x.",
-    'log': ("log(x[, base]) -> the logarithm of x to the given base.\n"
-            "If the base not specified, returns the natural logarithm "
-            "(base e) of x."),
-    'log10': "Return the base-10 logarithm of x.",
-    'exp': "Return the exponential value e**x.",
-    'cosh': "Return the hyperbolic cosine of x.",
-    'sinh': "Return the hyperbolic sine of x.",
-    'tanh': "Return the hyperbolic tangent of x.",
-    'cos': "Return the cosine of x.",
-    'sin': "Return the sine of x.",
-    'tan': "Return the tangent of x.",
-    'rect': "Convert from polar coordinates to rectangular coordinates.",
-    'polar': ("polar(z) -> r: float, phi: float\n"
-              "Convert a complex from rectangular coordinates "
-              "to polar coordinates. r is\n"
-              "the distance from 0 and phi the phase angle."),
-    'phase': "Return argument, also known as the phase angle, of a complex.",
-    'isinf': "Checks if the real or imaginary part of z is infinite.",
-    'isnan': "Checks if the real or imaginary part of z is not a number (NaN)",
-    'isfinite': "isfinite(z) -> bool\nReturn True if both the real and 
imaginary parts of z are finite, else False.",
-}
-
-
-class Module(MixedModule):
-    appleveldefs = {
-    }
-
-    interpleveldefs = {
-        'pi': 'space.newfloat(interp_cmath.pi)',
-        'e':  'space.newfloat(interp_cmath.e)',
-        'isclose': 'interp_cmath.isclose',
-    }
-    interpleveldefs.update(dict([(name, 'interp_cmath.wrapped_' + name)
-                                 for name in names_and_docstrings]))
diff --git a/pypy/module/cmath/__init__.py b/pypy/module/cmath/moduledef.py
copy from pypy/module/cmath/__init__.py
copy to pypy/module/cmath/moduledef.py
diff --git a/pypy/module/cpyext/__init__.py b/pypy/module/cpyext/__init__.py
--- a/pypy/module/cpyext/__init__.py
+++ b/pypy/module/cpyext/__init__.py
@@ -1,83 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-from pypy.module.cpyext.state import State
-from pypy.module.cpyext import api
-
-class Module(MixedModule):
-    interpleveldefs = {
-        'is_cpyext_function': 'interp_cpyext.is_cpyext_function',
-    }
-
-    appleveldefs = {
-    }
-
-    atexit_funcs = []
-
-    def startup(self, space):
-        space.fromcache(State).startup(space)
-        method = pypy.module.cpyext.typeobject.get_new_method_def(space)
-        # the w_self argument here is a dummy, the only thing done with w_obj
-        # is call type() on it
-        w_obj = pypy.module.cpyext.methodobject.W_PyCFunctionObject(space,
-                                                           method, 
space.w_None)
-        space.appexec([w_obj], """(meth):
-            from pickle import Pickler
-            Pickler.dispatch[type(meth)] = Pickler.save_global
-        """)
-
-    def register_atexit(self, function):
-        if len(self.atexit_funcs) >= 32:
-            raise ValueError("cannot register more than 32 atexit functions")
-        self.atexit_funcs.append(function)
-
-    def shutdown(self, space):
-        for func in self.atexit_funcs:
-            func()
-
-
-# import these modules to register api functions by side-effect
-import pypy.module.cpyext.pyobject
-import pypy.module.cpyext.boolobject
-import pypy.module.cpyext.floatobject
-import pypy.module.cpyext.modsupport
-import pypy.module.cpyext.pythonrun
-import pypy.module.cpyext.pyerrors
-import pypy.module.cpyext.typeobject
-import pypy.module.cpyext.object
-import pypy.module.cpyext.bytesobject
-import pypy.module.cpyext.bytearrayobject
-import pypy.module.cpyext.tupleobject
-import pypy.module.cpyext.setobject
-import pypy.module.cpyext.dictobject
-import pypy.module.cpyext.longobject
-import pypy.module.cpyext.listobject
-import pypy.module.cpyext.sequence
-import pypy.module.cpyext.buffer
-import pypy.module.cpyext.eval
-import pypy.module.cpyext.import_
-import pypy.module.cpyext.mapping
-import pypy.module.cpyext.iterator
-import pypy.module.cpyext.unicodeobject
-import pypy.module.cpyext.sysmodule
-import pypy.module.cpyext.number
-import pypy.module.cpyext.sliceobject
-import pypy.module.cpyext.stubsactive
-import pypy.module.cpyext.pystate
-import pypy.module.cpyext.cdatetime
-import pypy.module.cpyext.complexobject
-import pypy.module.cpyext.weakrefobject
-import pypy.module.cpyext.funcobject
-import pypy.module.cpyext.frameobject
-import pypy.module.cpyext.classobject
-import pypy.module.cpyext.exception
-import pypy.module.cpyext.memoryobject
-import pypy.module.cpyext.codecs
-import pypy.module.cpyext.pyfile
-import pypy.module.cpyext.pystrtod
-import pypy.module.cpyext.pytraceback
-import pypy.module.cpyext.methodobject
-import pypy.module.cpyext.dictproxyobject
-import pypy.module.cpyext.genobject
-import pypy.module.cpyext.namespaceobject
-
-# now that all rffi_platform.Struct types are registered, configure them
-api.configure_types()
diff --git a/pypy/module/cpyext/__init__.py b/pypy/module/cpyext/moduledef.py
copy from pypy/module/cpyext/__init__.py
copy to pypy/module/cpyext/moduledef.py
diff --git a/pypy/module/crypt/__init__.py b/pypy/module/crypt/__init__.py
--- a/pypy/module/crypt/__init__.py
+++ b/pypy/module/crypt/__init__.py
@@ -1,11 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule 
-
-class Module(MixedModule):
-    applevel_name = '_crypt'
-
-    interpleveldefs = {
-        'crypt'    : 'interp_crypt.crypt',
-    }
-
-    appleveldefs = {
-    }
diff --git a/pypy/module/crypt/__init__.py b/pypy/module/crypt/moduledef.py
copy from pypy/module/crypt/__init__.py
copy to pypy/module/crypt/moduledef.py
diff --git a/pypy/module/errno/__init__.py b/pypy/module/errno/__init__.py
--- a/pypy/module/errno/__init__.py
+++ b/pypy/module/errno/__init__.py
@@ -1,23 +0,0 @@
-from pypy.interpreter.mixedmodule import MixedModule
-from pypy.module.errno.interp_errno import name2code
-
-class Module(MixedModule):
-    """This module makes available standard errno system symbols.
-
-    The value of each symbol is the corresponding integer value,
-    e.g., on most systems, errno.ENOENT equals the integer 2.
-
-    The dictionary errno.errorcode maps numeric codes to symbol names,
-    e.g., errno.errorcode[2] could be the string 'ENOENT'.
-
-    Symbols that are not relevant to the underlying system are not defined.
-
-    To map error codes to error messages, use the function os.strerror(),
-    e.g. os.strerror(2) could return 'No such file or directory'."""
-
-    appleveldefs = {}
-    interpleveldefs = {"errorcode": "interp_errno.get_errorcode(space)"}
-
-for name, code in name2code.iteritems():
-    if code is not None:
-        Module.interpleveldefs[name] = ("space.newint(%s)" % code)
diff --git a/pypy/module/errno/__init__.py b/pypy/module/errno/moduledef.py
copy from pypy/module/errno/__init__.py
copy to pypy/module/errno/moduledef.py
diff --git a/pypy/module/exceptions/__init__.py 
b/pypy/module/exceptions/__init__.py
--- a/pypy/module/exceptions/__init__.py
+++ b/pypy/module/exceptions/__init__.py
@@ -1,85 +0,0 @@
-from rpython.rlib import rwin32
-from pypy.interpreter.mixedmodule import MixedModule
-
-class Module(MixedModule):
-    applevel_name = '__exceptions__'
-    appleveldefs = {}
-    
-    interpleveldefs = {
-        'ArithmeticError' : 'interp_exceptions.W_ArithmeticError',
-        'AssertionError' : 'interp_exceptions.W_AssertionError',
-        'AttributeError' : 'interp_exceptions.W_AttributeError',
-        'BaseException' : 'interp_exceptions.W_BaseException',
-        'BlockingIOError': 'interp_exceptions.W_BlockingIOError',
-        'BrokenPipeError': 'interp_exceptions.W_BrokenPipeError',
-        'BufferError' : 'interp_exceptions.W_BufferError',
-        'BytesWarning'  : 'interp_exceptions.W_BytesWarning',
-        'ChildProcessError': 'interp_exceptions.W_ChildProcessError',
-        'ConnectionAbortedError': 'interp_exceptions.W_ConnectionAbortedError',
-        'ConnectionError': 'interp_exceptions.W_ConnectionError',
-        'ConnectionRefusedError': 'interp_exceptions.W_ConnectionRefusedError',
-        'ConnectionResetError': 'interp_exceptions.W_ConnectionResetError',
-        'DeprecationWarning' : 'interp_exceptions.W_DeprecationWarning',
-        'EOFError' : 'interp_exceptions.W_EOFError',
-        'EnvironmentError' : 'interp_exceptions.W_OSError',
-        'Exception' : 'interp_exceptions.W_Exception',
-        'FileExistsError': 'interp_exceptions.W_FileExistsError',
-        'FileNotFoundError': 'interp_exceptions.W_FileNotFoundError',
-        'FloatingPointError' : 'interp_exceptions.W_FloatingPointError',
-        'FutureWarning' : 'interp_exceptions.W_FutureWarning',
-        'GeneratorExit' : 'interp_exceptions.W_GeneratorExit',
-        'IOError' : 'interp_exceptions.W_OSError',
-        'ImportError' : 'interp_exceptions.W_ImportError',
-        'ImportWarning' : 'interp_exceptions.W_ImportWarning',
-        'IndentationError' : 'interp_exceptions.W_IndentationError',
-        'IndexError' : 'interp_exceptions.W_IndexError',
-        'InterruptedError': 'interp_exceptions.W_InterruptedError',
-        'IsADirectoryError': 'interp_exceptions.W_IsADirectoryError',
-        'KeyError' : 'interp_exceptions.W_KeyError',
-        'KeyboardInterrupt' : 'interp_exceptions.W_KeyboardInterrupt',
-        'LookupError' : 'interp_exceptions.W_LookupError',
-        'MemoryError' : 'interp_exceptions.W_MemoryError',
-        'NameError' : 'interp_exceptions.W_NameError',
-        'NotADirectoryError': 'interp_exceptions.W_NotADirectoryError',
-        'NotImplementedError' : 'interp_exceptions.W_NotImplementedError',
-        'OSError' : 'interp_exceptions.W_OSError',
-        'OverflowError' : 'interp_exceptions.W_OverflowError',
-        'PendingDeprecationWarning' : 
'interp_exceptions.W_PendingDeprecationWarning',
-        'PermissionError': 'interp_exceptions.W_PermissionError',
-        'ProcessLookupError': 'interp_exceptions.W_ProcessLookupError',
-        'RecursionError' : 'interp_exceptions.W_RecursionError',
-        'ReferenceError' : 'interp_exceptions.W_ReferenceError',
-        'ResourceWarning'  : 'interp_exceptions.W_ResourceWarning',
-        'RuntimeError' : 'interp_exceptions.W_RuntimeError',
-        'RuntimeWarning' : 'interp_exceptions.W_RuntimeWarning',
-        'StopAsyncIteration' : 'interp_exceptions.W_StopAsyncIteration',
-        'StopIteration' : 'interp_exceptions.W_StopIteration',
-        'SyntaxError' : 'interp_exceptions.W_SyntaxError',
-        'SyntaxWarning' : 'interp_exceptions.W_SyntaxWarning',
-        'SystemError' : 'interp_exceptions.W_SystemError',
-        'SystemExit' : 'interp_exceptions.W_SystemExit',
-        'TabError' : 'interp_exceptions.W_TabError',
-        'TimeoutError': 'interp_exceptions.W_TimeoutError',
-        'TypeError' : 'interp_exceptions.W_TypeError',
-        'UnboundLocalError' : 'interp_exceptions.W_UnboundLocalError',
-        'UnicodeDecodeError' : 'interp_exceptions.W_UnicodeDecodeError',
-        'UnicodeEncodeError' : 'interp_exceptions.W_UnicodeEncodeError',
-        'UnicodeError' : 'interp_exceptions.W_UnicodeError',
-        'UnicodeTranslateError' : 'interp_exceptions.W_UnicodeTranslateError',
-        'UnicodeWarning' : 'interp_exceptions.W_UnicodeWarning',
-        'UserWarning' : 'interp_exceptions.W_UserWarning',
-        'ValueError' : 'interp_exceptions.W_ValueError',
-        'Warning' : 'interp_exceptions.W_Warning',
-        'ZeroDivisionError' : 'interp_exceptions.W_ZeroDivisionError',
-        }
-
-    if rwin32.WIN32:
-        interpleveldefs['WindowsError'] = 'interp_exceptions.W_OSError'
-
-    def setup_after_space_initialization(self):
-        from pypy.objspace.std.transparent import register_proxyable
-        from pypy.module.exceptions import interp_exceptions
-
-        for name, exc in interp_exceptions.__dict__.items():
-            if isinstance(exc, type) and issubclass(exc, 
interp_exceptions.W_BaseException):
-                register_proxyable(self.space, exc)
diff --git a/pypy/module/exceptions/__init__.py 
b/pypy/module/exceptions/moduledef.py
copy from pypy/module/exceptions/__init__.py
copy to pypy/module/exceptions/moduledef.py
diff --git a/pypy/module/faulthandler/__init__.py 
b/pypy/module/faulthandler/__init__.py
--- a/pypy/module/faulthandler/__init__.py
+++ b/pypy/module/faulthandler/__init__.py
@@ -1,38 +0,0 @@
-import sys
-from pypy.interpreter.mixedmodule import MixedModule
-
-
-class Module(MixedModule):
-    appleveldefs = {
-    }
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to