From ceb5edd14fbfbe4765410ade783f1c4c8241eea0 Mon Sep 17 00:00:00 2001 From: Andrey Lisin Date: Fri, 31 May 2019 13:20:17 +0300 Subject: [PATCH] PY-36069 Python console support for Python 3.8 GitOrigin-RevId: dc835bd629ef01332e6f37d02662dc62bf38b165 --- .../thriftpy/_shaded_thriftpy/_compat.py | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/python/helpers/third_party/thriftpy/_shaded_thriftpy/_compat.py b/python/helpers/third_party/thriftpy/_shaded_thriftpy/_compat.py index c8f08ce619f3..9ede4cf1c9e2 100644 --- a/python/helpers/third_party/thriftpy/_shaded_thriftpy/_compat.py +++ b/python/helpers/third_party/thriftpy/_shaded_thriftpy/_compat.py @@ -99,21 +99,28 @@ def init_func_generator(spec): code = init.__code__ if PY3: - new_code = types.CodeType(len(varnames), - 0, - len(varnames), - code.co_stacksize, - code.co_flags, - code.co_code, - code.co_consts, - code.co_names, - varnames, - code.co_filename, - "__init__", - code.co_firstlineno, - code.co_lnotab, - code.co_freevars, - code.co_cellvars) + args = [ + len(varnames), + 0, + len(varnames), + code.co_stacksize, + code.co_flags, + code.co_code, + code.co_consts, + code.co_names, + varnames, + code.co_filename, + "__init__", + code.co_firstlineno, + code.co_lnotab, + code.co_freevars, + code.co_cellvars + ] + if sys.version_info >= (3, 8, 0): + # Python 3.8 and above supports positional-only parameters. The number of such + # parameters is passed to the constructor as the second argument. + args.insert(2, 0) + new_code = types.CodeType(*args) elif JYTHON: from org.python.core import PyBytecode