jaraco/inflect

`engine.plural` raises unexpected `IndexError`

Aberta

#172 aberto em 7 de jan. de 2023

 (4 comentários) (0 reação) (0 responsável)Python (125 forks)github user discovery
help wanted

Métricas do repositório

Stars
 (1.082 estrelas)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

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.

Guia do colaborador