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/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): 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]