From 91e9563746c18987eb5a6a1293cd2fcfe4db037c Mon Sep 17 00:00:00 2001 From: Erik on Endeavour Date: Tue, 4 Feb 2020 23:49:21 -0700 Subject: [PATCH 1/4] Fixed and tested for 3.8 --- goto.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/goto.py b/goto.py index f3a86a7..4aa18cc 100644 --- a/goto.py +++ b/goto.py @@ -52,7 +52,8 @@ def _make_code(code, codestring): ] try: - args.insert(1, code.co_kwonlyargcount) # PY3 + args.insert(1, code.co_posonlyargcount) # PY3.8 + args.insert(2, code.co_kwonlyargcount) # PY3 except AttributeError: pass From 6e03f6810e7d8c9ddbc3a2b3cc7cafea9e944bcf Mon Sep 17 00:00:00 2001 From: Erik on Voyager2 Date: Thu, 6 Feb 2020 09:52:25 -0700 Subject: [PATCH 2/4] Revert "Fixed and tested for 3.8" This reverts commit 91e9563746c18987eb5a6a1293cd2fcfe4db037c. --- goto.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/goto.py b/goto.py index 4aa18cc..f3a86a7 100644 --- a/goto.py +++ b/goto.py @@ -52,8 +52,7 @@ def _make_code(code, codestring): ] try: - args.insert(1, code.co_posonlyargcount) # PY3.8 - args.insert(2, code.co_kwonlyargcount) # PY3 + args.insert(1, code.co_kwonlyargcount) # PY3 except AttributeError: pass From 7f8eb88de5fac1c3f621cbc55ebb3b9381e3b841 Mon Sep 17 00:00:00 2001 From: Erik on Voyager2 Date: Thu, 6 Feb 2020 09:48:01 -0700 Subject: [PATCH 3/4] Take @insignification's approach to Py38 compatibility https://github.com/insignification/python-goto/blob/py38/goto.py --- goto.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/goto.py b/goto.py index f3a86a7..2580310 100644 --- a/goto.py +++ b/goto.py @@ -43,20 +43,23 @@ def argument_bits(self): def _make_code(code, codestring): - args = [ - code.co_argcount, code.co_nlocals, code.co_stacksize, - code.co_flags, codestring, code.co_consts, - code.co_names, code.co_varnames, code.co_filename, - code.co_name, code.co_firstlineno, code.co_lnotab, - code.co_freevars, code.co_cellvars - ] - try: - args.insert(1, code.co_kwonlyargcount) # PY3 - except AttributeError: - pass + return code.replace(co_code=codestring) # new in 3.8+ + except: + args = [ + code.co_argcount, code.co_nlocals, code.co_stacksize, + code.co_flags, codestring, code.co_consts, + code.co_names, code.co_varnames, code.co_filename, + code.co_name, code.co_firstlineno, code.co_lnotab, + code.co_freevars, code.co_cellvars + ] + + try: + args.insert(1, code.co_kwonlyargcount) # PY3 + except AttributeError: + pass - return types.CodeType(*args) + return types.CodeType(*args) def _parse_instructions(code): From 0a2ee2910b27c0751cf966aa9041c773b241e14f Mon Sep 17 00:00:00 2001 From: Erik on Voyager2 Date: Thu, 6 Feb 2020 09:50:14 -0700 Subject: [PATCH 4/4] add Py3.8 to Travis, tox configuration --- .travis.yml | 1 + tox.ini | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 220c689..e1e6335 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ python: - "3.5" - "3.6" - "3.7" + - "3.8" - "pypy" - "pypy3" diff --git a/tox.ini b/tox.ini index 80c937e..3b213b0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26,py27,py32,py33,py34,py35,py36,py37,pypy,pypy3,flake8 +envlist = py26,py27,py32,py33,py34,py35,py36,py37,py38,pypy,pypy3,flake8 skip_missing_interpreters = true [testenv]