Skip to content

Commit 4b640d8

Browse files
Update selected RFC 2822 references to RFC 5322
RFC 2822 was obsoleted by RFC 5322 in 2008. This updates references to use the current standard in documentation, docstrings, and comments. It preserves RFC 2822 references in legacy API components to maintain their historical context. RFC 822 → RFC 2822 → RFC 5322 progression is explained where relevant. In some places specific sections of RFC are referenced where it seems helpful.
1 parent 1b8dcda commit 4b640d8

File tree

15 files changed

+34
-30
lines changed

15 files changed

+34
-30
lines changed

Doc/library/http.client.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ This module provides the following function:
133133

134134
Parse the headers from a file pointer *fp* representing a HTTP
135135
request/response. The file has to be a :class:`~io.BufferedIOBase` reader
136-
(i.e. not text) and must provide a valid :rfc:`2822` style header.
136+
(i.e. not text) and must provide a valid :rfc:`5322` style header.
137137

138138
This function returns an instance of :class:`http.client.HTTPMessage`
139139
that holds the header fields, but no payload

Doc/library/http.server.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ instantiation, of which this module provides three different variants:
154154
variable. This instance parses and manages the headers in the HTTP
155155
request. The :func:`~http.client.parse_headers` function from
156156
:mod:`http.client` is used to parse the headers and it requires that the
157-
HTTP request provide a valid :rfc:`2822` style header.
157+
HTTP request provide a valid :rfc:`5322` style header.
158158

159159
.. attribute:: rfile
160160

Doc/library/mailbox.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ Supported mailbox formats are Maildir, mbox, MH, Babyl, and MMDF.
917917
copied; furthermore, any format-specific information is converted insofar as
918918
possible if *message* is a :class:`!Message` instance. If *message* is a string,
919919
a byte string,
920-
or a file, it should contain an :rfc:`2822`\ -compliant message, which is read
920+
or a file, it should contain an :rfc:`5322`\ -compliant message, which is read
921921
and parsed. Files should be open in binary mode, but text mode files
922922
are accepted for backward compatibility.
923923

Doc/library/time.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ Functions
584584
calculations when the day of the week and the year are specified.
585585

586586
Here is an example, a format for dates compatible with that specified in the
587-
:rfc:`2822` Internet email standard. [1]_ ::
587+
:rfc:`5322` Internet email standard. [1]_ ::
588588

589589
>>> from time import gmtime, strftime
590590
>>> strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
@@ -1066,4 +1066,5 @@ Timezone Constants
10661066
strict reading of the original 1982 :rfc:`822` standard calls for a two-digit
10671067
year (``%y`` rather than ``%Y``), but practice moved to 4-digit years long before the
10681068
year 2000. After that, :rfc:`822` became obsolete and the 4-digit year has
1069-
been first recommended by :rfc:`1123` and then mandated by :rfc:`2822`.
1069+
been first recommended by :rfc:`1123` and then mandated by :rfc:`2822`,
1070+
with :rfc:`5322` continuing this requirement.

Doc/tutorial/stdlib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ sophisticated and robust capabilities of its larger packages. For example:
335335
names, no direct knowledge or handling of XML is needed.
336336

337337
* The :mod:`email` package is a library for managing email messages, including
338-
MIME and other :rfc:`2822`-based message documents. Unlike :mod:`smtplib` and
338+
MIME and other :rfc:`5322`-based message documents. Unlike :mod:`smtplib` and
339339
:mod:`poplib` which actually send and receive messages, the email package has
340340
a complete toolset for building or decoding complex message structures
341341
(including attachments) and for implementing internet encoding and header

Lib/email/_parseaddr.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,9 @@ def _parsedate_tz(data):
146146
return None
147147
# Check for a yy specified in two-digit format, then convert it to the
148148
# appropriate four-digit format, according to the POSIX standard. RFC 822
149-
# calls for a two-digit yy, but RFC 2822 (which obsoletes RFC 822)
150-
# mandates a 4-digit yy. For more information, see the documentation for
149+
# calls for a two-digit yy, but RFC 2822 (which obsoletes RFC 822) already
150+
# mandated a 4-digit yy, and RFC 5322 (which obsoletes RFC 2822) continues
151+
# this requirement. For more information, see the documentation for
151152
# the time module.
152153
if yy < 100:
153154
# The year is between 1969 and 1999 (inclusive).
@@ -233,9 +234,11 @@ def __init__(self, field):
233234
self.CR = '\r\n'
234235
self.FWS = self.LWS + self.CR
235236
self.atomends = self.specials + self.LWS + self.CR
236-
# Note that RFC 2822 now specifies '.' as obs-phrase, meaning that it
237-
# is obsolete syntax. RFC 2822 requires that we recognize obsolete
238-
# syntax, so allow dots in phrases.
237+
# Note that RFC 2822 section 4.1 introduced '.' as obs-phrase to handle
238+
# existing practice (periods in display names), even though it was not
239+
# allowed in RFC 822. RFC 5322 section 4.1 (which obsoletes RFC 2822)
240+
# continues this requirement. We must recognize obsolete syntax, so
241+
# allow dots in phrases.
239242
self.phraseends = self.atomends.replace('.', '')
240243
self.field = field
241244
self.commentlist = []

Lib/email/_policybase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def _fold(self, name, value, sanitize):
380380
h = value
381381
if h is not None:
382382
# The Header class interprets a value of None for maxlinelen as the
383-
# default value of 78, as recommended by RFC 2822.
383+
# default value of 78, as recommended by RFC 5322 section 2.1.1.
384384
maxlinelen = 0
385385
if self.max_line_length is not None:
386386
maxlinelen = self.max_line_length

Lib/email/feedparser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
NLCRE_bol = re.compile(r'(\r\n|\r|\n)')
3333
NLCRE_eol = re.compile(r'(\r\n|\r|\n)\z')
3434
NLCRE_crack = re.compile(r'(\r\n|\r|\n)')
35-
# RFC 2822 $3.6.8 Optional fields. ftext is %d33-57 / %d59-126, Any character
35+
# RFC 5322 section 3.6.8 Optional fields. ftext is %d33-57 / %d59-126, Any character
3636
# except controls, SP, and ":".
3737
headerRE = re.compile(r'^(From |[\041-\071\073-\176]*:|[\t ])')
3838
EMPTYSTRING = ''
@@ -294,7 +294,7 @@ def _parsegen(self):
294294
return
295295
if self._cur.get_content_maintype() == 'message':
296296
# The message claims to be a message/* type, then what follows is
297-
# another RFC 2822 message.
297+
# another RFC 5322 message.
298298
for retval in self._parsegen():
299299
if retval is NeedMoreData:
300300
yield NeedMoreData

Lib/email/generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(self, outfp, mangle_from_=None, maxheaderlen=None, *,
5050
expanded to 8 spaces) than maxheaderlen, the header will split as
5151
defined in the Header class. Set maxheaderlen to zero to disable
5252
header wrapping. The default is 78, as recommended (but not required)
53-
by RFC 2822.
53+
by RFC 5322 section 2.1.1.
5454
5555
The policy keyword specifies a policy object that controls a number of
5656
aspects of the generator's operation. If no policy is specified,

Lib/email/message.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def _decode_uu(encoded):
135135
class Message:
136136
"""Basic message object.
137137
138-
A message object is defined as something that has a bunch of RFC 2822
138+
A message object is defined as something that has a bunch of RFC 5322
139139
headers and a payload. It may optionally have an envelope header
140140
(a.k.a. Unix-From or From_ header). If the message is a container (i.e. a
141141
multipart or a message/rfc822), then the payload is a list of Message

0 commit comments

Comments
 (0)