Skip to content

Commit 26bdabb

Browse files
committed
Misc fixes
Update pre-config.yaml setup-python-3.6.sh - use 3.6 branch now of term-background __main__.py: better decompiler handling
1 parent 37348de commit 26bdabb

3 files changed

Lines changed: 23 additions & 15 deletions

File tree

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ repos:
66
hooks:
77
- id: check-merge-conflict
88
- id: debug-statements
9-
stages: [commit]
9+
stages: [pre-commit]
1010
- id: end-of-file-fixer
11-
stages: [commit]
11+
stages: [pre-commit]
1212
- repo: https://github.com/pycqa/isort
1313
rev: 5.13.2
1414
hooks:
1515
- id: isort
16-
stages: [commit]
16+
stages: [pre-commit]
1717
- repo: https://github.com/psf/black
1818
rev: 23.12.1
1919
hooks:
2020
- id: black
2121
language_version: python3
22-
stages: [commit]
22+
stages: [pre-commit]

admin-tools/setup-python-3.6.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ fi
1111
export PATH=$HOME/.pyenv/bin/pyenv:$PATH
1212
trepan3k_owd=$(pwd)
1313
mydir=$(dirname $bs)
14-
cd $mydir
15-
. ./checkout_common.sh
14+
. $mydir/checkout_common.sh
1615
(cd $mydir/../../../rocky && \
1716
setup_version python-uncompyle6 python-3.6 && \
1817
setup_version python-filecache python-3.6 && \
19-
setup_version shell-term-background python-3.3 && \
18+
setup_version shell-term-background python-3.6 && \
2019
setup_version pytracer python-3.6 \
2120
setup_version pycolumnize python-3.6 && \
2221
setup_version python-xdis python-3.6 \

trepan/__main__.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,14 @@ def main(dbg=None, sys_argv=list(sys.argv)):
153153
sys.exit(3)
154154
except IOError:
155155
decompiler = "uncompyle6"
156+
no_decompiler = False
156157
try:
157158
if (3, 7) <= PYTHON_VERSION_TRIPLE <= (3, 8):
158159
from decompyle3 import decompile_file
160+
elif PYTHON_VERSION_TRIPLE >= (3, 9):
161+
decompiler = "No decompiler found"
162+
no_decompiler = True
163+
raise ImportError
159164
else:
160165
from uncompyle6 import decompile_file
161166

@@ -195,14 +200,18 @@ def write_wrapper(*args, **kwargs):
195200

196201
# from io import StringIO
197202
# linemap_io = StringIO()
198-
try:
199-
decompile_file(mainpyfile, fd.file, mapstream=fd)
200-
linemaps = decompile_file(mainpyfile, fd.file, mapstream=fd)
201-
except Exception:
202-
print(
203-
f"{__title__}: error decompiling '{mainpyfile}'; disassembling instead.",
204-
file=sys.stderr,
205-
)
203+
if not no_decompiler:
204+
try:
205+
decompile_file(mainpyfile, fd.file, mapstream=fd)
206+
linemaps = decompile_file(mainpyfile, fd.file, mapstream=fd)
207+
except Exception:
208+
no_decompiler = True
209+
print(
210+
f"{__title__}: error decompiling '{mainpyfile}'; disassembling instead.",
211+
file=sys.stderr,
212+
)
213+
214+
if no_decompiler:
206215
info = disassemble_file(
207216
mainpyfile,
208217
outstream=fd,

0 commit comments

Comments
 (0)