From 95f4faa45e376baccfc98b0168d5896bc587d087 Mon Sep 17 00:00:00 2001 From: Vaclav Petras Date: Wed, 26 Feb 2020 09:49:41 -0500 Subject: [PATCH] ctypes: Fix ctypesgencore for Python 3 Python 3 sort says 'must use keyword argument for key function' (Python 2 accepts this new syntax). The parameter of Signature.update() is used as a hash, so any encoding will do, but using UTF-8 always for consistency. --- lib/python/ctypes/ctypesgencore/parser/yacc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/python/ctypes/ctypesgencore/parser/yacc.py b/lib/python/ctypes/ctypesgencore/parser/yacc.py index da0d48c6735..f1ad1d9d331 100644 --- a/lib/python/ctypes/ctypesgencore/parser/yacc.py +++ b/lib/python/ctypes/ctypesgencore/parser/yacc.py @@ -2276,7 +2276,7 @@ def yacc( raise YaccError("no rules of the form p_rulename are defined.") # Sort the symbols by line number - symbols.sort(lambda x, y: cmp(get_func_code(x).co_firstlineno, get_func_code(y).co_firstlineno)) + symbols.sort(key=lambda x: get_func_code(x).co_firstlineno) # Add all of the symbols to the grammar for f in symbols: @@ -2288,7 +2288,7 @@ def yacc( # Make a signature of the docstrings for f in symbols: if f.__doc__: - Signature.update(f.__doc__) + Signature.update(f.__doc__.encode("utf-8")) lr_init_vars()