abseil / abseil-py

Abseil Common Libraries (Python)
Apache License 2.0
2.27k stars 246 forks source link

Explicitly fail when a Mapping or Set object is passed to assertSequenceStartsWith as the `whole` argument. #251

Closed copybara-service[bot] closed 12 months ago

copybara-service[bot] commented 1 year ago

Explicitly fail when a Mapping or Set object is passed to assertSequenceStartsWith as the whole argument.

Previously, when passed a Mapping or Set object, it raises a TypeError. Except starting with Python 3.12, it raises a KeyError for a Mapping object because slice objects are now hashable (i.e. a_dict[:2] usually raises a KeyError).

This change makes the unexpected inputs fail more explicitly.