Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 5330:c5e72a3c69dd | 5331:57caeefb2f81 |
|---|---|
| 1450 | 1450 |
| 1451 def _do_pop(self, server, user, password, apop, ssl): | 1451 def _do_pop(self, server, user, password, apop, ssl): |
| 1452 '''Read a series of messages from the specified POP server. | 1452 '''Read a series of messages from the specified POP server. |
| 1453 ''' | 1453 ''' |
| 1454 import getpass, poplib, socket | 1454 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 | |
| 1455 try: | 1464 try: |
| 1456 if not user: | 1465 if not user: |
| 1457 user = raw_input('User: ') | 1466 user = raw_input('User: ') |
| 1458 if not password: | 1467 if not password: |
| 1459 password = getpass.getpass() | 1468 password = getpass.getpass() |
