5

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'
SiHa
  • 7,830
  • 13
  • 34
  • 43
green
  • 226
  • 2
  • 12

2 Answers2

18

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

Dave Woodward
  • 181
  • 1
  • 3
3

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.

Community
  • 1
  • 1
SiHa
  • 7,830
  • 13
  • 34
  • 43
  • The application is on OpenShift. After checking with local env, it looks like they have change from python 2.7.6 to 2.7.8. Thanks for pointing this out. Now will have to search around how to change the python back to 2.7.6 on Openshift! Once again, thank you. – green Jun 23 '15 at 07:08