#7627·requests

Docstring examples in `from_key_val_list` show the pre-3.12 OrderedDict repr

Author: pactenderCreated Sep 17, 2026Updated Sep 17, 2026

src/requests/utils.py's from_key_val_list docstring shows:

>>> from_key_val_list([('key', 'val')])
OrderedDict([('key', 'val')])

Since Python 3.12, collections.OrderedDict.__repr__ uses the regular dict form (cpython gh-101446), so on any currently supported Python this actually prints:

OrderedDict({'key': 'val'})

Reproducer (Python 3.13.5, requests 2.34.2):

>>> from requests.utils import from_key_val_list
>>> from_key_val_list([('key', 'val')])
OrderedDict({'key': 'val'})
>>> from_key_val_list({'key': 'val'})
OrderedDict({'key': 'val'})

The ValueError example in the same docstring is still accurate. Both stale occurrences are on lines 351 and 357, and a grep of the rest of the package found no others.

I have a two-line fix ready on a fork and would be glad to open a pull request if that's welcome. (The compare page says PRs are limited to collaborators, hence this issue.)