jaraco/inflect

`engine.plural` raises unexpected `IndexError`

开放

#172 创建于 2023年1月7日

 (4 条评论) (0 个反应) (0 位负责人)Python (125 个派生)github user discovery
help wanted

仓库指标

星标
 (1,082 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

This might be considered invalid input, but engine.plural accepts multiple words. When doing so, it can raise an unexpected IndexError:

>>> import inflect
>>> engine = inflect.engine()
>>> engine.plural("I'm only here for a minute, John.")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pydantic\decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
  File "pydantic\decorator.py", line 134, in pydantic.decorator.ValidatedFunction.call
  File "pydantic\decorator.py", line 206, in pydantic.decorator.ValidatedFunction.execute
  File "C:\Program Files\Python39\lib\site-packages\inflect\__init__.py", line 2403, in plural
    plural = self.postprocess(
  File "C:\Program Files\Python39\lib\site-packages\inflect\__init__.py", line 2375, in postprocess
    result[index] = result[index].capitalize()
IndexError: list index out of range

This seems to be because engine.postprocess expects the inflected it's passed to be the same number of words as the orig it's passed, but that's not necessarily the case.

贡献者指南