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.

classification
Title: xmlrpc.server assumes sys.stdout will have a buffer attribute
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 3.2
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: ncoghlan Nosy List: loewis, ncoghlan, pitrou, r.david.murray, vstinner
Priority: normal Keywords: patch

Created on 2009-10-18 12:40 by ncoghlan, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_xmlrpc.patch pitrou, 2009-10-21 18:27
Messages (8)
msg94212 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2009-10-18 12:40
The xmlrpc tests were changed to use a StringIO object instead of a
temporary file (this change reflects the corresponding change made on
the 2.x trunk).

The tests then started failing, since xmlrpc.server assumes sys.stdout
will provide the buffer attribute, which is not a valid assumption. From
the io.TestIOBase documentation:

buffer
    The underlying binary buffer (a BufferedIOBase instance) that
TextIOBase deals with. This is not part of the TextIOBase API and may
not exist on some implementations.

Assuming this attribute exists is a bug in xmlrpc.server that should be
fixed.
msg94317 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-10-21 18:27
Well this is in the CGI implementation, and it's reasonable to assume
that CGI will only be used with a real stream. Besides, the encoding
used with stdout must be the xmlrpc encoding (probably utf-8), not the
default encoding of standard streams on the system, which means direct
access to the underlying binary stream must be possible.

(however, _marshaled_dispatch() is quite strange in that it accepts str
but returns bytes)

I propose to fix test_xmlrpc instead so that it uses a BytesIO wrapped
in a TextIOWrapper. Patch included.
msg94469 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-10-26 00:23
I think Antoine's suggestion is reasonable, and that we should apply the
patch to stop the buildbots from failing, but leave this issue open
until someone with more xmlrpc knowledge can respond to Nick and
Antoine's questions.
msg94476 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-10-26 07:51
I agree with Antoine that CGIXML... is right in accessing
sys.stdout.buffer; this really needs binary IO.

Consequentially, his patch also looks right to me; please apply.
msg94479 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-10-26 08:30
Patch applied in r75710.
msg94514 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2009-10-26 21:30
Fine by me (I was very close to changing the test when I first triggered
the problem, but wasn't sure silencing the error was the right thing to do).

Assigning back to myself to add a comment to the relevant line (i.e.
that relying on the buffer attribute being present is a deliberate
design choice).
msg94516 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-10-26 21:46
> Assigning back to myself to add a comment to the relevant line (i.e.
> that relying on the buffer attribute being present is a deliberate
> design choice).

The remaining question, however, is why it doesn't also rely on
stdin.buffer.
msg98591 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-01-31 02:24
antoine's patch (fixing this issue) is commited. Can we close this issue?
History
Date User Action Args
2022-04-11 14:56:54adminsetgithub: 51414
2010-01-31 06:24:20loewissetstatus: open -> closed
stage: needs patch -> resolved
2010-01-31 02:24:34vstinnersetnosy: + vstinner
messages: + msg98591
2009-10-26 21:46:08pitrousetmessages: + msg94516
2009-10-26 21:30:19ncoghlansetassignee: pitrou -> ncoghlan
messages: + msg94514
2009-10-26 08:30:29r.david.murraysetmessages: + msg94479
2009-10-26 07:51:24loewissetassignee: pitrou
resolution: accepted
messages: + msg94476
2009-10-26 00:23:26r.david.murraysetnosy: + r.david.murray
messages: + msg94469
2009-10-21 18:27:46pitrousetfiles: + test_xmlrpc.patch

nosy: + loewis, pitrou
messages: + msg94317

keywords: + patch
2009-10-18 12:40:47ncoghlancreate