Skip to content

Commit b81254d

Browse files
committed
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.
1 parent d60f008 commit b81254d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

CHANGES.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,13 @@ Fixed:
505505
normal database operation.
506506
- Allow empty content property for file and message via xmlrpc
507507
interface. This used to raise a traceback in the (sql) backend.
508+
- Work around a limitation in python2.7 implementation of poplib (for
509+
the pop3 protocol for fetching emails): It seems poplib applies a
510+
line-length limit not just to the lines involving the pop3 protocol
511+
but to any email content, too. This sometimes leads to tracebacks
512+
whenever an email exceeding this limit is encountered. We "fix" this
513+
by monkey-patching poplib with a larger line-limit. Thanks to Heiko
514+
Stegmann for discovering this.
508515

509516

510517
2016-01-11: 1.5.1

roundup/mailgw.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,15 @@ def _do_pop(self, server, user, password, apop, ssl):
14521452
'''Read a series of messages from the specified POP server.
14531453
'''
14541454
import getpass, poplib, socket
1455+
# Monkey-patch poplib to have a large line-limit
1456+
# Seems that in python2.7 poplib applies a line-length limit not
1457+
# just to the lines that take care of the pop3 protocol but also
1458+
# to all email content
1459+
# See, e.g.,
1460+
# https://readlist.com/lists/python.org/python-list/69/346982.html
1461+
# 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
1462+
if 0 < getattr (poplib, '_MAXLINE', -1) < 100*1024:
1463+
poplib._MAXLINE = 100*1024
14551464
try:
14561465
if not user:
14571466
user = raw_input('User: ')

0 commit comments

Comments
 (0)