Skip to content

Commit

Permalink
Lint and administrivia
Browse files Browse the repository at this point in the history
lint various files
add 2.3 in Makefiles to handle pyston-3.8-2.3.3
  • Loading branch information
rocky committed May 20, 2022
1 parent 02fd3fa commit 4a61f5d
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 36 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ check-3.9 check-3.10: pytest
#: pypy3.8-7.3.7
7.3:

#: pyston 3.8-2.3.3
2.3:

#: Run py.test tests
pytest:
$(MAKE) -C pytest check
Expand Down
3 changes: 2 additions & 1 deletion admin-tools/check-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ for version in $PYVERSIONS; do
exit $?
fi
make clean && pip install -e .
if ! make check; then
# if ! remake -! check; then
if make check; then
exit $?
fi
echo === $version ===
Expand Down
2 changes: 1 addition & 1 deletion admin-tools/pyenv-versions
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
echo "This script should be *sourced* rather than run directly through bash"
exit 1
fi
export PYVERSIONS='3.7.12 pyston-2.3 3.8.12'
export PYVERSIONS='pyston-2.3.3 3.7.13 3.8.13'
4 changes: 1 addition & 3 deletions decompyle3/bin/decompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ def process_func():
f = fqueue.get()
if f is None:
break
(t, o, f, v) = main(
src_base, out_base, [f], None, outfile, **options
)
(t, o, f, v) = main(src_base, out_base, [f], None, outfile)
tot_files += t
okay_files += o
failed_files += f
Expand Down
4 changes: 2 additions & 2 deletions decompyle3/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,14 @@ def main(
try:
# FIXME: Something is weird with Pypy here
sys.stdout.flush()
except:
except Exception:
pass
if current_outfile:
sys.stdout.write("\n")
try:
# FIXME: Something is weird with Pypy here
sys.stdout.flush()
except:
except Exception:
pass
pass
return (tot_files, okay_files, failed_files, verify_failed_files)
Expand Down
2 changes: 1 addition & 1 deletion decompyle3/parsers/p37/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ def reduce_is_invalid(self, rule, ast, tokens, first, last):
try:
if fn:
return fn(self, lhs, n, rule, ast, tokens, first, last)
except:
except Exception:
import sys, traceback

print(
Expand Down
2 changes: 1 addition & 1 deletion decompyle3/parsers/p38/full.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def reduce_is_invalid(self, rule, ast, tokens, first, last):
try:
if fn:
return fn(self, lhs, n, rule, ast, tokens, first, last)
except:
except Exception:
import sys, traceback

print(
Expand Down
8 changes: 3 additions & 5 deletions decompyle3/parsers/parse_heads.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

from decompyle3.parsers.treenode import SyntaxTree
from spark_parser import GenericASTBuilder
from typing import Union


def nop_func(self, args):
Expand Down Expand Up @@ -103,11 +104,8 @@ def __init__(self, debug_parser, start_symbol, is_lambda=False):
self.start_symbol = start_symbol
self.new_rules = set()

def ast_first_offset(self, ast):
if hasattr(ast, "offset"):
return ast.offset
else:
return self.ast_first_offset(ast[0])
def ast_first_offset(self, ast) -> Union[int, str]:
return ast.offset if hasattr(ast, "offset") else self.ast_first_offset(ast[0])

def add_unique_rule(
self, rule, opname: str, arg_count: int, customize: dict
Expand Down
18 changes: 14 additions & 4 deletions decompyle3/parsers/reduce_check/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

from decompyle3.parsers.reduce_check.and_check import and_check
from decompyle3.parsers.reduce_check.and_cond_check import and_cond_check
from decompyle3.parsers.reduce_check.and_not_check import *
from decompyle3.parsers.reduce_check.and_not_check import and_not_check
from decompyle3.parsers.reduce_check.break38 import break_check
from decompyle3.parsers.reduce_check.if_and_stmt import *
from decompyle3.parsers.reduce_check.if_and_stmt import if_and_stmt
from decompyle3.parsers.reduce_check.if_and_elsestmt import *
from decompyle3.parsers.reduce_check.ifelsestmt import *
from decompyle3.parsers.reduce_check.ifelsestmt import ifelsestmt
from decompyle3.parsers.reduce_check.iflaststmt import *
from decompyle3.parsers.reduce_check.ifstmt import *
from decompyle3.parsers.reduce_check.ifstmts_jump import *
Expand All @@ -35,4 +35,14 @@
from decompyle3.parsers.reduce_check.whileTruestmt38 import *


__all__ = ["break_check", "for38_check", "pop_return_check", "whilestmt38_check"]
__all__ = [
"and_check",
"and_cond_check",
"and_not_check",
"break_check",
"for38_check",
"if_and_stmt",
"ifelsestmt",
"pop_return_check",
"whilestmt38_check",
]
1 change: 0 additions & 1 deletion decompyle3/parsers/reduce_check/and_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def and_check(
else:
# Probably not needed: was expr POP_JUMP_IF_FALSE
jump = ast[1]
have_expr_jifpop = True

if jump.kind.startswith("POP_JUMP_IF_"):
if last == n:
Expand Down
5 changes: 0 additions & 5 deletions decompyle3/parsers/reduce_check/c_tryelsestmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ def c_tryelsestmt(self, lhs, n, rule, ast, tokens, first, last):
if isinstance(leading_jump, SyntaxTree):
leading_jump = leading_jump.first_child()

leading_jump_offset = leading_jump.off2int()

if first_come_from and first_come_from.attr > except_handler_first_offset:
return True

# If there is a jump in the except that goes to the same place as
# except_handler_first_offset, then this is a "try" without an else.
except_stmt = except_handler[2]
Expand Down
4 changes: 1 addition & 3 deletions decompyle3/parsers/reduce_check/or_check.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020 Rocky Bernstein
# Copyright (c) 2020, 2022 Rocky Bernstein
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Expand Down Expand Up @@ -36,8 +36,6 @@ def or_check(
if expr_pjit != "expr_pjit":
return False

jump = expr_pjit[1]

# See FIXME: above
if tokens[last] in NOT_POP_FOLLOW_OPS or tokens[last - 1] in NOT_POP_FOLLOW_OPS:
return True
Expand Down
4 changes: 2 additions & 2 deletions decompyle3/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def get_inst(self, offset: int):

inst = self.insts[self.offset2inst_index[next_offset]]

assert inst.has_extended_arg == True
assert inst.has_extended_arg is True
return inst

return self.insts[self.offset2inst_index[offset]]
Expand Down Expand Up @@ -341,7 +341,7 @@ def inst_matches(self, start, end, instr, target=None, include_beyond_target=Fal
"""
try:
None in instr
except:
except Exception:
instr = [instr]

first = self.offset2inst_index[start]
Expand Down
4 changes: 2 additions & 2 deletions decompyle3/semantics/linemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, *args, **kwargs):
def write(self, *data):
"""Augment write routine to keep track of current line"""
for l in data:
## print("XXX write: '%s'" % l)
# print("XXX write: '%s'" % l)
for i in str(l):
if i == "\n":
self.current_line_number += 1
Expand Down Expand Up @@ -98,7 +98,7 @@ def deparse_test(co):
deparsed = code_deparse_with_map(co)
a = 1
b = 2
print("\n")
print("\n", a, b)
linemap = [
(line_no, deparsed.source_linemap[line_no])
for line_no in sorted(deparsed.source_linemap.keys())
Expand Down
9 changes: 5 additions & 4 deletions decompyle3/semantics/make_function36.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def build_param(tree, name, default, annotation=None):
self.write(", ")
ends_in_comma = True

ann_dict = kw_dict = default_tup = None
kw_dict = None
fn_bits = node[-1].attr
# Skip over:
# MAKE_FUNCTION,
Expand All @@ -259,13 +259,14 @@ def build_param(tree, name, default, annotation=None):
if fn_bits[-1]:
index -= 1
if fn_bits[-2]:
ann_dict = node[index]
# ann_dict = node[index]
index -= 1
if fn_bits[-3]:
kw_dict = node[index]
index -= 1
if fn_bits[-4]:
default_tup = node[index]
# default_tup = node[index]
pass

if kw_dict == "expr":
kw_dict = kw_dict[0]
Expand Down Expand Up @@ -297,7 +298,7 @@ def build_param(tree, name, default, annotation=None):
pass
pass
# handle others
other_kw = [c == None for c in kw_args]
other_kw = [c is None for c in kw_args]

for i, flag in enumerate(other_kw):
if flag:
Expand Down
2 changes: 1 addition & 1 deletion decompyle3/semantics/pysource.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ def code_deparse(
is_top_level_module=is_top_level_module,
)

#### XXX workaround for profiling
# XXX workaround for profiling
if deparsed.ast is None:
return None

Expand Down
2 changes: 2 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ check-code-fragments: \
#: pypy3.8-7.3.7
7.3:

2.3: check-bytecode-3.8


#: Get grammar coverage for Python 3.7
grammar-coverage-3.7:
Expand Down

0 comments on commit 4a61f5d

Please sign in to comment.