On Wed, 2023-09-06 at 07:36 +0100, José Matos wrote: > So it seems that what should not happen happened. :-) > > This means that something unexpected is happening and the code is not > able to react to it.
My analysis was not entirely correct. :-) In any case the issue is that function returns either False or a triplet with expected values. The funny thing, at least to me, is that the corresponding construct in C++ is std::optional (C++17 and later) https://en.cppreference.com/w/cpp/utility/optional again C++ is converging to python. :-D With the original file (from the bug reporter) it was possible to construct a minimal file, that follows attached. The fix was then simple and also follows attached. Please commit it. Best regards, -- José Abílio
minimal.lyx
Description: application/lyx
diff --git a/lib/lyx2lyx/parser_tools.py b/lib/lyx2lyx/parser_tools.py index cc2223615a..96abb1cebd 100644 --- a/lib/lyx2lyx/parser_tools.py +++ b/lib/lyx2lyx/parser_tools.py @@ -689,7 +689,8 @@ def count_pars_in_inset(lines, i): pars = 0 for j in range(ins[1], ins[2]): m = re.match(r'\\begin_layout (.*)', lines[j]) - if m and get_containing_inset(lines, j)[1] == ins[1]: + found_inset = get_containing_inset(lines, j) + if m and found_inset and found_inset[1] == ins[1]: pars += 1 return pars
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel