[Following up to a message that went to the checkins list.] Raymond sez: > Note change in behavior from 1.5.2. The new argument to > NameError is an error message and not just the missing name. Skip Montanaro writes: > It seems to me that somewhere in the docs it would be worthwhile to state > > Messages to exceptions are not part of the Python API. Their contents > may change from one version of Python to the next without warning and > should not be relied on for code which will be run with multiple > versions of the interpreter. Definately! The catch, of course, is that it's not clear (perhaps only to me?) that what changed was a message. I'd interpret the original behavior (if documented, which I won't bother to check) as an API requirement. AttributeError use to have a similar behavior; I don't know how rigorously that's been maintained either. In either case, I think the ideal solution to the problem of figuring out what went wrong, from within the executing program, is for these errors to have an attribute that identifies the missing name ("name" would be a good name for it). KeyError could similarly have an attribute "key". To deal with existing code, the attributes would not be set. Additional C functions could be provided for use in code that is modified to provide the information. -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Zope Corporation
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4