diff options
| author | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2015-03-29 07:15:14 -0400 |
|---|---|---|
| committer | Jean-Paul Calderone <exarkun@twistedmatrix.com> | 2015-03-29 07:15:14 -0400 |
| commit | 0894b17761d4f2b8b462be445ca8371d94f7fd8d (patch) | |
| tree | 423ed6c103eaa1310d66dca690f73d4c3c5294d5 /OpenSSL | |
| parent | 6462b0768d7d88e66344e731d9a3cb9a5e5ef48a (diff) | |
| download | pyopenssl-0894b17761d4f2b8b462be445ca8371d94f7fd8d.tar.gz | |
docstring
Diffstat (limited to 'OpenSSL')
| -rw-r--r-- | OpenSSL/_util.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/OpenSSL/_util.py b/OpenSSL/_util.py index da8270b..bb2b740 100644 --- a/OpenSSL/_util.py +++ b/OpenSSL/_util.py @@ -59,6 +59,18 @@ _TEXT_WARNING = u"{} for {{}} is no longer accepted, use bytes".format( ) def warn_text(label, obj): + """ + If ``obj`` is text, emit a warning that it should be bytes instead and try + to convert it to bytes automatically. + + :param str label: The name of the parameter from which ``obj`` was taken + (so a developer can easily find the source of the problem and correct + it). + + :return: If ``obj`` is the text string type, a ``bytes`` object giving the + UTF-8 encoding of that text is returned. Otherwise, ``obj`` itself is + returned. + """ if isinstance(obj, text_type): warn( _TEXT_WARNING.format(label), |
