classification
Title: imaplib.py MAXLINE value is too low for gmail
Type: enhancement Stage: needs patch
Components: email, Library (Lib) Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: arnt, barry, python-dev, r.david.murray
Priority: normal Keywords:

Created on 2015-03-12 15:39 by arnt, last changed 2015-03-24 14:29 by arnt.

Files
File name Uploaded Description Edit
0001-Increase-IMAP-line-length-limit.patch arnt, 2015-03-12 15:39 Patch to solve.
Messages (9)
msg237950 - (view) Author: Arnt Gulbrandsen (arnt) * Date: 2015-03-12 15:39
http://stackoverflow.com/q/28923997 and various other SO questions point out that imaplib's _MAXLINE value is a bit behind the times. Fine for 1997, when people had 10MB mailbox quotas, not so fine for the age of gmail.

I'm tired of seeing those questions, so the attached patch increases the limit without abolishing it completely.

There are also other issues in imaplib, but I fix just this one now, to test the waters so to speak.

FWIW, I've signed the contributor form, just in case.
msg237967 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-03-12 17:47
Gmail breaks the standards again, eh?  I suppose we'll have to accommodate them ;)
msg237985 - (view) Author: Arnt Gulbrandsen (arnt) * Date: 2015-03-12 20:54
The RFC in question is 2683, which isn't a standard, it's just advice.

What gmail breaks is the expectation that mailboxes and seach results are smallish. If you run a python script on gmail and it runs a search, the result can be a great deal bigger than the author of RFC2683 foresaw.
msg237988 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-03-12 21:32
Sorry, I was being a facetious, but despite the smiley that wasn't clear.  I *have* run into a number of cases where gmail violates the standard, but I wasn't really serious about this case.
msg238933 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-03-22 20:07
Now that I've had time to look at this, I see that in fact RFC2683 says nothing about what value MAXLINE should have, unless one is reasoning by analogy.  It is concerned with *command line* lengths from the client to the server, not about server responses.  It seems as though we really should be handling more or less arbitrary length lines in the server response.

I'll bump up the limit in the meantime.
msg238937 - (view) Author: Roundup Robot (python-dev) Date: 2015-03-22 20:21
New changeset a56aa567072c by R David Murray in branch '2.7':
#23647: Increase imaplib's MAXLINE to accommodate modern mailbox sizes.
https://hg.python.org/cpython/rev/a56aa567072c

New changeset c1348ada8fc6 by R David Murray in branch '3.4':
#23647: Increase imaplib's MAXLINE to accommodate modern mailbox sizes.
https://hg.python.org/cpython/rev/c1348ada8fc6

New changeset be6c4569f845 by R David Murray in branch 'default':
Merge: #23647: Increase imaplib's MAXLINE to accommodate modern mailbox sizes.
https://hg.python.org/cpython/rev/be6c4569f845
msg238990 - (view) Author: Arnt Gulbrandsen (arnt) * Date: 2015-03-23 08:47
You're entirely right. I should've reread 2683 too (a decade has passed since I read that).

The danger with accepting the unlimited line length is that batch scripts might accept an infinitely large batch. Which is a matter of python culture, really.

(This has been a very positive experience.)
msg239123 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-03-24 14:10
Yes, I agree that that is a concern.  What should probably happen is that the maximum line length be a settable parameter with a "reasonable" default.  It is too bad that (unlike say the SMTP protocol) the imap protocol does not address this directly.
msg239128 - (view) Author: Arnt Gulbrandsen (arnt) * Date: 2015-03-24 14:29
Length limits has actually been discussed and rejected; noone had a proposal that solved more problems than it introduced.
History
Date User Action Args
2015-03-24 14:29:22arntsetmessages: + msg239128
2015-03-24 14:10:13r.david.murraysetmessages: + msg239123
2015-03-23 08:47:08arntsetmessages: + msg238990
2015-03-22 20:35:43r.david.murraysetkeywords: - patch
stage: commit review -> needs patch
2015-03-22 20:21:20python-devsetnosy: + python-dev
messages: + msg238937
2015-03-22 20:07:02r.david.murraysetmessages: + msg238933
2015-03-12 21:32:19r.david.murraysetmessages: + msg237988
2015-03-12 20:54:01arntsetmessages: + msg237985
2015-03-12 17:47:26r.david.murraysetstage: commit review
2015-03-12 17:47:06r.david.murraysettitle: imaplib.py MAXLINE value is too low for 2015 (patch attached) -> imaplib.py MAXLINE value is too low for gmail
nosy: + barry, r.david.murray

messages: + msg237967

versions: + Python 3.5
components: + email
2015-03-12 15:39:25arntcreate