Whitespace normalization.
This commit is contained in:
parent
8a57f00081
commit
e0c446bb4a
|
@ -309,7 +309,7 @@ class ConfigParser:
|
||||||
def getboolean(self, section, option):
|
def getboolean(self, section, option):
|
||||||
states = {'1': 1, 'yes': 1, 'true': 1, 'on': 1,
|
states = {'1': 1, 'yes': 1, 'true': 1, 'on': 1,
|
||||||
'0': 0, 'no': 0, 'false': 0, 'off': 0}
|
'0': 0, 'no': 0, 'false': 0, 'off': 0}
|
||||||
v = self.get(section, option)
|
v = self.get(section, option)
|
||||||
if not states.has_key(v.lower()):
|
if not states.has_key(v.lower()):
|
||||||
raise ValueError, 'Not a boolean: %s' % v
|
raise ValueError, 'Not a boolean: %s' % v
|
||||||
return states[v.lower()]
|
return states[v.lower()]
|
||||||
|
|
|
@ -15,7 +15,7 @@ walk(ast, visitor, verbose=None)
|
||||||
See compiler.visitor for details.
|
See compiler.visitor for details.
|
||||||
|
|
||||||
compile(source, filename, mode, flags=None, dont_inherit=None)
|
compile(source, filename, mode, flags=None, dont_inherit=None)
|
||||||
Returns a code object. A replacement for the builtin compile() function.
|
Returns a code object. A replacement for the builtin compile() function.
|
||||||
|
|
||||||
compileFile(filename)
|
compileFile(filename)
|
||||||
Generates a .pyc file by compiling filename.
|
Generates a .pyc file by compiling filename.
|
||||||
|
@ -24,4 +24,3 @@ compileFile(filename)
|
||||||
from transformer import parse, parseFile
|
from transformer import parse, parseFile
|
||||||
from visitor import walk
|
from visitor import walk
|
||||||
from pycodegen import compile, compileFile
|
from pycodegen import compile, compileFile
|
||||||
|
|
||||||
|
|
|
@ -438,7 +438,7 @@ class Function(Node):
|
||||||
self.varargs = 1
|
self.varargs = 1
|
||||||
if flags & CO_VARKEYWORDS:
|
if flags & CO_VARKEYWORDS:
|
||||||
self.kwargs = 1
|
self.kwargs = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getChildren(self):
|
def getChildren(self):
|
||||||
|
|
|
@ -16,7 +16,7 @@ def is_future(stmt):
|
||||||
class FutureParser:
|
class FutureParser:
|
||||||
|
|
||||||
features = ("nested_scopes", "generators", "division")
|
features = ("nested_scopes", "generators", "division")
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.found = {} # set
|
self.found = {} # set
|
||||||
|
|
||||||
|
@ -70,4 +70,3 @@ if __name__ == "__main__":
|
||||||
walk(tree, v)
|
walk(tree, v)
|
||||||
print v.found
|
print v.found
|
||||||
print
|
print
|
||||||
|
|
||||||
|
|
|
@ -72,4 +72,3 @@ def set_filename(filename, tree):
|
||||||
node = worklist.pop(0)
|
node = worklist.pop(0)
|
||||||
node.filename = filename
|
node.filename = filename
|
||||||
worklist.extend(node.getChildNodes())
|
worklist.extend(node.getChildNodes())
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ class FlowGraph:
|
||||||
# these edges to get the blocks emitted in the right order,
|
# these edges to get the blocks emitted in the right order,
|
||||||
# however. :-( If a client needs to remove these edges, call
|
# however. :-( If a client needs to remove these edges, call
|
||||||
# pruneEdges().
|
# pruneEdges().
|
||||||
|
|
||||||
self.current.addNext(block)
|
self.current.addNext(block)
|
||||||
self.startBlock(block)
|
self.startBlock(block)
|
||||||
|
|
||||||
|
@ -110,13 +110,13 @@ class FlowGraph:
|
||||||
|
|
||||||
# XXX This is a total mess. There must be a better way to get
|
# XXX This is a total mess. There must be a better way to get
|
||||||
# the code blocks in the right order.
|
# the code blocks in the right order.
|
||||||
|
|
||||||
self.fixupOrderHonorNext(blocks, default_next)
|
self.fixupOrderHonorNext(blocks, default_next)
|
||||||
self.fixupOrderForward(blocks, default_next)
|
self.fixupOrderForward(blocks, default_next)
|
||||||
|
|
||||||
def fixupOrderHonorNext(self, blocks, default_next):
|
def fixupOrderHonorNext(self, blocks, default_next):
|
||||||
"""Fix one problem with DFS.
|
"""Fix one problem with DFS.
|
||||||
|
|
||||||
The DFS uses child block, but doesn't know about the special
|
The DFS uses child block, but doesn't know about the special
|
||||||
"next" block. As a result, the DFS can order blocks so that a
|
"next" block. As a result, the DFS can order blocks so that a
|
||||||
block isn't next to the right block for implicit control
|
block isn't next to the right block for implicit control
|
||||||
|
@ -200,14 +200,14 @@ class FlowGraph:
|
||||||
for c in chains:
|
for c in chains:
|
||||||
for b in c:
|
for b in c:
|
||||||
blocks.append(b)
|
blocks.append(b)
|
||||||
|
|
||||||
def getBlocks(self):
|
def getBlocks(self):
|
||||||
return self.blocks.elements()
|
return self.blocks.elements()
|
||||||
|
|
||||||
def getRoot(self):
|
def getRoot(self):
|
||||||
"""Return nodes appropriate for use with dominator"""
|
"""Return nodes appropriate for use with dominator"""
|
||||||
return self.entry
|
return self.entry
|
||||||
|
|
||||||
def getContainedGraphs(self):
|
def getContainedGraphs(self):
|
||||||
l = []
|
l = []
|
||||||
for b in self.getBlocks():
|
for b in self.getBlocks():
|
||||||
|
@ -246,7 +246,7 @@ class Block:
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
insts = map(str, self.insts)
|
insts = map(str, self.insts)
|
||||||
return "<block %s %d:\n%s>" % (self.label, self.bid,
|
return "<block %s %d:\n%s>" % (self.label, self.bid,
|
||||||
string.join(insts, '\n'))
|
string.join(insts, '\n'))
|
||||||
|
|
||||||
def emit(self, inst):
|
def emit(self, inst):
|
||||||
op = inst[0]
|
op = inst[0]
|
||||||
|
@ -331,7 +331,7 @@ class PyFlowGraph(FlowGraph):
|
||||||
self.argcount = getArgCount(args)
|
self.argcount = getArgCount(args)
|
||||||
self.klass = klass
|
self.klass = klass
|
||||||
if optimized:
|
if optimized:
|
||||||
self.flags = CO_OPTIMIZED | CO_NEWLOCALS
|
self.flags = CO_OPTIMIZED | CO_NEWLOCALS
|
||||||
else:
|
else:
|
||||||
self.flags = 0
|
self.flags = 0
|
||||||
self.consts = []
|
self.consts = []
|
||||||
|
@ -567,7 +567,7 @@ class PyFlowGraph(FlowGraph):
|
||||||
for name, obj in locals().items():
|
for name, obj in locals().items():
|
||||||
if name[:9] == "_convert_":
|
if name[:9] == "_convert_":
|
||||||
opname = name[9:]
|
opname = name[9:]
|
||||||
_converters[opname] = obj
|
_converters[opname] = obj
|
||||||
del name, obj, opname
|
del name, obj, opname
|
||||||
|
|
||||||
def makeByteCode(self):
|
def makeByteCode(self):
|
||||||
|
@ -623,7 +623,7 @@ class PyFlowGraph(FlowGraph):
|
||||||
elt = elt.getCode()
|
elt = elt.getCode()
|
||||||
l.append(elt)
|
l.append(elt)
|
||||||
return tuple(l)
|
return tuple(l)
|
||||||
|
|
||||||
def isJump(opname):
|
def isJump(opname):
|
||||||
if opname[:4] == 'JUMP':
|
if opname[:4] == 'JUMP':
|
||||||
return 1
|
return 1
|
||||||
|
@ -654,7 +654,7 @@ def twobyte(val):
|
||||||
|
|
||||||
class LineAddrTable:
|
class LineAddrTable:
|
||||||
"""lnotab
|
"""lnotab
|
||||||
|
|
||||||
This class builds the lnotab, which is documented in compile.c.
|
This class builds the lnotab, which is documented in compile.c.
|
||||||
Here's a brief recap:
|
Here's a brief recap:
|
||||||
|
|
||||||
|
@ -717,7 +717,7 @@ class LineAddrTable:
|
||||||
|
|
||||||
def getTable(self):
|
def getTable(self):
|
||||||
return string.join(map(chr, self.lnotab), '')
|
return string.join(map(chr, self.lnotab), '')
|
||||||
|
|
||||||
class StackDepthTracker:
|
class StackDepthTracker:
|
||||||
# XXX 1. need to keep track of stack depth on jumps
|
# XXX 1. need to keep track of stack depth on jumps
|
||||||
# XXX 2. at least partly as a result, this code is broken
|
# XXX 2. at least partly as a result, this code is broken
|
||||||
|
@ -792,7 +792,7 @@ class StackDepthTracker:
|
||||||
('BINARY_', -1),
|
('BINARY_', -1),
|
||||||
('LOAD_', 1),
|
('LOAD_', 1),
|
||||||
]
|
]
|
||||||
|
|
||||||
def UNPACK_SEQUENCE(self, count):
|
def UNPACK_SEQUENCE(self, count):
|
||||||
return count-1
|
return count-1
|
||||||
def BUILD_TUPLE(self, count):
|
def BUILD_TUPLE(self, count):
|
||||||
|
@ -820,5 +820,5 @@ class StackDepthTracker:
|
||||||
return -2
|
return -2
|
||||||
def DUP_TOPX(self, argc):
|
def DUP_TOPX(self, argc):
|
||||||
return argc
|
return argc
|
||||||
|
|
||||||
findDepth = StackDepthTracker().findDepth
|
findDepth = StackDepthTracker().findDepth
|
||||||
|
|
|
@ -36,7 +36,7 @@ END_FINALLY = 4
|
||||||
|
|
||||||
class BlockStack(misc.Stack):
|
class BlockStack(misc.Stack):
|
||||||
__super_init = misc.Stack.__init__
|
__super_init = misc.Stack.__init__
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.__super_init(self)
|
self.__super_init(self)
|
||||||
self.loop = None
|
self.loop = None
|
||||||
|
@ -59,7 +59,7 @@ def compile(source, filename, mode, flags=None, dont_inherit=None):
|
||||||
"""Replacement for builtin compile() function"""
|
"""Replacement for builtin compile() function"""
|
||||||
if flags is not None or dont_inherit is not None:
|
if flags is not None or dont_inherit is not None:
|
||||||
raise RuntimeError, "not implemented yet"
|
raise RuntimeError, "not implemented yet"
|
||||||
|
|
||||||
if mode == "single":
|
if mode == "single":
|
||||||
gen = Interactive(source, filename)
|
gen = Interactive(source, filename)
|
||||||
elif mode == "exec":
|
elif mode == "exec":
|
||||||
|
@ -198,7 +198,7 @@ class CodeGenerator:
|
||||||
NameFinder, FunctionGen, and ClassGen. These attributes can be
|
NameFinder, FunctionGen, and ClassGen. These attributes can be
|
||||||
defined in the initClass() method, which is a hook for
|
defined in the initClass() method, which is a hook for
|
||||||
initializing these methods after all the classes have been
|
initializing these methods after all the classes have been
|
||||||
defined.
|
defined.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
optimized = 0 # is namespace access optimized?
|
optimized = 0 # is namespace access optimized?
|
||||||
|
@ -312,7 +312,7 @@ class CodeGenerator:
|
||||||
self.emit(prefix + '_NAME', name)
|
self.emit(prefix + '_NAME', name)
|
||||||
|
|
||||||
def set_lineno(self, node, force=0):
|
def set_lineno(self, node, force=0):
|
||||||
"""Emit SET_LINENO if node has lineno attribute and it is
|
"""Emit SET_LINENO if node has lineno attribute and it is
|
||||||
different than the last lineno emitted.
|
different than the last lineno emitted.
|
||||||
|
|
||||||
Returns true if SET_LINENO was emitted.
|
Returns true if SET_LINENO was emitted.
|
||||||
|
@ -513,7 +513,7 @@ class CodeGenerator:
|
||||||
self.emit('CONTINUE_LOOP', loop_block)
|
self.emit('CONTINUE_LOOP', loop_block)
|
||||||
self.nextBlock()
|
self.nextBlock()
|
||||||
elif kind == END_FINALLY:
|
elif kind == END_FINALLY:
|
||||||
msg = "'continue' not allowed inside 'finally' clause (%s, %d)"
|
msg = "'continue' not allowed inside 'finally' clause (%s, %d)"
|
||||||
raise SyntaxError, msg % (node.filename, node.lineno)
|
raise SyntaxError, msg % (node.filename, node.lineno)
|
||||||
|
|
||||||
def visitTest(self, node, jump):
|
def visitTest(self, node, jump):
|
||||||
|
@ -558,7 +558,7 @@ class CodeGenerator:
|
||||||
|
|
||||||
# list comprehensions
|
# list comprehensions
|
||||||
__list_count = 0
|
__list_count = 0
|
||||||
|
|
||||||
def visitListComp(self, node):
|
def visitListComp(self, node):
|
||||||
self.set_lineno(node)
|
self.set_lineno(node)
|
||||||
# setup list
|
# setup list
|
||||||
|
@ -568,7 +568,7 @@ class CodeGenerator:
|
||||||
self.emit('DUP_TOP')
|
self.emit('DUP_TOP')
|
||||||
self.emit('LOAD_ATTR', 'append')
|
self.emit('LOAD_ATTR', 'append')
|
||||||
self._implicitNameOp('STORE', append)
|
self._implicitNameOp('STORE', append)
|
||||||
|
|
||||||
stack = []
|
stack = []
|
||||||
for i, for_ in zip(range(len(node.quals)), node.quals):
|
for i, for_ in zip(range(len(node.quals)), node.quals):
|
||||||
start, anchor = self.visit(for_)
|
start, anchor = self.visit(for_)
|
||||||
|
@ -583,7 +583,7 @@ class CodeGenerator:
|
||||||
self.visit(node.expr)
|
self.visit(node.expr)
|
||||||
self.emit('CALL_FUNCTION', 1)
|
self.emit('CALL_FUNCTION', 1)
|
||||||
self.emit('POP_TOP')
|
self.emit('POP_TOP')
|
||||||
|
|
||||||
for start, cont, anchor in stack:
|
for start, cont, anchor in stack:
|
||||||
if cont:
|
if cont:
|
||||||
skip_one = self.newBlock()
|
skip_one = self.newBlock()
|
||||||
|
@ -594,7 +594,7 @@ class CodeGenerator:
|
||||||
self.emit('JUMP_ABSOLUTE', start)
|
self.emit('JUMP_ABSOLUTE', start)
|
||||||
self.startBlock(anchor)
|
self.startBlock(anchor)
|
||||||
self._implicitNameOp('DELETE', append)
|
self._implicitNameOp('DELETE', append)
|
||||||
|
|
||||||
self.__list_count = self.__list_count - 1
|
self.__list_count = self.__list_count - 1
|
||||||
|
|
||||||
def visitListCompFor(self, node):
|
def visitListCompFor(self, node):
|
||||||
|
@ -675,7 +675,7 @@ class CodeGenerator:
|
||||||
self.setups.pop()
|
self.setups.pop()
|
||||||
self.emit('JUMP_FORWARD', lElse)
|
self.emit('JUMP_FORWARD', lElse)
|
||||||
self.startBlock(handlers)
|
self.startBlock(handlers)
|
||||||
|
|
||||||
last = len(node.handlers) - 1
|
last = len(node.handlers) - 1
|
||||||
for i in range(len(node.handlers)):
|
for i in range(len(node.handlers)):
|
||||||
expr, target, body = node.handlers[i]
|
expr, target, body = node.handlers[i]
|
||||||
|
@ -707,7 +707,7 @@ class CodeGenerator:
|
||||||
self.nextBlock(lElse)
|
self.nextBlock(lElse)
|
||||||
self.visit(node.else_)
|
self.visit(node.else_)
|
||||||
self.nextBlock(end)
|
self.nextBlock(end)
|
||||||
|
|
||||||
def visitTryFinally(self, node):
|
def visitTryFinally(self, node):
|
||||||
body = self.newBlock()
|
body = self.newBlock()
|
||||||
final = self.newBlock()
|
final = self.newBlock()
|
||||||
|
@ -746,7 +746,7 @@ class CodeGenerator:
|
||||||
def visitName(self, node):
|
def visitName(self, node):
|
||||||
self.set_lineno(node)
|
self.set_lineno(node)
|
||||||
self.loadName(node.name)
|
self.loadName(node.name)
|
||||||
|
|
||||||
def visitPass(self, node):
|
def visitPass(self, node):
|
||||||
self.set_lineno(node)
|
self.set_lineno(node)
|
||||||
|
|
||||||
|
@ -1139,7 +1139,7 @@ class ModuleCodeGenerator(NestedScopeMixin, CodeGenerator):
|
||||||
__super_init = CodeGenerator.__init__
|
__super_init = CodeGenerator.__init__
|
||||||
|
|
||||||
scopes = None
|
scopes = None
|
||||||
|
|
||||||
def __init__(self, tree):
|
def __init__(self, tree):
|
||||||
self.graph = pyassem.PyFlowGraph("<module>", tree.filename)
|
self.graph = pyassem.PyFlowGraph("<module>", tree.filename)
|
||||||
self.futures = future.find_futures(tree)
|
self.futures = future.find_futures(tree)
|
||||||
|
@ -1154,7 +1154,7 @@ class ExpressionCodeGenerator(NestedScopeMixin, CodeGenerator):
|
||||||
|
|
||||||
scopes = None
|
scopes = None
|
||||||
futures = ()
|
futures = ()
|
||||||
|
|
||||||
def __init__(self, tree):
|
def __init__(self, tree):
|
||||||
self.graph = pyassem.PyFlowGraph("<expression>", tree.filename)
|
self.graph = pyassem.PyFlowGraph("<expression>", tree.filename)
|
||||||
self.__super_init()
|
self.__super_init()
|
||||||
|
@ -1171,7 +1171,7 @@ class InteractiveCodeGenerator(NestedScopeMixin, CodeGenerator):
|
||||||
|
|
||||||
scopes = None
|
scopes = None
|
||||||
futures = ()
|
futures = ()
|
||||||
|
|
||||||
def __init__(self, tree):
|
def __init__(self, tree):
|
||||||
self.graph = pyassem.PyFlowGraph("<interactive>", tree.filename)
|
self.graph = pyassem.PyFlowGraph("<interactive>", tree.filename)
|
||||||
self.__super_init()
|
self.__super_init()
|
||||||
|
@ -1201,8 +1201,8 @@ class AbstractFunctionCode:
|
||||||
else:
|
else:
|
||||||
name = func.name
|
name = func.name
|
||||||
args, hasTupleArg = generateArgList(func.argnames)
|
args, hasTupleArg = generateArgList(func.argnames)
|
||||||
self.graph = pyassem.PyFlowGraph(name, func.filename, args,
|
self.graph = pyassem.PyFlowGraph(name, func.filename, args,
|
||||||
optimized=1)
|
optimized=1)
|
||||||
self.isLambda = isLambda
|
self.isLambda = isLambda
|
||||||
self.super_init()
|
self.super_init()
|
||||||
|
|
||||||
|
@ -1234,7 +1234,7 @@ class AbstractFunctionCode:
|
||||||
if type(arg) == types.TupleType:
|
if type(arg) == types.TupleType:
|
||||||
self.emit('LOAD_FAST', '.%d' % (i * 2))
|
self.emit('LOAD_FAST', '.%d' % (i * 2))
|
||||||
self.unpackSequence(arg)
|
self.unpackSequence(arg)
|
||||||
|
|
||||||
def unpackSequence(self, tup):
|
def unpackSequence(self, tup):
|
||||||
if VERSION > 1:
|
if VERSION > 1:
|
||||||
self.emit('UNPACK_SEQUENCE', len(tup))
|
self.emit('UNPACK_SEQUENCE', len(tup))
|
||||||
|
@ -1249,7 +1249,7 @@ class AbstractFunctionCode:
|
||||||
unpackTuple = unpackSequence
|
unpackTuple = unpackSequence
|
||||||
|
|
||||||
class FunctionCodeGenerator(NestedScopeMixin, AbstractFunctionCode,
|
class FunctionCodeGenerator(NestedScopeMixin, AbstractFunctionCode,
|
||||||
CodeGenerator):
|
CodeGenerator):
|
||||||
super_init = CodeGenerator.__init__ # call be other init
|
super_init = CodeGenerator.__init__ # call be other init
|
||||||
scopes = None
|
scopes = None
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ class Scope:
|
||||||
rather than free.
|
rather than free.
|
||||||
|
|
||||||
Be careful to stop if a child does not think the name is
|
Be careful to stop if a child does not think the name is
|
||||||
free.
|
free.
|
||||||
"""
|
"""
|
||||||
self.globals[name] = 1
|
self.globals[name] = 1
|
||||||
if self.frees.has_key(name):
|
if self.frees.has_key(name):
|
||||||
|
@ -172,7 +172,7 @@ class Scope:
|
||||||
|
|
||||||
class ModuleScope(Scope):
|
class ModuleScope(Scope):
|
||||||
__super_init = Scope.__init__
|
__super_init = Scope.__init__
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.__super_init("global", self)
|
self.__super_init("global", self)
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ class LambdaScope(FunctionScope):
|
||||||
__super_init = Scope.__init__
|
__super_init = Scope.__init__
|
||||||
|
|
||||||
__counter = 1
|
__counter = 1
|
||||||
|
|
||||||
def __init__(self, module, klass=None):
|
def __init__(self, module, klass=None):
|
||||||
i = self.__counter
|
i = self.__counter
|
||||||
self.__counter += 1
|
self.__counter += 1
|
||||||
|
@ -199,7 +199,7 @@ class SymbolVisitor:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.scopes = {}
|
self.scopes = {}
|
||||||
self.klass = None
|
self.klass = None
|
||||||
|
|
||||||
# node that define new scopes
|
# node that define new scopes
|
||||||
|
|
||||||
def visitModule(self, node):
|
def visitModule(self, node):
|
||||||
|
@ -217,7 +217,7 @@ class SymbolVisitor:
|
||||||
self._do_args(scope, node.argnames)
|
self._do_args(scope, node.argnames)
|
||||||
self.visit(node.code, scope)
|
self.visit(node.code, scope)
|
||||||
self.handle_free_vars(scope, parent)
|
self.handle_free_vars(scope, parent)
|
||||||
|
|
||||||
def visitLambda(self, node, parent):
|
def visitLambda(self, node, parent):
|
||||||
for n in node.defaults:
|
for n in node.defaults:
|
||||||
self.visit(n, parent)
|
self.visit(n, parent)
|
||||||
|
@ -326,7 +326,7 @@ class SymbolVisitor:
|
||||||
self.visit(node.lower, scope, 0)
|
self.visit(node.lower, scope, 0)
|
||||||
if node.upper:
|
if node.upper:
|
||||||
self.visit(node.upper, scope, 0)
|
self.visit(node.upper, scope, 0)
|
||||||
|
|
||||||
def visitAugAssign(self, node, scope):
|
def visitAugAssign(self, node, scope):
|
||||||
# If the LHS is a name, then this counts as assignment.
|
# If the LHS is a name, then this counts as assignment.
|
||||||
# Otherwise, it's just use.
|
# Otherwise, it's just use.
|
||||||
|
@ -371,8 +371,8 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
def get_names(syms):
|
def get_names(syms):
|
||||||
return [s for s in [s.get_name() for s in syms.get_symbols()]
|
return [s for s in [s.get_name() for s in syms.get_symbols()]
|
||||||
if not (s.startswith('_[') or s.startswith('.'))]
|
if not (s.startswith('_[') or s.startswith('.'))]
|
||||||
|
|
||||||
for file in sys.argv[1:]:
|
for file in sys.argv[1:]:
|
||||||
print file
|
print file
|
||||||
f = open(file)
|
f = open(file)
|
||||||
|
|
|
@ -692,14 +692,14 @@ class Transformer:
|
||||||
n = Backquote(self.com_node(nodelist[1]))
|
n = Backquote(self.com_node(nodelist[1]))
|
||||||
n.lineno = nodelist[0][2]
|
n.lineno = nodelist[0][2]
|
||||||
return n
|
return n
|
||||||
|
|
||||||
def atom_number(self, nodelist):
|
def atom_number(self, nodelist):
|
||||||
### need to verify this matches compile.c
|
### need to verify this matches compile.c
|
||||||
k = eval(nodelist[0][1])
|
k = eval(nodelist[0][1])
|
||||||
n = Const(k)
|
n = Const(k)
|
||||||
n.lineno = nodelist[0][2]
|
n.lineno = nodelist[0][2]
|
||||||
return n
|
return n
|
||||||
|
|
||||||
def atom_string(self, nodelist):
|
def atom_string(self, nodelist):
|
||||||
### need to verify this matches compile.c
|
### need to verify this matches compile.c
|
||||||
k = ''
|
k = ''
|
||||||
|
@ -743,7 +743,7 @@ class Transformer:
|
||||||
# here, Render it harmless. (genc discards ('discard',
|
# here, Render it harmless. (genc discards ('discard',
|
||||||
# ('const', xxxx)) Nodes)
|
# ('const', xxxx)) Nodes)
|
||||||
return Discard(Const(None))
|
return Discard(Const(None))
|
||||||
|
|
||||||
def com_arglist(self, nodelist):
|
def com_arglist(self, nodelist):
|
||||||
# varargslist:
|
# varargslist:
|
||||||
# (fpdef ['=' test] ',')* ('*' NAME [',' ('**'|'*' '*') NAME]
|
# (fpdef ['=' test] ',')* ('*' NAME [',' ('**'|'*' '*') NAME]
|
||||||
|
@ -805,7 +805,7 @@ class Transformer:
|
||||||
return node[1][1]
|
return node[1][1]
|
||||||
|
|
||||||
def com_fplist(self, node):
|
def com_fplist(self, node):
|
||||||
# fplist: fpdef (',' fpdef)* [',']
|
# fplist: fpdef (',' fpdef)* [',']
|
||||||
if len(node) == 2:
|
if len(node) == 2:
|
||||||
return self.com_fpdef(node[1])
|
return self.com_fpdef(node[1])
|
||||||
list = []
|
list = []
|
||||||
|
@ -854,7 +854,7 @@ class Transformer:
|
||||||
def com_try_finally(self, nodelist):
|
def com_try_finally(self, nodelist):
|
||||||
# try_fin_stmt: "try" ":" suite "finally" ":" suite
|
# try_fin_stmt: "try" ":" suite "finally" ":" suite
|
||||||
n = TryFinally(self.com_node(nodelist[2]),
|
n = TryFinally(self.com_node(nodelist[2]),
|
||||||
self.com_node(nodelist[5]))
|
self.com_node(nodelist[5]))
|
||||||
n.lineno = nodelist[0][2]
|
n.lineno = nodelist[0][2]
|
||||||
return n
|
return n
|
||||||
|
|
||||||
|
@ -922,7 +922,7 @@ class Transformer:
|
||||||
raise SyntaxError, "can't assign to operator"
|
raise SyntaxError, "can't assign to operator"
|
||||||
primary = self.com_apply_trailer(primary, ch)
|
primary = self.com_apply_trailer(primary, ch)
|
||||||
return self.com_assign_trailer(primary, node[-1],
|
return self.com_assign_trailer(primary, node[-1],
|
||||||
assigning)
|
assigning)
|
||||||
node = node[1]
|
node = node[1]
|
||||||
elif t == symbol.atom:
|
elif t == symbol.atom:
|
||||||
t = node[1][0]
|
t = node[1][0]
|
||||||
|
@ -1023,7 +1023,7 @@ class Transformer:
|
||||||
# list_if: 'if' test [list_iter]
|
# list_if: 'if' test [list_iter]
|
||||||
|
|
||||||
# XXX should raise SyntaxError for assignment
|
# XXX should raise SyntaxError for assignment
|
||||||
|
|
||||||
lineno = node[1][2]
|
lineno = node[1][2]
|
||||||
fors = []
|
fors = []
|
||||||
while node:
|
while node:
|
||||||
|
@ -1100,7 +1100,7 @@ class Transformer:
|
||||||
for i in range(1, len_nodelist, 2):
|
for i in range(1, len_nodelist, 2):
|
||||||
node = nodelist[i]
|
node = nodelist[i]
|
||||||
if node[0] == token.STAR or node[0] == token.DOUBLESTAR:
|
if node[0] == token.STAR or node[0] == token.DOUBLESTAR:
|
||||||
break
|
break
|
||||||
kw, result = self.com_argument(node, kw)
|
kw, result = self.com_argument(node, kw)
|
||||||
args.append(result)
|
args.append(result)
|
||||||
else:
|
else:
|
||||||
|
@ -1145,7 +1145,7 @@ class Transformer:
|
||||||
def com_subscriptlist(self, primary, nodelist, assigning):
|
def com_subscriptlist(self, primary, nodelist, assigning):
|
||||||
# slicing: simple_slicing | extended_slicing
|
# slicing: simple_slicing | extended_slicing
|
||||||
# simple_slicing: primary "[" short_slice "]"
|
# simple_slicing: primary "[" short_slice "]"
|
||||||
# extended_slicing: primary "[" slice_list "]"
|
# extended_slicing: primary "[" slice_list "]"
|
||||||
# slice_list: slice_item ("," slice_item)* [","]
|
# slice_list: slice_item ("," slice_item)* [","]
|
||||||
|
|
||||||
# backwards compat slice for '[i:j]'
|
# backwards compat slice for '[i:j]'
|
||||||
|
|
|
@ -78,7 +78,7 @@ class ExampleASTVisitor(ASTVisitor):
|
||||||
you still have to do.
|
you still have to do.
|
||||||
"""
|
"""
|
||||||
examples = {}
|
examples = {}
|
||||||
|
|
||||||
def dispatch(self, node, *args):
|
def dispatch(self, node, *args):
|
||||||
self.node = node
|
self.node = node
|
||||||
meth = self._cache.get(node.__class__, None)
|
meth = self._cache.get(node.__class__, None)
|
||||||
|
|
|
@ -75,7 +75,7 @@ BINDATA = ']q\x01(K\x00L1L\nG@\x00\x00\x00\x00\x00\x00\x00' + \
|
||||||
'\x00\x80J\x00\x00\x00\x80(U\x03abcq\x04h\x04(c__main__\n' + \
|
'\x00\x80J\x00\x00\x00\x80(U\x03abcq\x04h\x04(c__main__\n' + \
|
||||||
'C\nq\x05oq\x06}q\x07(U\x03fooq\x08K\x01U\x03barq\tK\x02ubh' + \
|
'C\nq\x05oq\x06}q\x07(U\x03fooq\x08K\x01U\x03barq\tK\x02ubh' + \
|
||||||
'\x06tq\nh\nK\x05e.'
|
'\x06tq\nh\nK\x05e.'
|
||||||
|
|
||||||
def create_data():
|
def create_data():
|
||||||
c = C()
|
c = C()
|
||||||
c.foo = 1
|
c.foo = 1
|
||||||
|
|
|
@ -199,7 +199,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
|
||||||
good.sort()
|
good.sort()
|
||||||
bad.sort()
|
bad.sort()
|
||||||
skipped.sort()
|
skipped.sort()
|
||||||
|
|
||||||
if good and not quiet:
|
if good and not quiet:
|
||||||
if not bad and not skipped and len(good) > 1:
|
if not bad and not skipped and len(good) > 1:
|
||||||
print "All",
|
print "All",
|
||||||
|
|
|
@ -113,4 +113,3 @@ else:
|
||||||
|
|
||||||
# Verify the treatment of Unicode strings
|
# Verify the treatment of Unicode strings
|
||||||
verify(binascii.hexlify(u'a') == '61', "hexlify failed for Unicode")
|
verify(binascii.hexlify(u'a') == '61', "hexlify failed for Unicode")
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ from pickletester import AbstractPickleTests, AbstractPickleModuleTests
|
||||||
from test_support import run_unittest
|
from test_support import run_unittest
|
||||||
|
|
||||||
class cPickleTests(AbstractPickleTests, AbstractPickleModuleTests):
|
class cPickleTests(AbstractPickleTests, AbstractPickleModuleTests):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.dumps = cPickle.dumps
|
self.dumps = cPickle.dumps
|
||||||
self.loads = cPickle.loads
|
self.loads = cPickle.loads
|
||||||
|
|
|
@ -291,7 +291,7 @@ class TestLongHeaders(unittest.TestCase):
|
||||||
self.assertEqual(sfp.getvalue(), """\
|
self.assertEqual(sfp.getvalue(), """\
|
||||||
From: test@dom.ain
|
From: test@dom.ain
|
||||||
References: <0@dom.ain> <1@dom.ain> <2@dom.ain> <3@dom.ain> <4@dom.ain>
|
References: <0@dom.ain> <1@dom.ain> <2@dom.ain> <3@dom.ain> <4@dom.ain>
|
||||||
<5@dom.ain> <6@dom.ain> <7@dom.ain> <8@dom.ain> <9@dom.ain>
|
\t<5@dom.ain> <6@dom.ain> <7@dom.ain> <8@dom.ain> <9@dom.ain>
|
||||||
|
|
||||||
Test""")
|
Test""")
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ class StatAttributeTests(unittest.TestCase):
|
||||||
f = open(self.fname, 'wb')
|
f = open(self.fname, 'wb')
|
||||||
f.write("ABC")
|
f.write("ABC")
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
os.unlink(self.fname)
|
os.unlink(self.fname)
|
||||||
os.rmdir(TESTFN)
|
os.rmdir(TESTFN)
|
||||||
|
@ -133,7 +133,7 @@ class StatAttributeTests(unittest.TestCase):
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_statvfs_attributes(self):
|
def test_statvfs_attributes(self):
|
||||||
if not hasattr(os, "statvfs"):
|
if not hasattr(os, "statvfs"):
|
||||||
return
|
return
|
||||||
|
|
|
@ -8,7 +8,7 @@ class PickleTests(AbstractPickleTests, AbstractPickleModuleTests):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.dumps = pickle.dumps
|
self.dumps = pickle.dumps
|
||||||
self.loads = pickle.loads
|
self.loads = pickle.loads
|
||||||
|
|
||||||
module = pickle
|
module = pickle
|
||||||
error = KeyError
|
error = KeyError
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,3 @@ socket.RAND_add("this is a random string", 75.0)
|
||||||
f = urllib.urlopen('https://sf.net')
|
f = urllib.urlopen('https://sf.net')
|
||||||
buf = f.read()
|
buf = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ if decomp2 != buf:
|
||||||
print "max_length decompressobj failed"
|
print "max_length decompressobj failed"
|
||||||
else:
|
else:
|
||||||
print "max_length decompressobj succeeded"
|
print "max_length decompressobj succeeded"
|
||||||
|
|
||||||
# Misc tests of max_length
|
# Misc tests of max_length
|
||||||
deco = zlib.decompressobj(-12)
|
deco = zlib.decompressobj(-12)
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue