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

Skip to content

Commit b057970

Browse files
committed
merge from 3.4
issue15588 - Correct the quopri module documentation. Mention the correct types of the parameters on encodestring and decodestring. Patch by Petri Lehtinen.
2 parents 33683df + 99597c4 commit b057970

2 files changed

Lines changed: 22 additions & 24 deletions

File tree

Doc/library/quopri.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,37 @@ sending a graphics file.
2424
.. function:: decode(input, output, header=False)
2525

2626
Decode the contents of the *input* file and write the resulting decoded binary
27-
data to the *output* file. *input* and *output* must be :term:`file objects
28-
<file object>`. *input* will be read until ``input.readline()`` returns an
29-
empty string. If the optional argument *header* is present and true, underscore
27+
data to the *output* file. *input* and *output* must be :term:`binary file objects
28+
<file object>`. If the optional argument *header* is present and true, underscore
3029
will be decoded as space. This is used to decode "Q"-encoded headers as
3130
described in :rfc:`1522`: "MIME (Multipurpose Internet Mail Extensions)
3231
Part Two: Message Header Extensions for Non-ASCII Text".
3332

3433

3534
.. function:: encode(input, output, quotetabs, header=False)
3635

37-
Encode the contents of the *input* file and write the resulting quoted-printable
38-
data to the *output* file. *input* and *output* must be :term:`file objects
39-
<file object>`. *input* will be read until ``input.readline()`` returns an
40-
empty string. *quotetabs* is a flag which controls whether to encode embedded
41-
spaces and tabs; when true it encodes such embedded whitespace, and when
42-
false it leaves them unencoded. Note that spaces and tabs appearing at the
43-
end of lines are always encoded, as per :rfc:`1521`. *header* is a flag
44-
which controls if spaces are encoded as underscores as per :rfc:`1522`.
36+
Encode the contents of the *input* file and write the resulting quoted-
37+
printable data to the *output* file. *input* and *output* must be
38+
:term:`binary file objects <file object>`. *quotetabs*, a flag which controls
39+
whether to encode embedded spaces and tabs must be provideda and when true it
40+
encodes such embedded whitespace, and when false it leaves them unencoded.
41+
Note that spaces and tabs appearing at the end of lines are always encoded,
42+
as per :rfc:`1521`. *header* is a flag which controls if spaces are encoded
43+
as underscores as per :rfc:`1522`.
4544

4645

4746
.. function:: decodestring(s, header=False)
4847

49-
Like :func:`decode`, except that it accepts a source string and returns the
50-
corresponding decoded string.
48+
Like :func:`decode`, except that it accepts a source :class:`bytes` and
49+
returns the corresponding decoded :class:`bytes`.
5150

5251

5352
.. function:: encodestring(s, quotetabs=False, header=False)
5453

55-
Like :func:`encode`, except that it accepts a source string and returns the
56-
corresponding encoded string. *quotetabs* and *header* are optional
57-
(defaulting to ``False``), and are passed straight through to :func:`encode`.
54+
Like :func:`encode`, except that it accepts a source :class:`bytes` and
55+
returns the corresponding encoded :class:`bytes`. By default, it sends a
56+
False value to *quotetabs* parameter of the :func:`encode` function.
57+
5858

5959

6060
.. seealso::

Lib/quopri.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@ def quote(c):
4444
def encode(input, output, quotetabs, header=False):
4545
"""Read 'input', apply quoted-printable encoding, and write to 'output'.
4646
47-
'input' and 'output' are files with readline() and write() methods.
48-
The 'quotetabs' flag indicates whether embedded tabs and spaces should be
49-
quoted. Note that line-ending tabs and spaces are always encoded, as per
50-
RFC 1521.
51-
The 'header' flag indicates whether we are encoding spaces as _ as per
52-
RFC 1522.
53-
"""
47+
'input' and 'output' are binary file objects. The 'quotetabs' flag
48+
indicates whether embedded tabs and spaces should be quoted. Note that
49+
line-ending tabs and spaces are always encoded, as per RFC 1521.
50+
The 'header' flag indicates whether we are encoding spaces as _ as per RFC
51+
1522."""
5452

5553
if b2a_qp is not None:
5654
data = input.read()
@@ -118,7 +116,7 @@ def encodestring(s, quotetabs=False, header=False):
118116

119117
def decode(input, output, header=False):
120118
"""Read 'input', apply quoted-printable decoding, and write to 'output'.
121-
'input' and 'output' are files with readline() and write() methods.
119+
'input' and 'output' are binary file objects.
122120
If 'header' is true, decode underscore as space (per RFC 1522)."""
123121

124122
if a2b_qp is not None:

0 commit comments

Comments
 (0)