This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sdaoden
Recipients amaury.forgeotdarc, georg.brandl, r.david.murray, sdaoden, twouters
Date 2011-04-09.13:27:31
SpamBayes Score 6.1062266e-16
Marked as misclassified No
Message-id <20110409132704.GA52452@sherwood.local>
In-reply-to <20110408155603.GA10017@sherwood.local>
Content
..
> So here is the rewritten .yeah-2.diff. 
..
> I added more tests (i'm absolutely convinced that the tests i've 
> found in test_mailbox.py really find all the cutting edges <;). 
> On my box this is clean. 

Haha, now this is *very* funny!

______
Traceback (most recent call last):
...
  File "/Users/steffen/usr/opt/py3k/lib/python3.3/email/parser.py", line 104, in parse
    return self.parser.parse(fp, headersonly)
  File "/Users/steffen/usr/opt/py3k/lib/python3.3/mailbox.py", line 1900, in flush
    raise io.UnsupportedOperation('flush')
Exception: io.UnsupportedOperation: flush
______

So, don't ask me why anyone tries to flush a readonly ProxyFile! 
BytesParser wraps this in TextIO, and in Modules/_io/textio.c i find:

c_STRVAR(textiowrapper_doc,
    "\n"
    "If line_buffering is True, a call to flush is implied when a call to\n"
    "write contains a newline character."
    );
..
typedef struct
{
..
    /* Reads and writes are internally buffered in order to speed things up.
       However, any read will first flush the write buffer if itsn't empty.
..
} textio;

No reason to call flush. 
So i replaced flush() and got this:

______
...
  File "/Users/steffen/usr/opt/py3k/lib/python3.3/email/parser.py", line 104, in parse
    return self.parser.parse(fp, headersonly)
  File "/Users/steffen/usr/opt/py3k/lib/python3.3/email/parser.py", line 48, in parse
    data = fp.read(8192)
Exception: AttributeError: '_PartialFile' object has no attribute 'read1'
______

Nice.  It seems that deriving _ProxyFile from io.RawIOBase will 
not work correctly with the current EMail package because 
BytesParser uses TextIOWrapper expects io.BufferedIOBase. 
Regardless of the fact i think TextIOWrapper should be 
configurable not to close the "buffer" - s...!

Anyway, it's seems not to be practical to implement ProxyFile 
*correctly*.  Therefore i'll attach yeah-3.diff which falsely 
ignores calls to flush(). 
To make this s... rock it is now also derived from 
io.BufferedIOBase, thus i've reintroduced read1() which - true - 
is now also tested!  *YES IT CAN*!
Nice weekend.
Files
File name Uploaded
11700.yeah-3.diff sdaoden, 2011-04-09.13:27:31
History
Date User Action Args
2011-04-09 13:27:33sdaodensetrecipients: + sdaoden, twouters, georg.brandl, amaury.forgeotdarc, r.david.murray
2011-04-09 13:27:32sdaodenlinkissue11700 messages
2011-04-09 13:27:31sdaodencreate