New submission from Frederick Ross <madhad...@gmail.com>:

When parsing something like '<a>x</a><a>y</a>' with xml.etree.ElementTree, or 
'{}{}' with json, these parser throw exceptions instead of reading a single 
element of the kind they understand off the stream (or throwing an exception if 
there is no element they understand) and leaving the stream in a sane state.

So I should be able to write

import xml.etree.ElementTree as et
import StringIO
s = StringIO.StringIO("<a>x</a><a>y</a>")
elem1 = et.parse(s)
elem2 = et.parse(s)

and have elem1 correspond to "<a>x</a>" and elem2 correspond to "<a>y</a>".

At the very least, if the parsers refuse to parse partial streams, they should 
at least not destroy the streams.

----------
components: Library (Lib)
messages: 161068
nosy: Frederick.Ross
priority: normal
severity: normal
status: open
title: json and ElementTree parsers misbehave on streams containing more than a 
single object
versions: Python 2.6, Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14852>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to