Closed jamesjer closed 2 years ago
Indeed, changing line 190 of pyml_tests.ml from:
filenames = [f.filename for f in traceback.extract_tb(err.__traceback__)]
to:
filenames = [f.filename for f in traceback.StackSummary.extract(traceback.walk_tb(err.__traceback__))]
gets the test to pass.
Some later tests were failing in weird ways. It turns out that the "ocaml other exception" test is to blame. When the OCaml exception is raised in that test, none of the python cleanup code is called. We are left with _Pyruntime.gilstate.tstate_current->cframe
pointing to a frame on the stack. When the next test runs, it overwrites the frame structure with whatever it pushes onto the stack, leading to very weird failures down the road.
Thank you, @jamesjer, for your report and your analysis, and sorry for the delay! I think I finally fixed this in f682f97: Python 3.11 interpreter didn't like to be interrupted by an OCaml exception.
Great, I will give it a try. Thank you!
That commit works great. I did some comparisons with the python 3.11 header files, and wonder if any of these should be addressed as well:
PyCompilerFlags
has a second field, cf_feature_version
. That field is not declared in pyml_stubs.h
, so the malloc in pyml_unwrap_compilerflags
asks for too few bytes. I think that field should be set to version_minor
. That should be okay for older Python interpreters, which won't read those bytes.generate.ml
: PyExc_EncodingWarning
(added in python 3.10) and PyExc_ResourceWarning
(added in python 3.2).PyMarshal_WriteObjectToFile
is declared as returning Int in generate.ml
, but it actually has return type of void; i.e., Unit. This is the case as far back as python 2.6. I didn't look further back than that. This also makes the assert_int_success
on line 2651 of py.ml suspect.PySet_Clear
is the other way around: it is declared as returning Unit in generate.ml
, but it actually returns Int. This is also the case as far back as python 2.6.Thank you very much for having carefully reviewing this! These differences should be fixed in 7fd6f0c . I hope to have tools for checking these kinds of things more systematically in a near future.
We are building all Fedora packages with the current beta release of python 3.11, to identify problems before the 3.11 release. The pyml package fails a test:
The failure may be due to a change in the traceback format: https://docs.python.org/3.11/whatsnew/3.11.html#enhanced-error-locations-in-tracebacks.