Mercurial > p > roundup > code
diff roundup/mailgw.py @ 5331:57caeefb2f81
Work around a line-length limit in poplib
Work around a limitation in python2.7 implementation of poplib (for the
pop3 protocol for fetching emails): It seems poplib applies a
line-length limit not just to the lines involving the pop3 protocol but
to any email content, too. This sometimes leads to tracebacks whenever
an email exceeding this limit is encountered. We "fix" this by
monkey-patching poplib with a larger line-limit. Thanks to Heiko
Stegmann for discovering this.
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Thu, 07 Jun 2018 12:39:31 +0200 |
| parents | 91354bf0b683 |
| children | 66a17c80e035 |
line wrap: on
line diff
--- a/roundup/mailgw.py Tue Jun 05 21:52:38 2018 -0400 +++ b/roundup/mailgw.py Thu Jun 07 12:39:31 2018 +0200 @@ -1452,6 +1452,15 @@ '''Read a series of messages from the specified POP server. ''' import getpass, poplib, socket + # Monkey-patch poplib to have a large line-limit + # Seems that in python2.7 poplib applies a line-length limit not + # just to the lines that take care of the pop3 protocol but also + # to all email content + # See, e.g., + # https://readlist.com/lists/python.org/python-list/69/346982.html + # https://stackoverflow.com/questions/30976106/python-poplib-error-proto-line-too-+long?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa + if 0 < getattr (poplib, '_MAXLINE', -1) < 100*1024: + poplib._MAXLINE = 100*1024 try: if not user: user = raw_input('User: ')
