From 43646b3c71af223cf8d2eda715cb1f4d334948dd Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 14 Jan 2019 17:41:54 -0500 Subject: [PATCH 1/9] Comma placement in 3.6 and 3.7 **kwargs fixes #208 --- test/bytecode_3.7_run/07_kwargs.pyc | Bin 0 -> 363 bytes test/simple_source/bug36/07_kwargs.py | 9 +++++++++ uncompyle6/semantics/make_function.py | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/bytecode_3.7_run/07_kwargs.pyc create mode 100644 test/simple_source/bug36/07_kwargs.py diff --git a/test/bytecode_3.7_run/07_kwargs.pyc b/test/bytecode_3.7_run/07_kwargs.pyc new file mode 100644 index 0000000000000000000000000000000000000000..20178a5243aba2bcef20d2bd8c7088b7cb0252ec GIT binary patch literal 363 zcmXw#ze)o^5XSeG2uXHx9GBdN**k)eD%ko4zJSkT zx2=`0VC6Tb?()rk!|wcM*xPP*M_@hfT|Rx_{N&_+#W2^9?;{vtB^cp|edrD6L literal 0 HcmV?d00001 diff --git a/test/simple_source/bug36/07_kwargs.py b/test/simple_source/bug36/07_kwargs.py new file mode 100644 index 00000000..88636e24 --- /dev/null +++ b/test/simple_source/bug36/07_kwargs.py @@ -0,0 +1,9 @@ +# Bug in Python 3.6 and 3.7 was getting comma before **kw + +def fn(arg, *, kwarg='test', **kw): + assert arg == 1 + assert kwarg == 'testing' + assert kw['foo'] == 'bar' + + +fn(1, kwarg='testing', foo='bar') diff --git a/uncompyle6/semantics/make_function.py b/uncompyle6/semantics/make_function.py index 7ccd48e1..67d43982 100644 --- a/uncompyle6/semantics/make_function.py +++ b/uncompyle6/semantics/make_function.py @@ -735,7 +735,7 @@ def make_function3(self, node, is_lambda, nested=1, code_node=None): self.write(sep) self.write("%s=%s" % (n, defaults[i])) sep = ', ' - ends_in_comma = True + ends_in_comma = False pass pass pass From fb117713cf5ad5ee82c6508bd838b6ea55f9544a Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 14 Jan 2019 22:10:20 -0500 Subject: [PATCH 2/9] Let's try Python 2.7.15 on CI --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 502464e0..57dd2e7d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,7 +42,7 @@ jobs: # This is based on your 1.0 configuration file or project settings - run: working_directory: ~/rocky/python-uncompyle6 - command: pyenv install 2.7.13 && pyenv local 2.7.13 && pyenv rehash && pip install virtualenv && pip install nose && pip install pep8 && pip install six && pyenv rehash + command: pyenv install 2.7.15 && pyenv local 2.7.15 && pyenv rehash && pip install virtualenv && pip install nose && pip install pep8 && pip install six && pyenv rehash # Dependencies # This would typically go in either a build or a build-and-test job when using workflows # Restore the dependency cache From 9f1a7fa7ffc778bd7cceb371aecfd6b4ad4740d5 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 14 Jan 2019 22:18:07 -0500 Subject: [PATCH 3/9] Go with Python 2.7.11 which seems to be installed already --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 57dd2e7d..5f5e4352 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,7 +42,7 @@ jobs: # This is based on your 1.0 configuration file or project settings - run: working_directory: ~/rocky/python-uncompyle6 - command: pyenv install 2.7.15 && pyenv local 2.7.15 && pyenv rehash && pip install virtualenv && pip install nose && pip install pep8 && pip install six && pyenv rehash + command: pyenv install 2.7.11 && pyenv local 2.7.11 && pyenv rehash && pip install virtualenv && pip install nose && pip install pep8 && pip install six && pyenv rehash # Dependencies # This would typically go in either a build or a build-and-test job when using workflows # Restore the dependency cache From 739ba48f61a5e19f6b9dada079f6788c7b9ab7f7 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 14 Jan 2019 22:18:52 -0500 Subject: [PATCH 4/9] Go with Python 2.7.11 which seems to be installed already --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5f5e4352..c5ecc892 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,7 +42,7 @@ jobs: # This is based on your 1.0 configuration file or project settings - run: working_directory: ~/rocky/python-uncompyle6 - command: pyenv install 2.7.11 && pyenv local 2.7.11 && pyenv rehash && pip install virtualenv && pip install nose && pip install pep8 && pip install six && pyenv rehash + command: pyenv local 2.7.11 && pyenv rehash && pip install virtualenv && pip install nose && pip install pep8 && pip install six && pyenv rehash # Dependencies # This would typically go in either a build or a build-and-test job when using workflows # Restore the dependency cache From 14111d9341d182cb7f44b83b114b0e984954c844 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 14 Jan 2019 22:21:59 -0500 Subject: [PATCH 5/9] Need hypothesis 3.0.0? --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c5ecc892..c14f66fc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,7 +57,7 @@ jobs: # This is based on your 1.0 configuration file or project settings - run: pip install --upgrade setuptools - run: pip install -e . - - run: pip install pytest==3.2.5 hypothesis + - run: pip install pytest==3.2.5 hypothesis==3.0.0 # Save dependency cache - save_cache: key: v1-dep-{{ .Branch }}-{{ epoch }} From 763c599c16636b838b09b177d00bc725553619bf Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 14 Jan 2019 22:28:14 -0500 Subject: [PATCH 6/9] I said use Python 2.7.11 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c14f66fc..5a65a3d2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -76,7 +76,7 @@ jobs: # This would typically be a build job when using workflows, possibly combined with build # This is based on your 1.0 configuration file or project settings - run: python ./setup.py develop && make check-2.7 - - run: cd ./test/stdlib && pyenv local 2.7.13 && bash ./runtests.sh 'test_[p-z]*.py' + - run: cd ./test/stdlib && pyenv local 2.7.11 && bash ./runtests.sh 'test_[p-z]*.py' # Teardown # If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each # Save test results From ceae035c7099893920aab544c4a10a8284878108 Mon Sep 17 00:00:00 2001 From: byehack Date: Wed, 16 Jan 2019 19:36:13 +0330 Subject: [PATCH 7/9] support utf-8 chars --- uncompyle6/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uncompyle6/main.py b/uncompyle6/main.py index 3bbbe62d..123a2e49 100644 --- a/uncompyle6/main.py +++ b/uncompyle6/main.py @@ -43,7 +43,7 @@ def _get_outstream(outfile): mode = 'wb' else: mode = 'w' - return open(outfile, mode) + return open(outfile, mode, encoding="utf-8") def decompile( bytecode_version, co, out=None, showasm=None, showast=False, From 138b2ac5ee223240c204aa7cd10354e7c18bf305 Mon Sep 17 00:00:00 2001 From: byehack Date: Thu, 17 Jan 2019 18:43:13 +0330 Subject: [PATCH 8/9] support utf-8 encoding for PYTHON>=3 --- uncompyle6/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/uncompyle6/main.py b/uncompyle6/main.py index 123a2e49..a071f290 100644 --- a/uncompyle6/main.py +++ b/uncompyle6/main.py @@ -40,10 +40,10 @@ def _get_outstream(outfile): except OSError: pass if PYTHON_VERSION < 3.0: - mode = 'wb' + kw = {'mode':'wb'} else: - mode = 'w' - return open(outfile, mode, encoding="utf-8") + kw= = {'mode':'w', 'encoding':'utf-8'} + return open(outfile, **kw) def decompile( bytecode_version, co, out=None, showasm=None, showast=False, From 0c5f0dfc7afb570877443329d09c3d11482a42f5 Mon Sep 17 00:00:00 2001 From: byehack Date: Thu, 17 Jan 2019 18:52:40 +0330 Subject: [PATCH 9/9] support utf-8 in py3 --- uncompyle6/main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/uncompyle6/main.py b/uncompyle6/main.py index a071f290..a5a0daf7 100644 --- a/uncompyle6/main.py +++ b/uncompyle6/main.py @@ -40,10 +40,9 @@ def _get_outstream(outfile): except OSError: pass if PYTHON_VERSION < 3.0: - kw = {'mode':'wb'} + return open(outfile, mode='wb') else: - kw= = {'mode':'w', 'encoding':'utf-8'} - return open(outfile, **kw) + return open(outfile, mode='w', encoding='utf-8') def decompile( bytecode_version, co, out=None, showasm=None, showast=False,