diff options
author | Georg Brandl <georg@python.org> | 2008-05-16 17:02:34 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-05-16 17:02:34 (GMT) |
commit | bf82e374ee737992235cbe944c9ddbd58236a892 (patch) | |
tree | f8c8dccaa76d58f9cb7d8cc0abb1355be75ee369 /Tools/framer | |
parent | acbca71ea775fc488bead0876d0cdbd48670dcbc (diff) | |
download | cpython-bf82e374ee737992235cbe944c9ddbd58236a892.zip cpython-bf82e374ee737992235cbe944c9ddbd58236a892.tar.gz cpython-bf82e374ee737992235cbe944c9ddbd58236a892.tar.bz2 |
More 2to3 fixes in the Tools directory. Fixes #2893.
Diffstat (limited to 'Tools/framer')
-rw-r--r-- | Tools/framer/framer/bases.py | 21 | ||||
-rw-r--r-- | Tools/framer/framer/function.py | 8 | ||||
-rw-r--r-- | Tools/framer/framer/struct.py | 2 | ||||
-rw-r--r-- | Tools/framer/framer/structparse.py | 2 |
4 files changed, 14 insertions, 19 deletions
diff --git a/Tools/framer/framer/bases.py b/Tools/framer/framer/bases.py index 99d47d1..d9c99db 100644 --- a/Tools/framer/framer/bases.py +++ b/Tools/framer/framer/bases.py @@ -10,11 +10,6 @@ from framer.util import cstring, unindent from types import FunctionType -def sortitems(dict): - L = dict.items() - L.sort() - return L - # The Module and Type classes are implemented using metaclasses, # because most of the methods are class methods. It is easier to use # metaclasses than the cumbersome classmethod() builtin. They have @@ -32,7 +27,7 @@ class BaseMetaclass(type): if not functions: return p(template.methoddef_start) - for name, func in sortitems(functions): + for name, func in sorted(functions.items()): if func.__doc__: p(template.methoddef_def_doc, func.vars) else: @@ -55,7 +50,7 @@ class ModuleMetaclass(BaseMetaclass): self.__types = {} self.__members = False - for name, obj in self.__dict__.iteritems(): + for name, obj in self.__dict__.items(): if isinstance(obj, FunctionType): self.__functions[name] = Function(obj, self) elif isinstance(obj, TypeMetaclass): @@ -87,16 +82,16 @@ class ModuleMetaclass(BaseMetaclass): if self.__doc__: p(template.module_doc) - for name, type in sortitems(self.__types): + for name, type in sorted(self.__types.items()): type.dump(f) - for name, func in sortitems(self.__functions): + for name, func in sorted(self.__functions.items()): func.dump(f) self.dump_methoddef(f, self.__functions, self.__vars) p(template.module_init_start) - for name, type in sortitems(self.__types): + for name, type in sorted(self.__types.items()): type.dump_init(f) p("}") @@ -119,7 +114,7 @@ class TypeMetaclass(BaseMetaclass): if self.__doc__: p(template.docstring) - for name, func in sortitems(self.__methods): + for name, func in sorted(self.__methods.items()): func.dump(f) self.dump_methoddef(f, self.__methods, self.__vars) @@ -143,7 +138,7 @@ class TypeMetaclass(BaseMetaclass): self.__methods = {} self.__members = {} for cls in self.__mro__: - for k, v in cls.__dict__.iteritems(): + for k, v in cls.__dict__.items(): if isinstance(v, FunctionType): self.__methods[k] = Method(v, self) if isinstance(v, member): @@ -190,7 +185,7 @@ class TypeMetaclass(BaseMetaclass): if not self.__members: return p(template.memberdef_start) - for name, slot in sortitems(self.__members): + for name, slot in sorted(self.__members.items()): slot.dump(f) p(template.memberdef_end) diff --git a/Tools/framer/framer/function.py b/Tools/framer/framer/function.py index 51ef861..f95ea20 100644 --- a/Tools/framer/framer/function.py +++ b/Tools/framer/framer/function.py @@ -45,7 +45,7 @@ class _ArgumentList(object): fmt = None def __init__(self, args): - self.args = map(Argument, args) + self.args = list(map(Argument, args)) def __len__(self): return len(self.args) @@ -99,15 +99,15 @@ class VarArgs(_ArgumentList): print(" %s" % a.decl(), file=f) def ArgumentList(func, method): - code = func.func_code + code = func.__code__ args = code.co_varnames[:code.co_argcount] if method: args = args[1:] pyarg = getattr(func, "pyarg", None) if pyarg is not None: args = VarArgs(args, pyarg) - if func.func_defaults: - L = list(func.func_defaults) + if func.__defaults__: + L = list(func.__defaults__) ndefault = len(L) i = len(args) - ndefault while L: diff --git a/Tools/framer/framer/struct.py b/Tools/framer/framer/struct.py index 1289f24..8fc2aec 100644 --- a/Tools/framer/framer/struct.py +++ b/Tools/framer/framer/struct.py @@ -25,7 +25,7 @@ def parse(s): The parser is very restricted in what it will accept. """ - lines = filter(None, s.split("\n")) # get non-empty lines + lines = [_f for _f in s.split("\n") if _f] # get non-empty lines assert lines[0].strip() == "typedef struct {" pyhead = lines[1].strip() assert (pyhead.startswith("PyObject") and diff --git a/Tools/framer/framer/structparse.py b/Tools/framer/framer/structparse.py index f24c0da..cf4224b 100644 --- a/Tools/framer/framer/structparse.py +++ b/Tools/framer/framer/structparse.py @@ -19,7 +19,7 @@ def parse(s): The parser is very restricted in what it will accept. """ - lines = filter(None, s.split("\n")) # get non-empty lines + lines = [_f for _f in s.split("\n") if _f] # get non-empty lines assert lines[0].strip() == "typedef struct {" pyhead = lines[1].strip() assert (pyhead.startswith("PyObject") and |