Closed FelixSchwarz closed 3 years ago
Similar failures with Python 3.10rc2 with one minor difference:
…
File "…/genshi/template/tests/eval.py", line 506, in test_error_getitem_undefined_string
self.assertEqual(50, frame.tb_lineno)
AssertionError: 50 != -1
Differences in line numbers are likely caused by PEP 626.
How did a line number end up being -1?
After digging a bit, I'm pretty sure that the arguments for CodeType
changed again as a result of PEP 626. Admittedly these arguments are undocumented, so we can't complain too much -- https://docs.python.org/3/library/types.html#types.CodeType.
There are two functions in genshi.compat
that are affected -- get_code_params
and build_code_chunk
.
For build_code_chunk
we can probably write a Python >= 3.8 version that calls the new .replace(...)
method on the code object to set the line number.
For get_code_params
I'm not quite sure what to do yet -- probably we need to go look at the 3.10 source code and see what has happened to CodeType and update the values returned.
For build_code_chunk we can probably write a Python >= 3.8 version that calls the new .replace(...) method on the code object to set the line number.
Thank you for the hint. I did that in #49 and all errors just vanished :-)
However...
For get_code_params I'm not quite sure what to do yet -- probably we need to go look at the 3.10 source code and see what has happened to CodeType and update the values returned.
I guess this means get_code_params()
is never really executed by the test suite... (?)
Actually we got a hint from the BFDL a while ago: https://github.com/edgewall/genshi/issues/43#issuecomment-845491080
get_code_params()
is only used when a genshi.template.eval.Code
object is serialized. This is actually tested (look for pickle
in genshi.template.tests.eval
) but nothing checks whether the code object is correct afterwards.
When switching from Python 3.10a2 -> 3.10a3 the test suite starts failing.
Initial report: https://bugzilla.redhat.com/show_bug.cgi?id=1907400