8000 Add warnings about obsolescence of 'email.header.decode_header' and '… · python/cpython@e07b36d · GitHub
[go: up one dir, main page]

Skip to content
  • Commit e07b36d

    8000 Browse files
    committed
    Add warnings about obsolescence of 'email.header.decode_header' and 'email.header.make_header' functions.
    Recommend use of `email.headerregistry.HeaderRegistry` instead, as suggested in #92900 (comment)
    1 parent 5bbec39 commit e07b36d

    File tree

    2 files changed

    +16
    -0
    lines changed

    2 files changed

    +16
    -0
    lines changed

    Doc/library/email.header.rst

    Lines changed: 10 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -202,6 +202,11 @@ The :mod:`email.header` module also provides the following convenient functions.
    202202
    >>> decode_header('bar =?utf-8?B?ZsOzbw==?=')
    203203
    [(b'bar ', None), (b'f\xc3\xb3o', 'utf-8')]
    204204

    205+
    .. note::
    206+
    207+
    This function exists for for backwards compatibility only. For
    208+
    new code, we recommend using :class:`email.headerregistry.HeaderRegistry`.
    209+
    205210

    206211
    .. function:: make_header(decoded_seq, maxlinelen=None, header_name=None, continuation_ws=' ')
    207212

    @@ -215,3 +220,8 @@ The :mod:`email.header` module also provides the following convenient functions.
    215220
    This function takes one of those sequence of pairs and returns a
    216221
    :class:`Header` instance. Optional *maxlinelen*, *header_name*, and
    217222
    *continuation_ws* are as in the :class:`Header` constructor.
    223+
    224+
    .. note::
    225+
    226+
    This function exists for for backwards compatibility only, and is
    227+
    not recommended for use in new code.

    Lib/email/header.py

    Lines changed: 6 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -74,6 +74,9 @@ def decode_header(header):
    7474
    7575
    An email.errors.HeaderParseError may be raised when certain decoding error
    7676
    occurs (e.g. a base64 decoding exception).
    77+
    78+
    This function exists for backwards compatibility only. For new code, we
    79+
    recommend using email.headerregistry.HeaderRegistry instead.
    7780
    """
    7881
    # If it is a Header object, we can just return the encoded chunks.
    7982
    if hasattr(header, '_chunks'):
    @@ -167,6 +170,9 @@ def make_header(decoded_seq, maxlinelen=None, header_name=None,
    167170
    This function takes one of those sequence of pairs and returns a Header
    168171
    instance. Optional maxlinelen, header_name, and continuation_ws are as in
    169172
    the Header constructor.
    173+
    174+
    This function exists for backwards compatibility only, and we is not
    175+
    recommended for use in new code.
    170176
    """
    171177
    h = Header(maxlinelen=maxlinelen, header_name=header_name,
    172178
    continuation_ws=continuation_ws)

    0 commit comments

    Comments
     (0)
    0