New submission from Larry Hastings: The documentation for Inspect.Signature and Inspect.Parameter states that the objects are immutable. And they go to great lengths to provide a convenient interface allowing you to "replace" members.
However, the objects make only a pathetic effort at being immutable. They hide their public API members (e.g. "name") behind a property, which they store internally in a member prefixed with an underscore (e.g. "_name"). BUT THE INTERNAL MEMBER IS EXTERNALLY MUTABLE. Example code: >>> def foo(i=3): pass >>> sig = inspect.signature(foo) >>> str(sig) '(i=3)' >>> sig.parameters['i']._name ='silly' >>> str(sig) '(silly3)' ---------- components: Library (Lib) messages: 184796 nosy: brett.cannon, larry priority: low severity: normal stage: test needed status: open title: inspect.Signature and inspect.Parameter objects are mutable type: behavior versions: Python 3.3, Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17499> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com