Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #104522
| From | cl@isbd.net |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: How to program round this poplib error? |
| Date | 2016-03-10 14:09 +0000 |
| Message-ID | <eqb8rc-fcn.ln1@esprimo.zbmc.eu> (permalink) |
| References | <nf48rc-ncl.ln1@esprimo.zbmc.eu> <slrnne2tft.19u.jon+usenet@wintry.unequivocal.co.uk> |
Jon Ribbens <jon+usenet@unequivocal.co.uk> wrote: > On 2016-03-10, cl@isbd.net <cl@isbd.net> wrote: > > # Read each message into a string and then parse with the email module, if > > # there's an error retrieving the message then just throw it away > > # > > try: > > popmsg = pop3.retr(i+1) > > except: > > pop3.dele(i+1) > > continue > > > > The trouble is that the error is (presumably) some sort of buffer size > > limitation in pop3.dele(). If I trap the error then I still can't get > > rid of the rogue E-Mail and, more to the point, I can't even identify > > it so that the trap could report the error and tell me which message > > was causing it. > > You really, really should not be using bare "except:". > Always specify which exceptions you are trying to catch. > Yes, I know, but it doesn't really relate to the problem does it. > In this case, I think there are two problems. Firstly, I think > whoever implemented poplib mis-read the POP3 specification, as > they are applying the line-length limit to not just the POP3 > commands and responses, but the email contents too. > > Secondly, you are just trying to carry on with the POP3 connection > after it has thrown an exception. You can't do that, because you > don't know what the problem was. My guess would be that what you > are mostly seeing is a line in the email content that is over 2kB, > which causes 'retr' to throw a "line too long" exception. > > You then blindly throw a "DELE" at the server, and when you try to > read the response to that command it throws another "line too long" > exception because (a) the server's actually still in the middle of > sending the email contents and (b) there's a bug in the SSL poplib > which means once it's thrown "line too long" it will keep doing so > repeatedly. > > So what I think you need to do is: > > (a) after your "import poplib" add "poplib._MAXLINE = 10*1024*1024" > or somesuch (i.e. increase it a lot), > Ah, that's a much better way of doing it than actually changing the code, thank you. > (b) get rid of your "except:" and work out what you really meant, > checking what the error returned was before blindly throwing > commands at a POP3 server in an unknown state. You may well > need to disconnect and reconnect before continuing - or indeed > you may well not need to catch any exception at all at this > point after doing (a). Yes, hopefully the exception will go away. Thank you again. -- Chris Green ยท
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to program round this poplib error? cl@isbd.net - 2016-03-10 12:04 +0000
Re: How to program round this poplib error? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-10 12:30 +0000
Re: How to program round this poplib error? cl@isbd.net - 2016-03-10 14:07 +0000
Re: How to program round this poplib error? Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2016-03-10 13:23 +0000
Re: How to program round this poplib error? cl@isbd.net - 2016-03-10 14:09 +0000
Re: How to program round this poplib error? dieter <dieter@handshake.de> - 2016-03-11 10:06 +0100
csiph-web