Source: epydoc Version: 3.0.1+dfsg-11 Severity: wishlist Tags: patch User: reproducible-bui...@lists.alioth.debian.org Usertags: randomness X-Debbugs-Cc: reproducible-bui...@lists.alioth.debian.org
Hi! While working on the “reproducible builds” effort [1], we have noticed that epydoc uses repr() on objects that don't always override the default one. As a consequence, the documentation shows memory references on the build system, eg. <module.Foo instance at 0x7f3aff4299e0> The attached patch detects objects with no overriding of __repr__ and provides a fallback that does not show the reference. Once applied, more packages using epydoc will be buildable reproducibly in our current experimental framework. [1]: https://wiki.debian.org/ReproducibleBuilds Regards, Val
diff -u -r epydoc-3.0.1+dfsg.old/epydoc/markup/pyval_repr.py epydoc-3.0.1+dfsg/epydoc/markup/pyval_repr.py --- epydoc-3.0.1+dfsg.old/epydoc/markup/pyval_repr.py 2015-08-16 18:57:38.152484836 +0000 +++ epydoc-3.0.1+dfsg/epydoc/markup/pyval_repr.py 2015-08-16 21:11:09.520790145 +0000 @@ -207,9 +207,17 @@ self._colorize_re(pyval, state) else: try: - pyval_repr = repr(pyval) - if not isinstance(pyval_repr, (str, unicode)): - pyval_repr = unicode(pyval_repr) + pyval_class = pyval.__class__ + if hasattr(pyval, '__repr__') and \ + pyval_class.__repr__ is not object.__repr__: + pyval_repr = repr(pyval) + if not isinstance(pyval_repr, (str, unicode)): + pyval_repr = unicode(pyval_repr) + else: + # pyval has a default repr(), which would leak + # a reference to the object + pyval_repr = '<%s.%s object>' % ( + pyval_class.__module__, pyval_class.__name__) pyval_repr_ok = True except KeyboardInterrupt: raise
signature.asc
Description: OpenPGP digital signature