View
@@ -34,7 +34,7 @@ def debug(msg, *args):
def debug1(msg, *args):
if args:
if args:
msg = msg % args
print(msg, file=sys.stderr)
@@ -50,7 +50,7 @@ class GuestException(Exception):
NOTE: I added this because the host traceback was conflated with the guest
traceback.
"""
def __init__(self, exctype, value, frames):
self.exctype = exctype
if isinstance(value, GuestException):
@@ -952,7 +952,7 @@ def call_function(self, arg, args, kwargs):
defaults, func.func_closure, self)
else:
byterun_func = func
#debug1(' Calling: %s', byterun_func)
retval = byterun_func(*posargs, **namedargs)
self.push(retval)
View
@@ -25,7 +25,7 @@ def abc():
xyz+=1
print("Midst:",xyz)
print "Pre:",xyz
abc()
print "Post:",xyz
View
@@ -141,9 +141,9 @@ def _Walk(obj, cls, ref, syms):
#if obj.__name__ in ('write', 'get', 'Parse'):
# log('OBJ %s %d', obj, id(obj))
# pass
# Oh is the namedtuple_ crap because of the Block class byterun/pyobj?
if module_name is None or module_name in (
'namedtuple_Arguments', 'namedtuple_ArgSpec',
'namedtuple_Block'):
@@ -210,7 +210,7 @@ def _Walk(obj, cls, ref, syms):
elif op == 'LOAD_ATTR':
#if last_val is not None and isinstance(last_val, types.ModuleType):
if last_val is not None:
if last_val is not None:
#log('%s %s', op, var)
val = _GetAttr(last_val, var)
ref.append(var)
@@ -219,7 +219,7 @@ def _Walk(obj, cls, ref, syms):
# methods, which have unique addresses.
# Examples: WAIT_SPEC.Parse, sys.stdout.write
# BUG: os.fork and sys.stdout.write are the same?
# BUG: os.fork and sys.stdout.write are the same?
# I thought os.fork is types.BuiltinFunctionType, and
# sys.stdout.write is types.BuiltinMethodType, but why not?
@@ -407,7 +407,7 @@ def Report(self, f=sys.stdout):
# Still missing: non-enum ASDL types? Why? CompoundObj?
# command_e is there, but command and SimpleCommmand aren't.
# it's because we do
# it's because we do
# ast.command_e vs. ast.SimpleCommand
# in both cases ast is a osh/meta _AsdlModule?
View
@@ -51,7 +51,7 @@ def to_hexstr(bytes_value, level=0, wrap=False):
# TODO: Do this in a cleaner way. Right now I'm avoiding modifying the
# consts module.
def build_flags_def(consts, co_flags_def):
for name in dir(consts):
for name in dir(consts):
if name.startswith('CO_'):
co_flags_def[name] = getattr(consts, name)
View
@@ -166,7 +166,7 @@ def visitIf(self, node):
def visitBreak(self, node):
print('Break')
if not self.setups:
raise SyntaxError("'break' outside loop (%s, %d)" %
raise SyntaxError("'break' outside loop (%s, %d)" %
(self.ctx.filename, node.lineno))
self.set_lineno(node)
@@ -260,7 +260,7 @@ def visitAdd(self, node):
def visitCompare(self, node):
print('Compare')
# I guess this is 1 < x < y < 3
# I guess this is 1 < x < y < 3
self.visit(node.expr)
cleanup = self.newBlock()
for op, code in node.ops[:-1]:
View
@@ -1258,7 +1258,7 @@ def _optimized(self):
return True
def FindLocals(self):
func = self.func
func = self.func
lnf = LocalNameFinder(set(self.func.argnames))
lnf.Dispatch(func.code)
View
@@ -9,7 +9,7 @@
import symtable
from . import symbols
from . import transformer
from . import transformer
def list_eq(l1, l2):
View
@@ -40,7 +40,7 @@ def Init(sym):
Args:
sym: module
The stdlib module is generated from pgen.c's output data. pgen2 derives it
from the grammar directly.
View
@@ -22,7 +22,7 @@ def getPycHeader(filename):
#mtime = os.path.getmtime(filename)
mtime = 0 # to make it deterministic for now
mtime = struct.pack('<i', int(mtime))
return imp.get_magic() + mtime
return imp.get_magic() + mtime
def compileAndWrite(in_path, out_path, compile_func):
View
@@ -1,5 +1,5 @@
#!/usr/bin/python
import sys
import sys
import speed
n = int(sys.argv[1])
View
@@ -253,7 +253,7 @@ def ParseFactor(self):
if not self._Next(): return None
return ast.BoolBinary(op, left, right)
else:
# [[ foo ]]
# [[ foo ]]
w = self.cur_word
if not self._Next(): return None
return ast.WordTest(w)
View
@@ -342,7 +342,7 @@ def IsKeyword(name):
C('|', Id.Lit_Chars),
] + [
# Avoid "unreachable rule error"
(is_regex, pat, re_list) for
(is_regex, pat, re_list) for
(is_regex, pat, re_list) in _UNQUOTED
if not (is_regex == False and pat in ('(', ')', '|'))
]
View
@@ -63,7 +63,7 @@ def __call__(self, lex_mode, line, start_pos):
re_list = self.lexer_def[lex_mode]
return _LongestMatch(re_list, line, start_pos)
def _MatchOshToken_Fast(lex_mode, line, start_pos):
"""Returns (Id, end_pos)."""
View
@@ -930,7 +930,7 @@ def _ReadArrayLiteralPart(self):
return None
if w.tag == word_e.TokenWord:
word_id = word.CommandId(w)
word_id = word.CommandId(w)
if word_id == Id.Right_ArrayLiteral:
break
# Unlike command parsing, array parsing allows embedded \n.
View
@@ -147,7 +147,7 @@ class UndefinedVariable(EvaluationError):
SIMPLE_FUNC, ENHANCED_FUNC = 0, 1
# Templates are a third kind of function, but only for formatters currently
TEMPLATE_FORMATTER = 2
TEMPLATE_FORMATTER = 2
class FunctionRegistry(object):
@@ -212,7 +212,7 @@ def LookupWithType(self, user_str):
class PrefixRegistry(FunctionRegistry):
"""Lookup functions with arguments.
The function name is identified by a prefix. The character after the prefix,
usually a space, is considered the argument delimiter (similar to sed/perl's
s/foo/bar s|foo|bar syntax).
@@ -245,7 +245,7 @@ def Lookup(self, user_str):
class _TemplateRef(object):
"""A reference from one template to another.
The _TemplateRef sits statically in the program tree as one of the formatters.
At runtime, _DoSubstitute calls Resolve() with the group being used.
"""
@@ -745,7 +745,7 @@ def _Reverse(x):
strings too.
"""
return list(reversed(x))
def _Pairs(data):
"""dictionary -> list of pairs"""
@@ -813,7 +813,7 @@ def _Pairs(data):
'js-string': None,
'reverse': _Reverse,
# Given a dictinonary, returns a *list* of key-value pairs. Used for
# section formatters. See jsontemplate_test.py for usage.
#
@@ -1527,7 +1527,7 @@ def tokenstream(self, data_dict):
class Trace(object):
"""Trace of execution for JSON Template.
This object should be passed into the execute/expand() function.
Useful for debugging, especially for templates which reference other
@@ -1582,7 +1582,7 @@ def MakeTemplateGroup(group):
This function *mutates* all the templates, so you shouldn't call it multiple
times on a single Template() instance. It's possible to put a single template
in multiple groups by creating multiple Template() instances from it.
Args:
group: dictionary of template name -> compiled Template instance
"""
@@ -1827,7 +1827,7 @@ def expand_with_style(template, style, data, body_subtree='body'):
Args:
template: Template instance for the inner "page content"
style: Template instance for the outer "page style"
style: Template instance for the outer "page style"
data: Data dictionary, with a 'body' key (or body_subtree
"""
if template.has_defines:
View
@@ -162,7 +162,7 @@ def peek(self):
#
# -- Code is either literal lines, or a commented out code: value.
# code = PLAIN_LINE*
# | '## code:' VALUE
# | '## code:' VALUE
#
# -- Key value pairs can be single- or multi-line
# key_value = '##' KEY ':' VALUE
@@ -173,10 +173,10 @@ def peek(self):
# key_value*
# code
# key_value*
#
#
# -- Should be a blank line after each test case. Leading comments and code
# -- are OK.
# test_file = (COMMENT | PLAIN_LINE)* (test_case '\n')*
# test_file = (COMMENT | PLAIN_LINE)* (test_case '\n')*
def AddMetadataToCase(case, qualifier, shells, name, value):
@@ -258,7 +258,7 @@ def ParseCodeLines(tokens, case):
def ParseTestCase(tokens):
"""Parse a single test case and return it.
If at EOF, return None.
"""
line_num, kind, item = tokens.peek()
@@ -381,7 +381,7 @@ def CreateAssertions(case, sh_label):
# code is 0.
a = EqualAssertion('status', 0)
assertions.append(a)
#print 'SHELL', shell
#pprint.pprint(case)
#print(assertions)
@@ -947,7 +947,7 @@ def main(argv):
return 0
allowed = opts.osh_failures_allowed
all_count = stats['num_failed']
all_count = stats['num_failed']
osh_count = stats['osh_num_failed']
if allowed == 0:
log('')
View
@@ -53,14 +53,14 @@ def testLineIter(self):
types = [type_ for line_num, type_, value in TOKENS1]
self.assertEqual(
[ TEST_CASE_BEGIN, PLAIN_LINE, PLAIN_LINE,
[ TEST_CASE_BEGIN, PLAIN_LINE, PLAIN_LINE,
KEY_VALUE, KEY_VALUE, KEY_VALUE,
EOF], types)
#pprint.pprint(TOKENS2)
types2 = [type_ for line_num, type_, value in TOKENS2]
self.assertEqual(
[ TEST_CASE_BEGIN, PLAIN_LINE, PLAIN_LINE,
[ TEST_CASE_BEGIN, PLAIN_LINE, PLAIN_LINE,
KEY_VALUE, KEY_VALUE,
KEY_VALUE_MULTILINE, PLAIN_LINE, PLAIN_LINE,
KEY_VALUE_MULTILINE, PLAIN_LINE, PLAIN_LINE, END_MULTILINE,
View
@@ -564,7 +564,7 @@ def _ReadTaskFile(path):
with open(raw_base + '__parse.stderr.txt') as f:
st['parse_stderr'] = f.read()
osh2oil_task_path = raw_base + '__osh2oil.task.txt'
st['osh2oil_failed'], st['osh2oil_proc_secs'] = _ReadTaskFile(
osh2oil_task_path)
View
@@ -127,7 +127,7 @@ def _Visit(self, node):
# Should we mark them behind 'sudo'? e.g. "sudo apt install"?
self.progs_used[argv1] = True
elif cls is ast.FuncDef:
self.funcs_defined[node.name] = True
View
@@ -10,7 +10,7 @@
Things it handles:
- table-sort.js integration <colgroup>
- table-sort.js integration <colgroup>
- <table id="foo"> for making columns sortable
- for choosing the comparator to use!
- for highlighting on sort
@@ -140,7 +140,7 @@ def ColumnIndexHasHref(self, index):
def ColumnPrecision(self, index):
col_name = self.col_names[index]
return self.precision_lookup.get(col_name, 1) # default is arbitrary
def PrintRow(row, schema):
"""Print a CSV row as HTML, using the given formatting.
@@ -201,7 +201,7 @@ def PrintRow(row, schema):
s = '<a href="%s">%s</a>' % (cgi.escape(href), cgi.escape(cell_str))
else:
s = cgi.escape(cell_str)
print(s, end=' ')
print('</td>')