[New-bugs-announce] [issue10950] ServerProxy returns bad XML

Beau report at bugs.python.org
Wed Jan 19 19:19:05 CET 2011

New submission from Beau <beaumartinez at gmail.com>:

xmlrpc.client.ServerProxy calls that return XML (ie, the a non-marshallable type) give bad XML, with \" (backslash then double quote characters, '\\"'; not escaped double quote) in place of ", and \' in place of '. Ampersands aren't XML-escaped either.

(I have only tested this with Last.fm's API but I have made calls that return marshallable types with no problem, so I'm assuming the issue lies with ServerProxy and not Last.fm's XML-RPC servers.)

The following test code, identical to that in the attached file illustrates the bug; it throws an xml.parsers.expat.ExpatError as the XML is bad:

# Get a Last.fm user's library.
# http://www.last.fm/api/show?service=323

import xmlrpc.client
import xml.etree

server = xmlrpc.client.ServerProxy('http://ws.audioscrobbler.com/2.0/')
parameters = {'api_key': 'b25b959554ed76058ac220b7b2e0a026', 'user': 'joanofarctan', 'page': 1}

tracks = server.library.getTracks(parameters)
tracks_xml = xml.etree.ElementTree.parse(tracks)

# Should get "xml.parsers.expat.ExpatError: XML declaration not well-formed: line 1, column 14".
# (Line 1, column 14 is a backslash: <?xml version=\"1.0\" encoding=\"utf-8\"?>.)

I'm running "Python 3.1.2 (r312:79149, Mar 20 2010, 22:55:39) [MSC v.1500 64 bit (AMD64)] on win32".

components: Library (Lib)
files: serverproxy_test.py
messages: 126552
nosy: beaumartinez
priority: normal
severity: normal
status: open
title: ServerProxy returns bad XML
type: compile error
versions: Python 3.1
Added file: http://bugs.python.org/file20455/serverproxy_test.py

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list