[Python-checkins] python/dist/src/Doc/lib libstring.tex,1.62,1.63

bwarsaw at users.sourceforge.net bwarsaw at users.sourceforge.net
Mon Nov 1 04:52:45 CET 2004


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25882/Doc/lib

Modified Files:
	libstring.tex 
Log Message:
SF patch #1056967, changes the semantics of Template.safe_substitute() to not
raise a ValueError for dangling delimiters (the delimiter itself is returned).



Index: libstring.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstring.tex,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- libstring.tex	18 Sep 2004 21:13:43 -0000	1.62
+++ libstring.tex	1 Nov 2004 03:52:41 -0000	1.63
@@ -131,8 +131,16 @@
 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:



More information about the Python-checkins mailing list