Python poplib error_proto: line too long

3.9k views Asked by At

Recently, without changes to codes/libs, I started getting python error_proto: line too long error when reading email (poplib.retr) from hotmail inbox. I am using Python version 2.7.8. I understand that a long line may be caused this error. But is there a way to go around this or a certain version I need to put in place. Thank you for any advice/direction anyone can give.

Here is a traceback error:

"/opt/rh/python27/root/usr/lib64/python2.7/poplib.py", line 232, in retr\n return self._longcmd(\'RETR %s\' % which)\n', 
' File "/opt/rh/python27/root/usr/lib64/python2.7/poplib.py", line 167, in _longcmd\n return self._getlongresp()\n', 
' File "/opt/rh/python27/root/usr/lib64/python2.7/poplib.py", line 152, in _getlongresp\n line, o = self._getline()\n', 
' File "/opt/rh/python27/root/usr/lib64/python2.7/poplib.py", line 377, in _getline\n raise error_proto(\'line too long\')\n', 
'error_proto: line too long\n'
2

There are 2 answers

1
SiHa On BEST ANSWER

Are you sure you've not updated poplib? Have a look at the most recent diff, committed last night:

# Added:
 ...
# maximal line length when calling readline(). This is to prevent
# reading arbitrary length lines. RFC 1939 limits POP3 line length to
# 512 characters, including CRLF. We have selected 2048 just to be on
# the safe side.
_MAXLINE = 2048

...
# in_getline()...

    if len(self.buffer) > _MAXLINE:
        raise error_proto('line too long')

...it looks suspiciously similar to your problem.

So if you roll back to the previous version, it will probably be OK.

0
Dave Woodward On

A python bug report exists for this issue here: https://bugs.python.org/issue16041

The work around I put inplace was as follows:

import poplib
poplib._MAXLINE=20480

I thought this was a better idea, rather than editing the poplib.py library file directly.

Woody