1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
Description: remove memory addresses for weakref.* instances
Instances of the weakref.WeakKeyDictionary, weakref.WeakValueDictionary
and weakref.WeakSet classes have a __repr__ string which contains their
memory address. This should be skipped when printing their values for
reproducibility of epydoc output.
Author: Sascha Steinbiss <sascha@steinbiss.name>
Bug: https://sourceforge.net/p/epydoc/bugs/370/
Bug-Debian: http://bugs.debian.org/827416
Forwarded: https://sourceforge.net/p/epydoc/bugs/370/
Last-Update: 2016-06-15
--- a/epydoc/markup/pyval_repr.py
+++ b/epydoc/markup/pyval_repr.py
@@ -203,6 +203,8 @@
elif pyval_type is dict:
self._multiline(self._colorize_dict, self._sort(pyval.items()),
state, '{', '}')
+ elif hasattr(pyval, '__class__') and (pyval.__class__.__name__ == 'WeakKeyDictionary' or pyval.__class__.__name__ == 'WeakValueDictionary' or pyval.__class__.__name__ == 'WeakSet'):
+ self._colorize_str(pyval.__class__.__name__, state, '', 'string-escape')
elif is_re_pattern(pyval):
self._colorize_re(pyval, state)
else:
|