# HG changeset patch # User Franz Glasner # Date 1777397368 -7200 # Node ID a2a56d08b860588acdd3ac13ce11c502f6cf8e2b # Parent 206017a08ed762d768b131357b1ebd776817fa57 FIX: Python 2 needs a "staticmethod" on "op_fixed()" when called via the LexBase. Python 3 does not allow this. Implement proper decoration depending on the Python version. diff -r 206017a08ed7 -r a2a56d08b860 pygments_lexer_pseudocode2/bases.py --- a/pygments_lexer_pseudocode2/bases.py Tue Apr 28 19:14:17 2026 +0200 +++ b/pygments_lexer_pseudocode2/bases.py Tue Apr 28 19:29:28 2026 +0200 @@ -8,11 +8,16 @@ __all__ = ["LexBase", "uni_name", "py_innerstring_rules", "py_name_rules"] +import sys + from pygments import unistring from pygments.lexer import RegexLexer, combined, bygroups, include from pygments.token import (Comment, Error, Name, Number, Other, String) +PY2 = sys.version_info[0] <= 2 + + # # SPDX-SnippetBegin # SPDX-License-Identifier: BSD-2-Clause @@ -23,6 +28,14 @@ uni_name = "[%s][%s]*" % (unistring.xid_start, unistring.xid_continue) +"""PY3 allows no @staticmethod but PY2 needs it.""" +if PY2: + _staticmethod = staticmethod +else: + def _staticmethod(fn): + return fn + + def py_innerstring_rules(ttype): return [ # the old style '%s' % (...) string formatting (still valid in Py3) @@ -73,6 +86,7 @@ if False: yield match.start(), Other, "" + @_staticmethod def op_fixed(toktype, value): """Unconditionally yield a given token type and value."""