@luke report an error when do search
and we have the error log below:
Module script, line 50, in Base_getSummaryAsHTML
- <PythonScript at /nexedi/Base_getSummaryAsHTML used for /nexedi/web_page_module/xxx>
- Line 50
found = context.Base_showFoundText()
Module Products.ERP5Type.patches.PythonScript, line 181, in __call__
return self._orig_bindAndExec(args, kw, None)
Module Shared.DC.Scripts.Bindings, line 372, in _bindAndExec
return self._exec(bound_data, args, kw)
Module Products.PythonScripts.PythonScript, line 354, in _exec
result = function(*args, **kw)
Module script, line 52, in Base_showFoundText
- <PythonScript at /nexedi/Base_showFoundText used for /nexedi/web_page_module/xxx>
- Line 52
found_text_fragments = context.Base_getExcerptText(
Module Products.ERP5Type.patches.ExternalMethod, line 127, in __call__
return _f[0](*args, **kw)
Module erp5.component.extension.erp5_version.DocumentExtraction, line 117, in getExcerptText
return [p for p in generateParts(context,text,sw,tags,trail,maxlines)]
Module erp5.component.extension.erp5_version.DocumentExtraction, line 117, in <listcomp>
return [p for p in generateParts(context,text,sw,tags,trail,maxlines)]
RuntimeError: generator raised StopIteration
when check more, i found the behavior of raise StopIteration in generator change in python2&python3
My proposition is to use return instead of raise to have the same behavior
| Test | Python 2.7 | Python 3.7+ |
|---|---|---|
raise StopIteration in generator |
Normal stop | RuntimeError |
return in generator |
Normal stop | Normal stop |
a simple test to produce the behavior
def gen():
yield 1
raise StopIteration
yield 2
print(list(gen()))
