From 163dfd888d8b56b3d5fcf828b9d06641ba63bca7 Mon Sep 17 00:00:00 2001 From: rocky Date: Thu, 5 May 2016 22:09:22 -0400 Subject: [PATCH] Minor tweaks --- README.rst | 9 ++++++--- uncompyle6/semantics/fragments.py | 12 +++++++++--- uncompyle6/semantics/pysource.py | 6 ++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/README.rst b/README.rst index d49705b9..993c488b 100644 --- a/README.rst +++ b/README.rst @@ -13,7 +13,7 @@ Introduction *uncompyle6* translates Python bytecode back into equivalent Python source code. It accepts bytecodes from Python version 2.5 to 3.4 or so. The code requires Python 2.6 or later and has been tested on Python -running versions 2.6, 2.7, 3.3, 3.4 and 3.5. +running versions 2.6, 2.7, 3.2, 3.3, 3.4 and 3.5. Why this? --------- @@ -92,8 +92,11 @@ for usage help. Known Bugs/Restrictions ----------------------- -Python 2 deparsing is probably as solid as the various versions of -uncompyle2. Python 3 deparsing is okay but not as solid. Python 3.5 is missing some of new opcodes added, but still often works. +Python 2 deparsing decompiles all of the Python 2.7.10 library and as +such is probably a little better than uncompyle2. Python 3 deparsing +is okay, sometimes. More work is needed to decompile all of its +library. Python 3.5 is missing some of new opcodes added, but still +often works. See Also -------- diff --git a/uncompyle6/semantics/fragments.py b/uncompyle6/semantics/fragments.py index ba88a153..81831f68 100644 --- a/uncompyle6/semantics/fragments.py +++ b/uncompyle6/semantics/fragments.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015 by Rocky Bernstein +# Copyright (c) 2015, 2016 by Rocky Bernstein # Copyright (c) 2005 by Dan Pascu # Copyright (c) 2000-2002 by hartmut Goebel # Copyright (c) 1999 John Aycock @@ -595,8 +595,14 @@ class FragmentsWalker(pysource.SourceWalker, object): else: buildclass = node[0] build_list = buildclass[1][0] - subclass = buildclass[-3][0].attr - currentclass = buildclass[0].pattr + if hasattr(buildclass[-3][0], 'attr'): + subclass = buildclass[-3][0].attr + currentclass = buildclass[0].pattr + elif hasattr(node[0][0], 'pattr'): + subclass = buildclass[-3][1].attr + currentclass = node[0][0].pattr + else: + raise 'Internal Error n_classdef: cannot find class name' self.write('\n\n') self.currentclass = str(currentclass) diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 1913d954..61170faf 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1075,14 +1075,12 @@ class SourceWalker(GenericASTTraversal, object): else: buildclass = node[0] build_list = buildclass[1][0] - subclass = buildclass[-3][0].attr - currentclass = buildclass[0].pattr - if hasattr(buildclass[-3][0], 'pattr'): + if hasattr(buildclass[-3][0], 'attr'): subclass = buildclass[-3][0].attr currentclass = buildclass[0].pattr elif hasattr(node[0][0], 'pattr'): - currentclass = node[0][0].pattr subclass = buildclass[-3][1].attr + currentclass = node[0][0].pattr else: raise 'Internal Error n_classdef: cannot find class name'