Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • erp5 erp5
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Merge requests 147
    • Merge requests 147
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedinexedi
  • erp5erp5
  • Merge requests
  • !2242

erp5_core: return instead of raise StopIteration

  • Review changes

  • Download
  • Patches
  • Plain diff
Closed Xiaowu Zhang requested to merge xiaowu.zhang/erp5:fix/stopIteration into master Feb 12, 2026
  • Overview 4
  • Commits 0
  • Pipelines 0
  • Changes -

@luke report an error when do search

image

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()))

/cc @jerome @romain

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: fix/stopIteration
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7