changeset 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 c5e72a3c69dd
children d0689aaa83db
files CHANGES.txt roundup/mailgw.py
diffstat 2 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Tue Jun 05 21:52:38 2018 -0400
+++ b/CHANGES.txt	Thu Jun 07 12:39:31 2018 +0200
@@ -505,6 +505,13 @@
   normal database operation.
 - Allow empty content property for file and message via xmlrpc
   interface. This used to raise a traceback in the (sql) backend.
+- 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.
 
 
 2016-01-11: 1.5.1
--- 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: ')

Roundup Issue Tracker: http://roundup-tracker.org/