Skip to content

Commit dd0a1f9

Browse files
miss-islingtonJosephSBoyleAlexWaygood
authored
[3.11] gh-102507 Remove invisible pagebreak characters (GH-102531) (#108266)
gh-102507 Remove invisible pagebreak characters (GH-102531) (cherry picked from commit b097925) Co-authored-by: JosephSBoyle <[email protected]> Co-authored-by: AlexWaygood <[email protected]>
1 parent cc42182 commit dd0a1f9

16 files changed

+6
-45
lines changed

Lib/email/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
]
2626

2727

28-
2928
# Some convenience routines. Don't import Parser and Message as side-effects
3029
# of importing email since those cascadingly import most of the rest of the
3130
# email package.

Lib/email/base64mime.py

-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
MISC_LEN = 7
4646

4747

48-
4948
# Helpers
5049
def header_length(bytearray):
5150
"""Return the length of s when it is encoded with base64."""
@@ -57,7 +56,6 @@ def header_length(bytearray):
5756
return n
5857

5958

60-
6159
def header_encode(header_bytes, charset='iso-8859-1'):
6260
"""Encode a single header line with Base64 encoding in a given charset.
6361
@@ -72,7 +70,6 @@ def header_encode(header_bytes, charset='iso-8859-1'):
7270
return '=?%s?b?%s?=' % (charset, encoded)
7371

7472

75-
7673
def body_encode(s, maxlinelen=76, eol=NL):
7774
r"""Encode a string with base64.
7875
@@ -98,7 +95,6 @@ def body_encode(s, maxlinelen=76, eol=NL):
9895
return EMPTYSTRING.join(encvec)
9996

10097

101-
10298
def decode(string):
10399
"""Decode a raw base64 string, returning a bytes object.
104100

Lib/email/charset.py

-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from email.encoders import encode_7or8bit
1919

2020

21-
2221
# Flags for types of header encodings
2322
QP = 1 # Quoted-Printable
2423
BASE64 = 2 # Base64
@@ -32,7 +31,6 @@
3231
EMPTYSTRING = ''
3332

3433

35-
3634
# Defaults
3735
CHARSETS = {
3836
# input header enc body enc output conv
@@ -104,7 +102,6 @@
104102
}
105103

106104

107-
108105
# Convenience functions for extending the above mappings
109106
def add_charset(charset, header_enc=None, body_enc=None, output_charset=None):
110107
"""Add character set properties to the global registry.
@@ -153,7 +150,6 @@ def add_codec(charset, codecname):
153150
CODEC_MAP[charset] = codecname
154151

155152

156-
157153
# Convenience function for encoding strings, taking into account
158154
# that they might be unknown-8bit (ie: have surrogate-escaped bytes)
159155
def _encode(string, codec):
@@ -163,7 +159,6 @@ def _encode(string, codec):
163159
return string.encode(codec)
164160

165161

166-
167162
class Charset:
168163
"""Map character sets to their email properties.
169164

Lib/email/encoders.py

-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from quopri import encodestring as _encodestring
1717

1818

19-
2019
def _qencode(s):
2120
enc = _encodestring(s, quotetabs=True)
2221
# Must encode spaces, which quopri.encodestring() doesn't do
@@ -34,7 +33,6 @@ def encode_base64(msg):
3433
msg['Content-Transfer-Encoding'] = 'base64'
3534

3635

37-
3836
def encode_quopri(msg):
3937
"""Encode the message's payload in quoted-printable.
4038
@@ -46,7 +44,6 @@ def encode_quopri(msg):
4644
msg['Content-Transfer-Encoding'] = 'quoted-printable'
4745

4846

49-
5047
def encode_7or8bit(msg):
5148
"""Set the Content-Transfer-Encoding header to 7bit or 8bit."""
5249
orig = msg.get_payload(decode=True)
@@ -64,6 +61,5 @@ def encode_7or8bit(msg):
6461
msg['Content-Transfer-Encoding'] = '7bit'
6562

6663

67-
6864
def encode_noop(msg):
6965
"""Do nothing."""

Lib/email/feedparser.py

-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
NeedMoreData = object()
4242

4343

44-
4544
class BufferedSubFile(object):
4645
"""A file-ish object that can have new data loaded into it.
4746
@@ -132,7 +131,6 @@ def __next__(self):
132131
return line
133132

134133

135-
136134
class FeedParser:
137135
"""A feed-style parser of email."""
138136

Lib/email/generator.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
fcre = re.compile(r'^From ', re.MULTILINE)
2323

2424

25-
2625
class Generator:
2726
"""Generates output from a Message object tree.
2827
@@ -392,7 +391,7 @@ def _make_boundary(cls, text=None):
392391
def _compile_re(cls, s, flags):
393392
return re.compile(s, flags)
394393

395-
394+
396395
class BytesGenerator(Generator):
397396
"""Generates a bytes version of a Message object tree.
398397
@@ -443,7 +442,6 @@ def _compile_re(cls, s, flags):
443442
return re.compile(s.encode('ascii'), flags)
444443

445444

446-
447445
_FMT = '[Non-text (%(type)s) part of message omitted, filename %(filename)s]'
448446

449447
class DecodedGenerator(Generator):
@@ -503,7 +501,6 @@ def _dispatch(self, msg):
503501
}, file=self)
504502

505503

506-
507504
# Helper used by Generator._make_boundary
508505
_width = len(repr(sys.maxsize-1))
509506
_fmt = '%%0%dd' % _width

Lib/email/header.py

-5
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,10 @@
5252
_embedded_header = re.compile(r'\n[^ \t]+:')
5353

5454

55-
5655
# Helpers
5756
_max_append = email.quoprimime._max_append
5857

5958

60-
6159
def decode_header(header):
6260
"""Decode a message header value without converting charset.
6361
@@ -152,7 +150,6 @@ def decode_header(header):
152150
return collapsed
153151

154152

155-
156153
def make_header(decoded_seq, maxlinelen=None, header_name=None,
157154
continuation_ws=' '):
158155
"""Create a Header from a sequence of pairs as returned by decode_header()
@@ -175,7 +172,6 @@ def make_header(decoded_seq, maxlinelen=None, header_name=None,
175172
return h
176173

177174

178-
179175
class Header:
180176
def __init__(self, s=None, charset=None,
181177
maxlinelen=None, header_name=None,
@@ -409,7 +405,6 @@ def _normalize(self):
409405
self._chunks = chunks
410406

411407

412-
413408
class _ValueFormatter:
414409
def __init__(self, headerlen, maxlen, continuation_ws, splitchars):
415410
self._maxlen = maxlen

Lib/email/iterators.py

-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from io import StringIO
1616

1717

18-
1918
# This function will become a method of the Message class
2019
def walk(self):
2120
"""Walk over the message tree, yielding each subpart.
@@ -29,7 +28,6 @@ def walk(self):
2928
yield from subpart.walk()
3029

3130

32-
3331
# These two functions are imported into the Iterators.py interface module.
3432
def body_line_iterator(msg, decode=False):
3533
"""Iterate over the parts, returning string payloads line-by-line.
@@ -55,7 +53,6 @@ def typed_subpart_iterator(msg, maintype='text', subtype=None):
5553
yield subpart
5654

5755

58-
5956
def _structure(msg, fp=None, level=0, include_default=False):
6057
"""A handy debugging aid"""
6158
if fp is None:

Lib/email/mime/base.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from email import message
1212

1313

14-
1514
class MIMEBase(message.Message):
1615
"""Base class for MIME specializations."""
1716

Lib/email/mime/message.py

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from email.mime.nonmultipart import MIMENonMultipart
1111

1212

13-
1413
class MIMEMessage(MIMENonMultipart):
1514
"""Class representing message/* MIME documents."""
1615

Lib/email/mime/multipart.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from email.mime.base import MIMEBase
1010

1111

12-
1312
class MIMEMultipart(MIMEBase):
1413
"""Base class for MIME multipart/* type messages."""
1514

Lib/email/mime/nonmultipart.py

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from email.mime.base import MIMEBase
1111

1212

13-
1413
class MIMENonMultipart(MIMEBase):
1514
"""Base class for MIME non-multipart type messages."""
1615

Lib/email/mime/text.py

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from email.mime.nonmultipart import MIMENonMultipart
1111

1212

13-
1413
class MIMEText(MIMENonMultipart):
1514
"""Class for generating text/* type MIME documents."""
1615

Lib/email/parser.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,14 @@ def parsestr(self, text, headersonly=False):
6767
return self.parse(StringIO(text), headersonly=headersonly)
6868

6969

70-
7170
class HeaderParser(Parser):
7271
def parse(self, fp, headersonly=True):
7372
return Parser.parse(self, fp, True)
7473

7574
def parsestr(self, text, headersonly=True):
7675
return Parser.parsestr(self, text, True)
7776

78-
77+
7978
class BytesParser:
8079

8180
def __init__(self, *args, **kw):

Modules/_io/bufferedio.c

-3
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,6 @@ _bufferedreader_peek_unlocked(buffered *self)
17401740
self->pos = 0;
17411741
return PyBytes_FromStringAndSize(self->buffer, r);
17421742
}
1743-
17441743

17451744

17461745
/*
@@ -2047,7 +2046,6 @@ _io_BufferedWriter_write_impl(buffered *self, Py_buffer *buffer)
20472046
LEAVE_BUFFERED(self)
20482047
return res;
20492048
}
2050-
20512049

20522050

20532051
/*
@@ -2253,7 +2251,6 @@ bufferedrwpair_closed_get(rwpair *self, void *context)
22532251
}
22542252
return PyObject_GetAttr((PyObject *) self->writer, &_Py_ID(closed));
22552253
}
2256-
22572254

22582255

22592256
/*

Tools/i18n/pygettext.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@
174174
EMPTYSTRING = ''
175175

176176

177-
178177
# The normal pot-file header. msgmerge and Emacs's po-mode work better if it's
179178
# there.
180179
pot_header = _('''\
@@ -196,15 +195,14 @@
196195
197196
''')
198197

199-
198+
200199
def usage(code, msg=''):
201200
print(__doc__ % globals(), file=sys.stderr)
202201
if msg:
203202
print(msg, file=sys.stderr)
204203
sys.exit(code)
205204

206205

207-
208206
def make_escapes(pass_nonascii):
209207
global escapes, escape
210208
if pass_nonascii:
@@ -258,7 +256,7 @@ def normalize(s, encoding):
258256
s = '""\n"' + lineterm.join(lines) + '"'
259257
return s
260258

261-
259+
262260
def containsAny(str, set):
263261
"""Check whether 'str' contains ANY of the chars in 'set'"""
264262
return 1 in [c in str for c in set]
@@ -307,7 +305,7 @@ def getFilesForName(name):
307305

308306
return []
309307

310-
308+
311309
class TokenEater:
312310
def __init__(self, options):
313311
self.__options = options
@@ -515,7 +513,6 @@ def write(self, fp):
515513
print('msgstr ""\n', file=fp)
516514

517515

518-
519516
def main():
520517
global default_keywords
521518
try:
@@ -675,7 +672,7 @@ class Options:
675672
if closep:
676673
fp.close()
677674

678-
675+
679676
if __name__ == '__main__':
680677
main()
681678
# some more test strings

0 commit comments

Comments
 (0)