Skip to content

Commit

Permalink
pythongh-102507 Remove invisible pagebreak characters (pythonGH-102531)
Browse files Browse the repository at this point in the history
(cherry picked from commit b097925)

Co-authored-by: JosephSBoyle <48555120+JosephSBoyle@users.noreply.github.com>
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
  • Loading branch information
2 people authored and miss-islington committed Aug 22, 2023
1 parent 4d4871e commit 61d3a8a
Show file tree
Hide file tree
Showing 16 changed files with 6 additions and 45 deletions.
1 change: 0 additions & 1 deletion Lib/email/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
]



# Some convenience routines. Don't import Parser and Message as side-effects
# of importing email since those cascadingly import most of the rest of the
# email package.
Expand Down
4 changes: 0 additions & 4 deletions Lib/email/base64mime.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
MISC_LEN = 7



# Helpers
def header_length(bytearray):
"""Return the length of s when it is encoded with base64."""
Expand All @@ -57,7 +56,6 @@ def header_length(bytearray):
return n



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



def body_encode(s, maxlinelen=76, eol=NL):
r"""Encode a string with base64.
Expand All @@ -98,7 +95,6 @@ def body_encode(s, maxlinelen=76, eol=NL):
return EMPTYSTRING.join(encvec)



def decode(string):
"""Decode a raw base64 string, returning a bytes object.
Expand Down
5 changes: 0 additions & 5 deletions Lib/email/charset.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from email.encoders import encode_7or8bit



# Flags for types of header encodings
QP = 1 # Quoted-Printable
BASE64 = 2 # Base64
Expand All @@ -32,7 +31,6 @@
EMPTYSTRING = ''



# Defaults
CHARSETS = {
# input header enc body enc output conv
Expand Down Expand Up @@ -104,7 +102,6 @@
}



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



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



class Charset:
"""Map character sets to their email properties.
Expand Down
4 changes: 0 additions & 4 deletions Lib/email/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from quopri import encodestring as _encodestring



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



def encode_quopri(msg):
"""Encode the message's payload in quoted-printable.
Expand All @@ -46,7 +44,6 @@ def encode_quopri(msg):
msg['Content-Transfer-Encoding'] = 'quoted-printable'



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



def encode_noop(msg):
"""Do nothing."""
2 changes: 0 additions & 2 deletions Lib/email/feedparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
NeedMoreData = object()



class BufferedSubFile(object):
"""A file-ish object that can have new data loaded into it.
Expand Down Expand Up @@ -132,7 +131,6 @@ def __next__(self):
return line



class FeedParser:
"""A feed-style parser of email."""

Expand Down
5 changes: 1 addition & 4 deletions Lib/email/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
fcre = re.compile(r'^From ', re.MULTILINE)



class Generator:
"""Generates output from a Message object tree.
Expand Down Expand Up @@ -392,7 +391,7 @@ def _make_boundary(cls, text=None):
def _compile_re(cls, s, flags):
return re.compile(s, flags)



class BytesGenerator(Generator):
"""Generates a bytes version of a Message object tree.
Expand Down Expand Up @@ -443,7 +442,6 @@ def _compile_re(cls, s, flags):
return re.compile(s.encode('ascii'), flags)



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

class DecodedGenerator(Generator):
Expand Down Expand Up @@ -503,7 +501,6 @@ def _dispatch(self, msg):
}, file=self)



# Helper used by Generator._make_boundary
_width = len(repr(sys.maxsize-1))
_fmt = '%%0%dd' % _width
Expand Down
5 changes: 0 additions & 5 deletions Lib/email/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@
_embedded_header = re.compile(r'\n[^ \t]+:')



# Helpers
_max_append = email.quoprimime._max_append



def decode_header(header):
"""Decode a message header value without converting charset.
Expand Down Expand Up @@ -152,7 +150,6 @@ def decode_header(header):
return collapsed



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



class Header:
def __init__(self, s=None, charset=None,
maxlinelen=None, header_name=None,
Expand Down Expand Up @@ -409,7 +405,6 @@ def _normalize(self):
self._chunks = chunks



class _ValueFormatter:
def __init__(self, headerlen, maxlen, continuation_ws, splitchars):
self._maxlen = maxlen
Expand Down
3 changes: 0 additions & 3 deletions Lib/email/iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from io import StringIO



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



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



def _structure(msg, fp=None, level=0, include_default=False):
"""A handy debugging aid"""
if fp is None:
Expand Down
1 change: 0 additions & 1 deletion Lib/email/mime/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from email import message



class MIMEBase(message.Message):
"""Base class for MIME specializations."""

Expand Down
1 change: 0 additions & 1 deletion Lib/email/mime/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from email.mime.nonmultipart import MIMENonMultipart



class MIMEMessage(MIMENonMultipart):
"""Class representing message/* MIME documents."""

Expand Down
1 change: 0 additions & 1 deletion Lib/email/mime/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from email.mime.base import MIMEBase



class MIMEMultipart(MIMEBase):
"""Base class for MIME multipart/* type messages."""

Expand Down
1 change: 0 additions & 1 deletion Lib/email/mime/nonmultipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from email.mime.base import MIMEBase



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

Expand Down
1 change: 0 additions & 1 deletion Lib/email/mime/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from email.mime.nonmultipart import MIMENonMultipart



class MIMEText(MIMENonMultipart):
"""Class for generating text/* type MIME documents."""

Expand Down
3 changes: 1 addition & 2 deletions Lib/email/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,14 @@ def parsestr(self, text, headersonly=False):
return self.parse(StringIO(text), headersonly=headersonly)



class HeaderParser(Parser):
def parse(self, fp, headersonly=True):
return Parser.parse(self, fp, True)

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



class BytesParser:

def __init__(self, *args, **kw):
Expand Down
3 changes: 0 additions & 3 deletions Modules/_io/bufferedio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,6 @@ _bufferedreader_peek_unlocked(buffered *self)
self->pos = 0;
return PyBytes_FromStringAndSize(self->buffer, r);
}



/*
Expand Down Expand Up @@ -2047,7 +2046,6 @@ _io_BufferedWriter_write_impl(buffered *self, Py_buffer *buffer)
LEAVE_BUFFERED(self)
return res;
}



/*
Expand Down Expand Up @@ -2253,7 +2251,6 @@ bufferedrwpair_closed_get(rwpair *self, void *context)
}
return PyObject_GetAttr((PyObject *) self->writer, &_Py_ID(closed));
}



/*
Expand Down
11 changes: 4 additions & 7 deletions Tools/i18n/pygettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@
EMPTYSTRING = ''



# The normal pot-file header. msgmerge and Emacs's po-mode work better if it's
# there.
pot_header = _('''\
Expand All @@ -196,15 +195,14 @@
''')



def usage(code, msg=''):
print(__doc__ % globals(), file=sys.stderr)
if msg:
print(msg, file=sys.stderr)
sys.exit(code)



def make_escapes(pass_nonascii):
global escapes, escape
if pass_nonascii:
Expand Down Expand Up @@ -258,7 +256,7 @@ def normalize(s, encoding):
s = '""\n"' + lineterm.join(lines) + '"'
return s



def containsAny(str, set):
"""Check whether 'str' contains ANY of the chars in 'set'"""
return 1 in [c in str for c in set]
Expand Down Expand Up @@ -307,7 +305,7 @@ def getFilesForName(name):

return []



class TokenEater:
def __init__(self, options):
self.__options = options
Expand Down Expand Up @@ -515,7 +513,6 @@ def write(self, fp):
print('msgstr ""\n', file=fp)



def main():
global default_keywords
try:
Expand Down Expand Up @@ -675,7 +672,7 @@ class Options:
if closep:
fp.close()



if __name__ == '__main__':
main()
# some more test strings
Expand Down

0 comments on commit 61d3a8a

Please sign in to comment.