#1153243 sphinx: please make the output of object_description reproducible when passed a types.MappingProxyType instance

#1153243#5
Date:
2026-11-06 17:27:41 UTC
From:
To:
Hi,

Whilst working on the Reproducible Builds effort [0], we noticed that
sphinx was generating nondetermistic output.

Specifically, although Sphinx has code to generate determinstic string
representations of many Python objects (via the object_description method),
it does not (yet) know to traverse types.MappingProxyType instances.

The existing code will run repr(…) on these dict-like objects and this
will usually result in deterministic output. But the keys of these of
dictionaries are not sorted (AFAICT), and, more importantly, the values
of MappingProxyType's underlying dict are not recursively passed to
object_description.

That means that if a MappingProxyType dict contains, say, a frozenset
instance, then it will not be 'sorted' by object_description, and thus
Sphinx will generate output nondetermistically when facing this kind of
instance.

   >>> types.MappingProxyType({"key": frozenset(("a", "b"))})

You can see this in the python-keystoneauth1 package:

https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/python-keystoneauth1.html

This diff is non-intuitive to read, but you have: