diff options
author | Barry Warsaw <barry@python.org> | 2004-11-01 03:52:43 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2004-11-01 03:52:43 (GMT) |
commit | 8c72eae2378fde4e473feadd4c7139d9ec9cb8e3 (patch) | |
tree | 6d780db607a15f5d3c025cbfaa7f7fb6811da93d /Doc | |
parent | 4590c00e89e349d6ec7247d1c4e7e22222e8ae76 (diff) | |
download | cpython-8c72eae2378fde4e473feadd4c7139d9ec9cb8e3.zip cpython-8c72eae2378fde4e473feadd4c7139d9ec9cb8e3.tar.gz cpython-8c72eae2378fde4e473feadd4c7139d9ec9cb8e3.tar.bz2 |
SF patch #1056967, changes the semantics of Template.safe_substitute() to not
raise a ValueError for dangling delimiters (the delimiter itself is returned).
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/lib/libstring.tex | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Doc/lib/libstring.tex b/Doc/lib/libstring.tex index c9d27b5..1828b2e 100644 --- a/Doc/lib/libstring.tex +++ b/Doc/lib/libstring.tex @@ -131,8 +131,16 @@ precedence. Like \method{substitute()}, except that if placeholders are missing from \var{mapping} and \var{kws}, instead of raising a \exception{KeyError} exception, the original placeholder will appear in the resulting string -intact. Note that other exceptions may still be raised, including -\exception{ValueError} as described above. +intact. Also, unlike with \method{substitute()}, any other appearances of the +\samp{\$} will simply return \samp{\$} instead of raising +\exception{ValueError}. + +While other exceptions may still occur, this method is called ``safe'' because +substitutions always tries to return a usable string instead of raising an +exception. In another sense, \method{safe_substitute()} may be anything other +than safe, since it will silently ignore malformed templates containing +dangling delimiters, unmatched braces, or placeholders that are not valid +Python identifiers. \end{methoddesc} \class{Template} instances also provide one public data attribute: |