Skip to content

statistics: median_grouped() loses exception context when converting interval #149259

@htjworld

Description

@htjworld

median_grouped(interval='bad') raises TypeError: Value cannot be converted to a float, but the original ValueError is lost (__cause__=None).

import statistics
try:
    statistics.median_grouped([1, 2, 3], interval='bad')
except TypeError as e:
    print(e)            # Value cannot be converted to a float
    print(e.__cause__)  # None

Tested on Python 3.14 (main branch).

Linked PRs

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions