Author: Brian Kearns <[email protected]>
Branch:
Changeset: r62651:f4837cb97fc2
Date: 2013-03-22 05:51 -0400
http://bitbucket.org/pypy/pypy/changeset/f4837cb97fc2/
Log: random other cleanups
diff --git a/pypy/bin/checkmodule.py b/pypy/bin/checkmodule.py
--- a/pypy/bin/checkmodule.py
+++ b/pypy/bin/checkmodule.py
@@ -33,7 +33,7 @@
modname = os.path.basename(modname)
try:
checkmodule(modname)
- except Exception, e:
+ except Exception:
import traceback, pdb
traceback.print_exc()
pdb.post_mortem(sys.exc_info()[2])
diff --git a/pypy/bin/dotviewer.py b/pypy/bin/dotviewer.py
--- a/pypy/bin/dotviewer.py
+++ b/pypy/bin/dotviewer.py
@@ -4,6 +4,7 @@
Run with no arguments for help.
"""
+import os
import sys
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__),
'..', '..')))
from dotviewer.dotviewer import main
diff --git a/pypy/bin/pyinteractive.py b/pypy/bin/pyinteractive.py
--- a/pypy/bin/pyinteractive.py
+++ b/pypy/bin/pyinteractive.py
@@ -6,14 +6,13 @@
"""
-import os, sys
+import os
+import sys
import time
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
-import pypy
from pypy.tool import option
-from optparse import make_option
from pypy.interpreter import main, interactive, error, gateway
from rpython.config.config import OptionDescription, BoolOption, StrOption
from rpython.config.config import Config, to_optparse
diff --git a/pypy/bin/reportstaticdata.py b/pypy/bin/reportstaticdata.py
--- a/pypy/bin/reportstaticdata.py
+++ b/pypy/bin/reportstaticdata.py
@@ -61,7 +61,6 @@
def main():
- import sys
try:
kwds = parse_options(sys.argv[1:])
except AssertionError:
diff --git a/pypy/goal/targetpypystandalone.py
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -5,7 +5,7 @@
from pypy.interpreter import gateway
from pypy.interpreter.error import OperationError
from pypy.tool.ann_override import PyPyAnnotatorPolicy
-from rpython.config.config import Config, to_optparse, make_dict,
SUPPRESS_USAGE
+from rpython.config.config import to_optparse, make_dict, SUPPRESS_USAGE
from rpython.config.config import ConflictConfigError
from pypy.tool.option import make_objspace
from pypy.conftest import pypydir
diff --git a/pypy/tool/alarm.py b/pypy/tool/alarm.py
--- a/pypy/tool/alarm.py
+++ b/pypy/tool/alarm.py
@@ -7,8 +7,6 @@
sending KeyboardInterrupts.
"""
-import traceback
-
def _main_with_alarm(finished):
import sys, os
import time
diff --git a/pypy/tool/ann_override.py b/pypy/tool/ann_override.py
--- a/pypy/tool/ann_override.py
+++ b/pypy/tool/ann_override.py
@@ -1,10 +1,7 @@
# overrides for annotation specific to PyPy codebase
-from rpython.annotator.policy import AnnotatorPolicy, Sig
-# for some reason, model must be imported first,
-# or we create a cycle.
+from rpython.annotator.policy import AnnotatorPolicy
+from rpython.annotator.signature import Sig
from rpython.flowspace.model import Constant
-from rpython.annotator import model as annmodel
-from rpython.annotator.bookkeeper import getbookkeeper
from rpython.annotator import specialize
from pypy.interpreter import baseobjspace
@@ -60,8 +57,8 @@
# for jit benefit
if cached not in t._immutable_fields_: # accessed this way just
# for convenience
- t._immutable_fields_.append(cached)
-
+ t._immutable_fields_.append(cached)
+
def attach_lookup(pol, t, attr):
cached = "cached_%s" % attr
if not t.is_heaptype() and not t.is_cpytype():
diff --git a/pypy/tool/import_graph.py b/pypy/tool/import_graph.py
--- a/pypy/tool/import_graph.py
+++ b/pypy/tool/import_graph.py
@@ -1,7 +1,6 @@
from __future__ import division
import py
-import math
import random
exclude_files = ["__init__.py", "conftest.py"]
@@ -72,7 +71,6 @@
return points[0]
def color(t):
- points = [0, 0, 1, 0, 0]
casteljeau([0, 0, 1, 0, 0], t) / 0.375
class ModuleGraph(object):
diff --git a/pypy/tool/option.py b/pypy/tool/option.py
--- a/pypy/tool/option.py
+++ b/pypy/tool/option.py
@@ -1,8 +1,7 @@
# This is where the options for py.py are defined.
-import os
from pypy.config.pypyoption import get_pypy_config
-from rpython.config.config import Config, OptionDescription, to_optparse
+from rpython.config.config import to_optparse
import optparse
extra_useage = """For detailed descriptions of all the options see
diff --git a/pypy/tool/pydis.py b/pypy/tool/pydis.py
--- a/pypy/tool/pydis.py
+++ b/pypy/tool/pydis.py
@@ -147,7 +147,6 @@
n = len(code)
i = 0
extended_arg = 0
- free = None
while i < n:
c = code[i]
op = ord(c)
@@ -171,7 +170,7 @@
i = i+2
if op == EXTENDED_ARG:
extended_arg = oparg*65536L
-
+
disresult.append(current_bytecodeindex, oparg, lineno)
assert disresult is not None
return disresult
diff --git a/pypy/tool/traceconfig.py b/pypy/tool/traceconfig.py
--- a/pypy/tool/traceconfig.py
+++ b/pypy/tool/traceconfig.py
@@ -29,7 +29,7 @@
# Many operations call back into the object space
"recursive_operations" : False,
-
+
# Show the bytecode or just the operations
"show_bytecode" : True,
@@ -45,6 +45,4 @@
"result_printer_clz" : ResultPrinter,
"operations" : get_operations_all()
-
}
-
diff --git a/rpython/bin/translatorshell.py b/rpython/bin/translatorshell.py
--- a/rpython/bin/translatorshell.py
+++ b/rpython/bin/translatorshell.py
@@ -24,7 +24,8 @@
Try dir(snippet) for list of current snippets.
"""
-import os, sys
+import os
+import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(
os.path.dirname(os.path.realpath(__file__)))))
@@ -32,8 +33,6 @@
from rpython.rtyper.rtyper import *
from rpython.rlib.rarithmetic import *
-import py
-
def get_c_function(lib, f):
from ctypes import CDLL
diff --git a/rpython/config/config.py b/rpython/config/config.py
--- a/rpython/config/config.py
+++ b/rpython/config/config.py
@@ -1,4 +1,3 @@
-import py
import optparse
from rpython.tool.pairtype import extendabletype
@@ -18,7 +17,7 @@
class Config(object):
_cfgimpl_frozen = False
-
+
def __init__(self, descr, parent=None, **overrides):
self._cfgimpl_descr = descr
self._cfgimpl_value_owners = {}
@@ -239,15 +238,15 @@
def add_optparse_option(self, argnames, parser, config):
callback = ConfigUpdate(config, self)
- option = parser.add_option(help=self.doc+" %default",
- action='callback', type=self.opt_type,
- callback=callback,
metavar=self._name.upper(),
- *argnames)
+ parser.add_option(help=self.doc+" %default",
+ action='callback', type=self.opt_type,
+ callback=callback, metavar=self._name.upper(),
+ *argnames)
-
+
class ChoiceOption(Option):
opt_type = 'string'
-
+
def __init__(self, name, doc, values, default=None, requires=None,
suggests=None, cmdline=DEFAULT_OPTION_NAME):
super(ChoiceOption, self).__init__(name, doc, cmdline)
@@ -328,9 +327,9 @@
def add_optparse_option(self, argnames, parser, config):
callback = BoolConfigUpdate(config, self, True)
- option = parser.add_option(help=self.doc+" %default",
- action='callback',
- callback=callback, *argnames)
+ parser.add_option(help=self.doc+" %default",
+ action='callback',
+ callback=callback, *argnames)
if not self.negation:
return
no_argnames = ["--" + _getnegation(argname.lstrip("-"))
@@ -340,14 +339,14 @@
no_argnames = ["--" + _getnegation(argname.lstrip("-"))
for argname in argnames]
callback = BoolConfigUpdate(config, self, False)
- option = parser.add_option(help="unset option set by %s %%default" %
(argname, ),
- action='callback',
- callback=callback, *no_argnames)
+ parser.add_option(help="unset option set by %s %%default" % (argname,
),
+ action='callback',
+ callback=callback, *no_argnames)
-
+
class IntOption(Option):
opt_type = 'int'
-
+
def __init__(self, name, doc, default=None, cmdline=DEFAULT_OPTION_NAME):
super(IntOption, self).__init__(name, doc, cmdline)
self.default = default
diff --git a/rpython/config/translationoption.py
b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -1,6 +1,6 @@
-import py, os, sys
+import sys
from rpython.config.config import OptionDescription, BoolOption, IntOption,
ArbitraryOption, FloatOption
-from rpython.config.config import ChoiceOption, StrOption, to_optparse, Config
+from rpython.config.config import ChoiceOption, StrOption, Config
from rpython.config.config import ConfigError
from rpython.config.support import detect_number_of_processors
@@ -349,11 +349,6 @@
"""Apply optimization suggestions on the 'config'.
The optimizations depend on the selected level and possibly on the backend.
"""
- # warning: during some tests, the type_system and the backend may be
- # unspecified and we get None. It shouldn't occur in translate.py though.
- type_system = config.translation.type_system
- backend = config.translation.backend
-
try:
opts = OPT_TABLE[level]
except KeyError:
diff --git a/rpython/jit/conftest.py b/rpython/jit/conftest.py
--- a/rpython/jit/conftest.py
+++ b/rpython/jit/conftest.py
@@ -1,8 +1,5 @@
-import py
-
def pytest_addoption(parser):
group = parser.getgroup("JIT options")
group.addoption('--slow', action="store_true",
default=False, dest="run_slow_tests",
help="run all the compiled tests (instead of just a few)")
-
diff --git a/rpython/memory/support.py b/rpython/memory/support.py
--- a/rpython/memory/support.py
+++ b/rpython/memory/support.py
@@ -1,6 +1,5 @@
from rpython.rtyper.lltypesystem import lltype, llmemory
from rpython.rlib.objectmodel import free_non_gc_object, we_are_translated
-from rpython.rlib.rarithmetic import r_uint, LONG_BIT
from rpython.rlib.debug import ll_assert
from rpython.tool.identity_dict import identity_dict
diff --git a/rpython/rtyper/annlowlevel.py b/rpython/rtyper/annlowlevel.py
--- a/rpython/rtyper/annlowlevel.py
+++ b/rpython/rtyper/annlowlevel.py
@@ -4,7 +4,8 @@
from rpython.tool.sourcetools import valid_identifier
from rpython.annotator import model as annmodel
-from rpython.annotator.policy import AnnotatorPolicy, Sig
+from rpython.annotator.policy import AnnotatorPolicy
+from rpython.annotator.signature import Sig
from rpython.annotator.specialize import flatten_star_args
from rpython.rtyper.lltypesystem import lltype, llmemory
from rpython.flowspace.model import Constant
diff --git a/rpython/tool/gcc_cache.py b/rpython/tool/gcc_cache.py
--- a/rpython/tool/gcc_cache.py
+++ b/rpython/tool/gcc_cache.py
@@ -1,5 +1,4 @@
from rpython.translator.platform import CompilationError
-from rpython.translator.tool.cbuild import ExternalCompilationInfo
from rpython.conftest import cache_dir
from hashlib import md5
import py
diff --git a/rpython/tool/runsubprocess.py b/rpython/tool/runsubprocess.py
--- a/rpython/tool/runsubprocess.py
+++ b/rpython/tool/runsubprocess.py
@@ -3,7 +3,8 @@
if the current process already grew very large.
"""
-import sys, gc
+import sys
+import gc
import os
from subprocess import PIPE, Popen
@@ -21,18 +22,18 @@
else:
args = [str(executable)] + args
shell = False
+
# Just before spawning the subprocess, do a gc.collect(). This
# should help if we are running on top of PyPy, if the subprocess
# is going to need a lot of RAM and we are using a lot too.
gc.collect()
- #
+
pipe = Popen(args, stdout=PIPE, stderr=PIPE, shell=shell, env=env, cwd=cwd)
stdout, stderr = pipe.communicate()
return pipe.returncode, stdout, stderr
if __name__ == '__main__':
- import gc
while True:
gc.collect()
operation = sys.stdin.readline()
diff --git a/rpython/tool/udir.py b/rpython/tool/udir.py
--- a/rpython/tool/udir.py
+++ b/rpython/tool/udir.py
@@ -17,8 +17,8 @@
# of the current Mercurial branch.
#
-import os, sys
-import py
+import os
+import sys
from rpython.tool.version import get_repo_version_info
from py.path import local
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit