[Python-Dev] [Python-checkins] r88197 - python/branches/py3k/Lib/email/generator.py

Victor Stinner victor.stinner at haypocalc.com
Wed Jan 26 10:57:28 CET 2011


Hi,

Le mardi 25 janvier 2011 à 18:07 -0800, Brett Cannon a écrit :
> This broke the buildbots (R. David Murray thinks you may have
> forgotten to call super() in the 'payload is None' branch). Are you
> getting code reviews and fully running the test suite before
> committing? We are in RC.
> (...)
> > -        if _has_surrogates(msg._payload):
> > -            self.write(msg._payload)
> > +        payload = msg.get_payload()
> > +        if payload is None:
> > +            return
> > +        if _has_surrogates(payload):
> > +            self.write(payload)

I didn't realize that such minor change can do anything harmful: the
parent method (Generator._handle_text) has exaclty the same test. If
msg._payload is None, call the parent method with None does nothing. But
_has_surrogates() doesn't support None.

The problem is not the test of None, but replacing msg._payload by
msg.get_payload(). I thought that get_payload() was a dummy getter
reading self._payload, but I was completly wrong :-)

I was stupid to not run at least test_email, sorry. And no, I didn't ask
for a review, because I thought that such minor change cannot be
harmful.

FYI the commit is related indirectly to #9124 (Mailbox module should use
binary I/O, not text I/O).

Victor



More information about the Python-Dev mailing list