Author: Brian Kearns <[email protected]>
Branch:
Changeset: r62646:2299a8227a15
Date: 2013-03-22 04:29 -0400
http://bitbucket.org/pypy/pypy/changeset/2299a8227a15/
Log: cleanups in pypy.module
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,5 +1,3 @@
-import py
-
from pypy.interpreter.mixedmodule import MixedModule
class Module(MixedModule):
diff --git a/pypy/module/_continuation/interp_continuation.py
b/pypy/module/_continuation/interp_continuation.py
--- a/pypy/module/_continuation/interp_continuation.py
+++ b/pypy/module/_continuation/interp_continuation.py
@@ -221,7 +221,6 @@
self = global_state.origin
self.h = h
global_state.clear()
- space = self.space
try:
frame = self.bottomframe
w_result = frame.execute_frame()
diff --git a/pypy/module/_demo/demo.py b/pypy/module/_demo/demo.py
--- a/pypy/module/_demo/demo.py
+++ b/pypy/module/_demo/demo.py
@@ -5,7 +5,7 @@
from rpython.rtyper.lltypesystem import rffi, lltype
from rpython.rtyper.tool import rffi_platform
from rpython.translator.tool.cbuild import ExternalCompilationInfo
-import sys, math
+import math
time_t = rffi_platform.getsimpletype('time_t', '#include <time.h>', rffi.LONG)
diff --git a/pypy/module/_ffi/interp_funcptr.py
b/pypy/module/_ffi/interp_funcptr.py
--- a/pypy/module/_ffi/interp_funcptr.py
+++ b/pypy/module/_ffi/interp_funcptr.py
@@ -11,7 +11,7 @@
from rpython.rlib import libffi
from rpython.rlib.clibffi import get_libc_name, StackCheckError, LibFFIError
from rpython.rlib.rdynload import DLOpenError
-from rpython.rlib.rarithmetic import intmask, r_uint
+from rpython.rlib.rarithmetic import r_uint
from rpython.rlib.objectmodel import we_are_translated
from pypy.module._ffi.type_converter import FromAppLevelConverter,
ToAppLevelConverter
from pypy.module._rawffi.interp_rawffi import got_libffi_error
diff --git a/pypy/module/_ffi/interp_struct.py
b/pypy/module/_ffi/interp_struct.py
--- a/pypy/module/_ffi/interp_struct.py
+++ b/pypy/module/_ffi/interp_struct.py
@@ -3,13 +3,12 @@
from rpython.rlib import libffi
from rpython.rlib import jit
from rpython.rlib.rgc import must_be_light_finalizer
-from rpython.rlib.rarithmetic import r_uint, r_ulonglong, r_singlefloat,
intmask
+from rpython.rlib.rarithmetic import r_uint, r_ulonglong, intmask
from pypy.interpreter.baseobjspace import Wrappable
from pypy.interpreter.typedef import TypeDef, interp_attrproperty
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.error import operationerrfmt
-from pypy.objspace.std.typetype import type_typedef
-from pypy.module._ffi.interp_ffitype import W_FFIType, app_types
+from pypy.module._ffi.interp_ffitype import W_FFIType
from pypy.module._ffi.type_converter import FromAppLevelConverter,
ToAppLevelConverter
diff --git a/pypy/module/_ffi/type_converter.py
b/pypy/module/_ffi/type_converter.py
--- a/pypy/module/_ffi/type_converter.py
+++ b/pypy/module/_ffi/type_converter.py
@@ -1,7 +1,6 @@
from rpython.rlib import libffi
from rpython.rlib import jit
-from rpython.rlib.rarithmetic import intmask, r_uint
-from rpython.rtyper.lltypesystem import rffi
+from rpython.rlib.rarithmetic import r_uint
from pypy.interpreter.error import operationerrfmt, OperationError
from pypy.module._rawffi.structure import W_StructureInstance, W_Structure
from pypy.module._ffi.interp_ffitype import app_types
@@ -307,7 +306,7 @@
def get_unsigned_which_fits_into_a_signed(self, w_ffitype):
"""
Return type: lltype.Signed.
-
+
We return Signed even if the input type is unsigned, because this way
we get an app-level <int> instead of a <long>.
"""
diff --git a/pypy/module/_file/interp_file.py b/pypy/module/_file/interp_file.py
--- a/pypy/module/_file/interp_file.py
+++ b/pypy/module/_file/interp_file.py
@@ -138,7 +138,6 @@
self.fdopenstream(stream, fd, mode)
def direct_close(self):
- space = self.space
stream = self.stream
if stream is not None:
self.newlines = self.stream.getnewlines()
diff --git a/pypy/module/_hashlib/interp_hashlib.py
b/pypy/module/_hashlib/interp_hashlib.py
--- a/pypy/module/_hashlib/interp_hashlib.py
+++ b/pypy/module/_hashlib/interp_hashlib.py
@@ -4,9 +4,8 @@
from pypy.interpreter.error import OperationError
from rpython.tool.sourcetools import func_renamer
from pypy.interpreter.baseobjspace import Wrappable
-from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
+from rpython.rtyper.lltypesystem import lltype, rffi
from rpython.rlib import rgc, ropenssl
-from rpython.rlib.objectmodel import keepalive_until_here
from rpython.rlib.rstring import StringBuilder
from pypy.module.thread.os_lock import Lock
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,10 +1,9 @@
from pypy.interpreter.mixedmodule import MixedModule
-import sys
class Module(MixedModule):
appleveldefs = {
- }
+ }
interpleveldefs = {
'DEFAULT_BUFFER_SIZE': 'space.wrap(interp_iobase.DEFAULT_BUFFER_SIZE)',
@@ -25,7 +24,7 @@
'open': 'interp_io.open',
'IncrementalNewlineDecoder':
'interp_textio.W_IncrementalNewlineDecoder',
- }
+ }
def init(self, space):
MixedModule.init(self, space)
@@ -41,4 +40,3 @@
# at shutdown, flush all open streams. Ignore I/O errors.
from pypy.module._io.interp_iobase import get_autoflushher
get_autoflushher(space).flush_all(space)
-
diff --git a/pypy/module/_io/interp_bufferedio.py
b/pypy/module/_io/interp_bufferedio.py
--- a/pypy/module/_io/interp_bufferedio.py
+++ b/pypy/module/_io/interp_bufferedio.py
@@ -531,7 +531,7 @@
raise
else:
break
-
+
if space.is_w(w_size, space.w_None):
raise BlockingIOError()
size = space.int_w(w_size)
@@ -564,7 +564,6 @@
result_buffer = ['\0'] * n
remaining = n
written = 0
- data = None
if current_size:
for i in range(current_size):
result_buffer[written + i] = self.buffer[self.pos + i]
@@ -926,10 +925,6 @@
mode = GetSetProperty(W_BufferedWriter.mode_get_w),
)
-def _forward_call(space, w_obj, method, __args__):
- w_meth = self.getattr(w_obj, self.wrap(method))
- return self.call_args(w_meth, __args__)
-
def make_forwarding_method(method, writer=False, reader=False):
@func_renamer(method + '_w')
def method_w(self, space, __args__):
diff --git a/pypy/module/_io/interp_fileio.py b/pypy/module/_io/interp_fileio.py
--- a/pypy/module/_io/interp_fileio.py
+++ b/pypy/module/_io/interp_fileio.py
@@ -290,7 +290,7 @@
self._check_closed(space)
if self.seekable < 0:
try:
- pos = os.lseek(self.fd, 0, os.SEEK_CUR)
+ os.lseek(self.fd, 0, os.SEEK_CUR)
except OSError:
self.seekable = 0
else:
diff --git a/pypy/module/_io/interp_iobase.py b/pypy/module/_io/interp_iobase.py
--- a/pypy/module/_io/interp_iobase.py
+++ b/pypy/module/_io/interp_iobase.py
@@ -149,8 +149,6 @@
# For backwards compatibility, a (slowish) readline().
limit = convert_size(space, w_limit)
- old_size = -1
-
has_peek = space.findattr(self, space.wrap("peek"))
builder = StringBuilder()
@@ -315,7 +313,6 @@
# ------------------------------------------------------------
class StreamHolder(object):
-
def __init__(self, w_iobase):
self.w_iobase_ref = rweakref.ref(w_iobase)
w_iobase.autoflusher = self
@@ -325,7 +322,7 @@
if w_iobase is not None:
try:
space.call_method(w_iobase, 'flush')
- except OperationError, e:
+ except OperationError:
# Silencing all errors is bad, but getting randomly
# interrupted here is equally as bad, and potentially
# more frequent (because of shutdown issues).
@@ -333,7 +330,6 @@
class AutoFlusher(object):
-
def __init__(self, space):
self.streams = {}
@@ -366,8 +362,5 @@
else:
streamholder.autoflush(space)
-
def get_autoflushher(space):
return space.fromcache(AutoFlusher)
-
-
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
@@ -8,9 +8,7 @@
py.test.skip("no _curses or _minimal_curses module") #no _curses at all
from pypy.interpreter.mixedmodule import MixedModule
-from pypy.module._minimal_curses import fficurses
-from pypy.module._minimal_curses import interp_curses
-from rpython.rlib.nonconst import NonConstant
+from pypy.module._minimal_curses import fficurses # for side effects
class Module(MixedModule):
@@ -21,7 +19,7 @@
appleveldefs = {
'error' : 'app_curses.error',
}
-
+
interpleveldefs = {
'setupterm' : 'interp_curses.setupterm',
'tigetstr' : 'interp_curses.tigetstr',
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,11 +1,8 @@
-import py
-
from pypy.interpreter.mixedmodule import MixedModule
class Module(MixedModule):
appleveldefs = {}
-
+
interpleveldefs = {
'Random' : 'interp_random.W_Random',
- }
-
+ }
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,15 +1,9 @@
-
""" Low-level interface to clibffi
"""
from pypy.interpreter.mixedmodule import MixedModule
-from pypy.module._rawffi.interp_rawffi import W_CDLL
-from rpython.rtyper.lltypesystem import lltype, rffi
-from pypy.module._rawffi.tracker import Tracker
-import sys
class Module(MixedModule):
-
interpleveldefs = {
'CDLL' : 'interp_rawffi.W_CDLL',
'FuncPtr' : 'interp_rawffi.W_FuncPtr',
@@ -52,6 +46,6 @@
]:
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/_socket/__init__.py b/pypy/module/_socket/__init__.py
--- a/pypy/module/_socket/__init__.py
+++ b/pypy/module/_socket/__init__.py
@@ -1,6 +1,4 @@
-# Package initialisation
from pypy.interpreter.mixedmodule import MixedModule
-import sys
class Module(MixedModule):
@@ -31,11 +29,10 @@
getdefaulttimeout setdefaulttimeout
""".split():
- if name in ('inet_pton', 'inet_ntop',
- 'fromfd', 'socketpair',
- ) and not hasattr(rsocket, name):
+ if name in ('inet_pton', 'inet_ntop', 'fromfd', 'socketpair') \
+ and not hasattr(rsocket, name):
continue
-
+
Module.interpleveldefs[name] = 'interp_func.%s' % (name, )
for constant, value in rsocket.constants.iteritems():
diff --git a/pypy/module/_socket/interp_socket.py
b/pypy/module/_socket/interp_socket.py
--- a/pypy/module/_socket/interp_socket.py
+++ b/pypy/module/_socket/interp_socket.py
@@ -163,7 +163,7 @@
def bind_w(self, space, w_addr):
"""bind(address)
-
+
Bind the socket to a local address. For IP sockets, the address is a
pair (host, port); the host must refer to the local host. For raw
packet
sockets the address is a tuple (ifname, proto [,pkttype [,hatype]])
@@ -180,7 +180,7 @@
"""
try:
self.close()
- except SocketError, e:
+ except SocketError:
# cpython doesn't return any errors on close
pass
diff --git a/pypy/module/_warnings/interp_warnings.py
b/pypy/module/_warnings/interp_warnings.py
--- a/pypy/module/_warnings/interp_warnings.py
+++ b/pypy/module/_warnings/interp_warnings.py
@@ -190,7 +190,6 @@
return space.wrap("<unknown>")
filename = space.str_w(w_filename)
- length = len(filename)
if filename.endswith(".py"):
n = len(filename) - 3
assert n >= 0
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,5 +1,4 @@
from pypy.interpreter.mixedmodule import MixedModule
-from pypy.module._winreg import interp_winreg
from rpython.rlib.rwinreg import constants
class Module(MixedModule):
diff --git a/pypy/module/_winreg/interp_winreg.py
b/pypy/module/_winreg/interp_winreg.py
--- a/pypy/module/_winreg/interp_winreg.py
+++ b/pypy/module/_winreg/interp_winreg.py
@@ -188,7 +188,6 @@
The caller of this method must possess the SeBackupPrivilege security
privilege.
This function passes NULL for security_attributes to the API."""
hkey = hkey_w(w_hkey, space)
- pSA = 0
ret = rwinreg.RegSaveKey(hkey, filename, None)
if ret != 0:
raiseWindowsError(space, ret, 'RegSaveKey')
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,5 +1,6 @@
from pypy.interpreter.mixedmodule import MixedModule
-from pypy.module.array.interp_array import types, W_ArrayBase
+
+from pypy.module.array.interp_array import types
from pypy.objspace.std.model import registerimplementation
for mytype in types.values():
@@ -7,7 +8,6 @@
class Module(MixedModule):
-
interpleveldefs = {
'array': 'interp_array.W_ArrayBase',
'ArrayType': 'interp_array.W_ArrayBase',
diff --git a/pypy/module/array/interp_array.py
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -412,7 +412,6 @@
return space.wrap(cnt)
def array_index__Array_ANY(space, self, w_val):
- cnt = 0
for i in range(self.len):
w_item = self.w_getitem(space, i)
if space.is_true(space.eq(w_item, w_val)):
diff --git a/pypy/module/clr/app_importer.py b/pypy/module/clr/app_importer.py
--- a/pypy/module/clr/app_importer.py
+++ b/pypy/module/clr/app_importer.py
@@ -4,7 +4,6 @@
# Meta hooks can override the sys.path, frozen modules , built-in modules
# To register a Meta Hook simply add importer object to sys.meta_path
-import imp
import sys
import types
@@ -69,8 +68,6 @@
mod.__name__ = fullname
# add it to the modules dict
sys.modules[fullname] = mod
- else:
- mod = sys.modules[fullname]
# if it is a PACKAGE then we are to initialize the __path__ for
the module
# we won't deal with Packages here
@@ -81,7 +78,7 @@
if not name.startswith("__"):
try:
iname = self.__name__ + '.' + name
- mod = __import__(iname)
+ __import__(iname)
except ImportError:
pass
return types.ModuleType.__getattribute__(self, name)
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,8 +1,6 @@
from pypy.interpreter.mixedmodule import MixedModule
-from rpython.rlib.objectmodel import we_are_translated
from pypy.module.cpyext.state import State
from pypy.module.cpyext import api
-from rpython.rtyper.lltypesystem import rffi, lltype
class Module(MixedModule):
interpleveldefs = {
diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -112,7 +112,7 @@
def try_getattr(space, w_obj, w_name):
try:
return space.getattr(w_obj, w_name)
- except OperationError, e:
+ except OperationError:
# ugh, but blame CPython :-/ this is supposed to emulate
# hasattr, which eats all exceptions.
return None
@@ -164,8 +164,7 @@
# Try to import parent package
try:
- w_parent = absolute_import(space, ctxt_package, 0,
- None, tentative=False)
+ absolute_import(space, ctxt_package, 0, None, tentative=False)
except OperationError, e:
if not e.match(space, space.w_ImportError):
raise
@@ -703,7 +702,6 @@
namepath = modulename.split('.')
subname = namepath[-1]
parent_name = '.'.join(namepath[:-1])
- parent = None
if parent_name:
w_parent = check_sys_modules_w(space, parent_name)
if w_parent is None:
@@ -1005,7 +1003,6 @@
Load a module from a compiled file, execute it, and return its
module object.
"""
- w = space.wrap
if magic != get_pyc_magic(space):
raise operationerrfmt(space.w_ImportError,
"Bad magic number in %s", cpathname)
diff --git a/pypy/module/marshal/interp_marshal.py
b/pypy/module/marshal/interp_marshal.py
--- a/pypy/module/marshal/interp_marshal.py
+++ b/pypy/module/marshal/interp_marshal.py
@@ -235,7 +235,6 @@
lng = len(lst_w)
self.put_int(lng)
idx = 0
- space = self.space
while idx < lng:
w_obj = lst_w[idx]
self.space.marshal_w(w_obj, self)
diff --git a/pypy/module/math/interp_math.py b/pypy/module/math/interp_math.py
--- a/pypy/module/math/interp_math.py
+++ b/pypy/module/math/interp_math.py
@@ -1,7 +1,7 @@
import math
import sys
-from rpython.rlib import rfloat, unroll
+from rpython.rlib import rfloat
from pypy.interpreter.error import OperationError
class State:
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -10,8 +10,7 @@
from rpython.rlib.rawstorage import (alloc_raw_storage, raw_storage_setitem,
raw_storage_getitem)
from rpython.rlib.objectmodel import specialize
-from rpython.rlib.rarithmetic import (widen, byteswap, r_ulonglong,
- most_neg_value_of)
+from rpython.rlib.rarithmetic import widen, byteswap, r_ulonglong
from rpython.rtyper.lltypesystem import lltype, rffi
from rpython.rlib.rstruct.runpack import runpack
from rpython.rlib.rstruct.nativefmttable import native_is_bigendian
diff --git a/pypy/module/mmap/__init__.py b/pypy/module/mmap/__init__.py
--- a/pypy/module/mmap/__init__.py
+++ b/pypy/module/mmap/__init__.py
@@ -1,5 +1,4 @@
from pypy.interpreter.mixedmodule import MixedModule
-from rpython.rlib import rmmap
class Module(MixedModule):
interpleveldefs = {
@@ -14,13 +13,11 @@
appleveldefs = {
}
-
+
def buildloaders(cls):
- from pypy.module.mmap import interp_mmap
+ from rpython.rlib import rmmap
for constant, value in rmmap.constants.iteritems():
if isinstance(value, (int, long)):
Module.interpleveldefs[constant] = "space.wrap(%r)" % value
-
super(Module, cls).buildloaders()
buildloaders = classmethod(buildloaders)
-
diff --git a/pypy/module/operator/__init__.py b/pypy/module/operator/__init__.py
--- a/pypy/module/operator/__init__.py
+++ b/pypy/module/operator/__init__.py
@@ -1,5 +1,4 @@
-from pypy.interpreter.mixedmodule import MixedModule
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.mixedmodule import MixedModule
class Module(MixedModule):
"""Operator Builtin Module. """
@@ -10,19 +9,19 @@
def __init__(self, space, w_name):
def create_lambda(name, alsoname):
return lambda space : self.getdictvalue(space, alsoname)
-
+
MixedModule.__init__(self, space, w_name)
for name, alsoname in self.mapping.iteritems():
self.loaders[name] = create_lambda(name, alsoname)
- appleveldefs = {}
-
+ appleveldefs = {}
+
app_names = ['__delslice__', '__getslice__', '__repeat__', '__setslice__',
'countOf', 'delslice', 'getslice', 'indexOf',
'isMappingType', 'isNumberType', 'isSequenceType',
'repeat', 'setslice',
'attrgetter', 'itemgetter', 'methodcaller',
- ]
+ ]
for name in app_names:
appleveldefs[name] = 'app_operator.%s' % name
@@ -45,52 +44,52 @@
interpleveldefs[name] = 'interp_operator.%s' % name
mapping = {
- '__abs__' : 'abs',
- '__add__' : 'add',
- '__and__' : 'and_',
- '__concat__' : 'concat',
- '__contains__' : 'contains',
- 'sequenceIncludes' : 'contains',
- '__delitem__' : 'delitem',
- '__div__' : 'div',
- '__eq__' : 'eq',
- '__floordiv__' : 'floordiv',
- '__ge__' : 'ge',
- '__getitem__' : 'getitem',
- '__gt__' : 'gt',
- '__inv__' : 'inv',
- '__invert__' : 'invert',
- '__le__' : 'le',
- '__lshift__' : 'lshift',
- '__lt__' : 'lt',
- '__mod__' : 'mod',
- '__mul__' : 'mul',
- '__ne__' : 'ne',
- '__neg__' : 'neg',
- '__not__' : 'not_',
- '__or__' : 'or_',
- '__pos__' : 'pos',
- '__pow__' : 'pow',
- '__rshift__' : 'rshift',
- '__setitem__' : 'setitem',
- '__sub__' : 'sub',
- '__truediv__' : 'truediv',
- '__xor__' : 'xor',
- # in-place
- '__iadd__' : 'iadd',
- '__iand__' : 'iand',
- '__iconcat__' : 'iconcat',
- '__idiv__' : 'idiv',
- '__ifloordiv__' : 'ifloordiv',
- '__ilshift__' : 'ilshift',
- '__imod__' : 'imod',
- '__imul__' : 'imul',
- '__ior__' : 'ior',
- '__ipow__' : 'ipow',
- '__irepeat__' : 'irepeat',
- '__irshift__' : 'irshift',
- '__isub__' : 'isub',
- '__itruediv__' : 'itruediv',
- '__ixor__' : 'ixor',
+ '__abs__' : 'abs',
+ '__add__' : 'add',
+ '__and__' : 'and_',
+ '__concat__' : 'concat',
+ '__contains__' : 'contains',
+ 'sequenceIncludes' : 'contains',
+ '__delitem__' : 'delitem',
+ '__div__' : 'div',
+ '__eq__' : 'eq',
+ '__floordiv__' : 'floordiv',
+ '__ge__' : 'ge',
+ '__getitem__' : 'getitem',
+ '__gt__' : 'gt',
+ '__inv__' : 'inv',
+ '__invert__' : 'invert',
+ '__le__' : 'le',
+ '__lshift__' : 'lshift',
+ '__lt__' : 'lt',
+ '__mod__' : 'mod',
+ '__mul__' : 'mul',
+ '__ne__' : 'ne',
+ '__neg__' : 'neg',
+ '__not__' : 'not_',
+ '__or__' : 'or_',
+ '__pos__' : 'pos',
+ '__pow__' : 'pow',
+ '__rshift__' : 'rshift',
+ '__setitem__' : 'setitem',
+ '__sub__' : 'sub',
+ '__truediv__' : 'truediv',
+ '__xor__' : 'xor',
+ # in-place
+ '__iadd__' : 'iadd',
+ '__iand__' : 'iand',
+ '__iconcat__' : 'iconcat',
+ '__idiv__' : 'idiv',
+ '__ifloordiv__' : 'ifloordiv',
+ '__ilshift__' : 'ilshift',
+ '__imod__' : 'imod',
+ '__imul__' : 'imul',
+ '__ior__' : 'ior',
+ '__ipow__' : 'ipow',
+ '__irepeat__' : 'irepeat',
+ '__irshift__' : 'irshift',
+ '__isub__' : 'isub',
+ '__itruediv__' : 'itruediv',
+ '__ixor__' : 'ixor',
}
diff --git a/pypy/module/oracle/conftest.py b/pypy/module/oracle/conftest.py
--- a/pypy/module/oracle/conftest.py
+++ b/pypy/module/oracle/conftest.py
@@ -1,5 +1,3 @@
-from rpython.rtyper.tool.rffi_platform import CompilationError
-import py
import os
def pytest_addoption(parser):
diff --git a/pypy/module/oracle/transform.py b/pypy/module/oracle/transform.py
--- a/pypy/module/oracle/transform.py
+++ b/pypy/module/oracle/transform.py
@@ -1,5 +1,5 @@
from rpython.rtyper.lltypesystem import rffi, lltype
-from pypy.module.oracle import roci, config
+from pypy.module.oracle import roci
def OracleNumberToPythonFloat(environment, valueptr):
"Return a Python float object given an oracle number"
diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py
--- a/pypy/module/posix/__init__.py
+++ b/pypy/module/posix/__init__.py
@@ -1,8 +1,7 @@
-# Package initialisation
from pypy.interpreter.mixedmodule import MixedModule
from rpython.rtyper.module.ll_os import RegisterOs
-import os, sys
+import os
exec 'import %s as posix' % os.name
# this is the list of function which is *not* present in the posix module of
diff --git a/pypy/module/posix/interp_posix.py
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -4,20 +4,17 @@
from rpython.rlib.rarithmetic import r_longlong
from rpython.rlib.unroll import unrolling_iterable
from pypy.interpreter.error import OperationError, wrap_oserror, wrap_oserror2
-from pypy.interpreter.error import operationerrfmt
from rpython.rtyper.module.ll_os import RegisterOs
from rpython.rtyper.module import ll_os_stat
-from rpython.rtyper.lltypesystem import rffi, lltype
-from rpython.rtyper.tool import rffi_platform
-from rpython.translator.tool.cbuild import ExternalCompilationInfo
from pypy.module.sys.interp_encoding import getfilesystemencoding
-import os, sys
+import os
+import sys
_WIN32 = sys.platform == 'win32'
if _WIN32:
from rpython.rlib.rwin32 import _MAX_ENV
-
+
c_int = "c_int"
# CPython 2.7 semantics are too messy to follow exactly,
@@ -854,17 +851,6 @@
raise
raise OperationError(space.w_TypeError, space.wrap(msg))
-def setsid(space):
- """setsid() -> pid
-
- Creates a new session with this process as the leader.
- """
- try:
- result = os.setsid()
- except OSError, e:
- raise wrap_oserror(space, e)
- return space.wrap(result)
-
def uname(space):
""" uname() -> (sysname, nodename, release, version, machine)
@@ -1161,7 +1147,7 @@
def getloadavg(space):
try:
load = os.getloadavg()
- except OSError, e:
+ except OSError:
raise OperationError(space.w_OSError,
space.wrap("Load averages are unobtainable"))
return space.newtuple([space.wrap(load[0]),
diff --git a/pypy/module/pwd/interp_pwd.py b/pypy/module/pwd/interp_pwd.py
--- a/pypy/module/pwd/interp_pwd.py
+++ b/pypy/module/pwd/interp_pwd.py
@@ -1,8 +1,8 @@
from rpython.translator.tool.cbuild import ExternalCompilationInfo
from rpython.rtyper.tool import rffi_platform
from rpython.rtyper.lltypesystem import rffi, lltype
-from pypy.interpreter.gateway import interp2app, unwrap_spec
-from pypy.interpreter.error import OperationError, operationerrfmt
+from pypy.interpreter.gateway import unwrap_spec
+from pypy.interpreter.error import operationerrfmt
from rpython.rlib.rarithmetic import intmask
eci = ExternalCompilationInfo(
diff --git a/pypy/module/pyexpat/__init__.py b/pypy/module/pyexpat/__init__.py
--- a/pypy/module/pyexpat/__init__.py
+++ b/pypy/module/pyexpat/__init__.py
@@ -1,5 +1,3 @@
-import py
-
from pypy.interpreter.mixedmodule import MixedModule
class ErrorsModule(MixedModule):
diff --git a/pypy/module/signal/__init__.py b/pypy/module/signal/__init__.py
--- a/pypy/module/signal/__init__.py
+++ b/pypy/module/signal/__init__.py
@@ -1,7 +1,6 @@
+from pypy.interpreter.mixedmodule import MixedModule
-from pypy.interpreter.mixedmodule import MixedModule
import os
-import signal as cpy_signal
class Module(MixedModule):
interpleveldefs = {
diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -91,18 +91,18 @@
if sys.platform == 'win32':
interpleveldefs['winver'] = 'version.get_winver(space)'
interpleveldefs['getwindowsversion'] = 'vm.getwindowsversion'
-
+
appleveldefs = {
- 'excepthook' : 'app.excepthook',
- '__excepthook__' : 'app.excepthook',
- 'exit' : 'app.exit',
+ 'excepthook' : 'app.excepthook',
+ '__excepthook__' : 'app.excepthook',
+ 'exit' : 'app.exit',
'exitfunc' : 'app.exitfunc',
'callstats' : 'app.callstats',
'copyright' : 'app.copyright_str',
'flags' : 'app.null_sysflags',
}
- def setbuiltinmodule(self, w_module, name):
+ def setbuiltinmodule(self, w_module, name):
w_name = self.space.wrap(name)
w_modules = self.get('modules')
self.space.setitem(w_modules, w_name, w_module)
@@ -120,8 +120,8 @@
def getmodule(self, name):
space = self.space
- w_modules = self.get('modules')
- try:
+ w_modules = self.get('modules')
+ try:
return space.getitem(w_modules, space.wrap(name))
except OperationError, e:
if not e.match(space, space.w_KeyError):
diff --git a/pypy/module/sys/currentframes.py b/pypy/module/sys/currentframes.py
--- a/pypy/module/sys/currentframes.py
+++ b/pypy/module/sys/currentframes.py
@@ -48,7 +48,6 @@
This function should be used for specialized purposes only."""
w_result = space.newdict()
w_fake_frame = app.wget(space, "fake_frame")
- w_fake_code = app.wget(space, "fake_code")
ecs = space.threadlocals.getallvalues()
for thread_ident, ec in ecs.items():
vref = ec.topframeref
@@ -61,7 +60,7 @@
vref = f.f_backref
else:
frames.append(None)
- #
+
w_topframe = space.wrap(None)
w_prevframe = None
for f in frames:
@@ -71,7 +70,7 @@
else:
space.setattr(w_prevframe, space.wrap('f_back'), w_nextframe)
w_prevframe = w_nextframe
- #
+
space.setitem(w_result,
space.wrap(thread_ident),
w_topframe)
diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -1,8 +1,6 @@
"""
Implementation of interpreter-level 'sys' routines.
"""
-import sys
-
from pypy.interpreter import gateway
from pypy.interpreter.error import OperationError
from pypy.interpreter.gateway import unwrap_spec, WrappedDefault
@@ -11,15 +9,6 @@
# ____________________________________________________________
-def setbuiltinmodule(w_module, name):
- """ put a module into the modules builtin_modules dicts """
- if builtin_modules[name] is None:
- builtin_modules[name] = space.unwrap(w_module)
- else:
- assert builtin_modules[name] is space.unwrap(w_module), (
- "trying to change the builtin-in module %r" % (name,))
- space.setitem(w_modules, space.wrap(name), w_module)
-
@unwrap_spec(w_depth = WrappedDefault(0))
def _getframe(space, w_depth):
"""Return a frame object from the call stack. If optional integer depth is
diff --git a/pypy/module/termios/__init__.py b/pypy/module/termios/__init__.py
--- a/pypy/module/termios/__init__.py
+++ b/pypy/module/termios/__init__.py
@@ -1,7 +1,4 @@
-
from pypy.interpreter.mixedmodule import MixedModule
-import termios
-from rpython.rlib.nonconst import NonConstant
class Module(MixedModule):
"This module provides an interface to the Posix calls for tty I/O
control.\n\
@@ -15,7 +12,7 @@
appleveldefs = {
}
-
+
interpleveldefs = {
'tcdrain' : 'interp_termios.tcdrain',
'tcflow' : 'interp_termios.tcflow',
@@ -26,13 +23,10 @@
'error' : 'space.fromcache(interp_termios.Cache).w_error',
}
-import termios
-from pypy.module.termios import interp_termios
-
# XXX this is extremaly not-portable, but how to prevent this?
+import termios
for i in dir(termios):
val = getattr(termios, i)
if i.isupper() and type(val) is int:
Module.interpleveldefs[i] = "space.wrap(%s)" % val
-
diff --git a/pypy/module/termios/interp_termios.py
b/pypy/module/termios/interp_termios.py
--- a/pypy/module/termios/interp_termios.py
+++ b/pypy/module/termios/interp_termios.py
@@ -4,10 +4,7 @@
"""
from pypy.interpreter.gateway import unwrap_spec
-from pypy.interpreter.error import OperationError, wrap_oserror
-from rpython.rtyper.module import ll_termios
-from rpython.rlib.objectmodel import we_are_translated
-import os
+from pypy.interpreter.error import wrap_oserror
from rpython.rlib import rtermios
import termios
diff --git a/pypy/module/thread/os_local.py b/pypy/module/thread/os_local.py
--- a/pypy/module/thread/os_local.py
+++ b/pypy/module/thread/os_local.py
@@ -1,6 +1,6 @@
import weakref
from rpython.rlib import jit
-from pypy.interpreter.baseobjspace import Wrappable, W_Root
+from pypy.interpreter.baseobjspace import Wrappable
from pypy.interpreter.executioncontext import ExecutionContext
from pypy.interpreter.typedef import (TypeDef, interp2app, GetSetProperty,
descr_get_dict)
diff --git a/pypy/module/thread/os_thread.py b/pypy/module/thread/os_thread.py
--- a/pypy/module/thread/os_thread.py
+++ b/pypy/module/thread/os_thread.py
@@ -183,7 +183,7 @@
try:
rthread.gc_thread_prepare() # (this has no effect any more)
ident = rthread.start_new_thread(bootstrapper.bootstrap, ())
- except Exception, e:
+ except Exception:
bootstrapper.release() # normally called by the new thread
raise
except rthread.error:
diff --git a/pypy/module/time/__init__.py b/pypy/module/time/__init__.py
--- a/pypy/module/time/__init__.py
+++ b/pypy/module/time/__init__.py
@@ -1,17 +1,13 @@
-# Package initialisation
from pypy.interpreter.mixedmodule import MixedModule
-import time
-
class Module(MixedModule):
"""time module"""
appleveldefs = {
}
-
+
interpleveldefs = {
- 'clock' : 'interp_time.clock',
- 'time' : 'interp_time.time_',
- 'sleep' : 'interp_time.sleep',
+ 'clock' : 'interp_time.clock',
+ 'time' : 'interp_time.time_',
+ 'sleep' : 'interp_time.sleep',
}
-
diff --git a/pypy/module/unicodedata/__init__.py
b/pypy/module/unicodedata/__init__.py
--- a/pypy/module/unicodedata/__init__.py
+++ b/pypy/module/unicodedata/__init__.py
@@ -1,4 +1,5 @@
from pypy.interpreter.mixedmodule import MixedModule
+
# This is the default unicodedb used in various places:
# - the unicode type
# - the regular expression engine
diff --git a/pypy/module/zipimport/interp_zipimport.py
b/pypy/module/zipimport/interp_zipimport.py
--- a/pypy/module/zipimport/interp_zipimport.py
+++ b/pypy/module/zipimport/interp_zipimport.py
@@ -52,10 +52,8 @@
raise OperationError(space.w_KeyError, space.wrap(name))
assert isinstance(w_zipimporter, W_ZipImporter)
w = space.wrap
- values = {}
w_d = space.newdict()
for key, info in w_zipimporter.zip_file.NameToInfo.iteritems():
- w_values = space.newdict()
space.setitem(w_d, w(key), space.newtuple([
w(info.filename), w(info.compress_type), w(info.compress_size),
w(info.file_size), w(info.file_offset), w(info.dostime),
@@ -350,7 +348,6 @@
@unwrap_spec(name='str0')
def descr_new_zipimporter(space, w_type, name):
- w = space.wrap
ok = False
parts_ends = [i for i in range(0, len(name))
if name[i] == os.path.sep or name[i] == ZIPSEP]
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit