Skip to content

Comparing Quantity to list yields unhandled IndexError: list index out of range #783

@alexbhandari

Description

@alexbhandari

To replicate run

import pint
ureg = pint.UnitRegistry()
ureg('g') == []

results in

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/alexbhandari-young/miniconda3/envs/django/lib/python3.7/site-packages/pint/quantity.py", line 73, in wrapped
    elif isinstance(other, list) and isinstance(other[0], type(self)):
IndexError: list index out of range

This is the case for comparing any Quantity with a list. Seems to be caused by the other[0] access in the check_implemented method used by Quantity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions