Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 463c5a8

Browse files
committed
Update get_param() description to reflect changes to the docstring.
1 parent c86c24e commit 463c5a8

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

Doc/lib/emailmessage.tex

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,18 @@
354354
Parameter keys are always compared case insensitively. The return
355355
value can either be a string, or a 3-tuple if the parameter was
356356
\rfc{2231} encoded. When it's a 3-tuple, the elements of the value are of
357-
the form \code{(CHARSET, LANGUAGE, VALUE)}, where \code{LANGUAGE} may
358-
be the empty string. Your application should be prepared to deal with
359-
3-tuple return values, which it can convert to a Unicode string like
360-
so:
357+
the form \code{(CHARSET, LANGUAGE, VALUE)}. Note that both \code{CHARSET} and
358+
\code{LANGUAGE} can be \code{None}, in which case you should consider
359+
\code{VALUE} to be encoded in the \code{us-ascii} charset. You can
360+
usually ignore \code{LANGUAGE}.
361+
362+
Your application should be prepared to deal with 3-tuple return
363+
values, and can convert the parameter to a Unicode string like so:
361364

362365
\begin{verbatim}
363366
param = msg.get_param('foo')
364367
if isinstance(param, tuple):
365-
param = unicode(param[2], param[0])
368+
param = unicode(param[2], param[0] or 'us-ascii')
366369
\end{verbatim}
367370

368371
In any case, the parameter value (either the returned string, or the

0 commit comments

Comments
 (0)