summaryrefslogtreecommitdiffstats
path: root/Modules/_elementtree.c
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2011-11-01 22:33:14 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2011-11-01 22:33:14 (GMT)
commitf24e7e6c4154178dc8409e4caee33777e166f949 (patch)
tree49acb0b680b7cacd7a0486043ed5ef1faeb98a3a /Modules/_elementtree.c
parentf588dd60ccc5f4bd8a747fb4a9799c00730021cf (diff)
parent91d5193b3ad208f359107512ff12a416c9dbec3b (diff)
downloadcpython-f24e7e6c4154178dc8409e4caee33777e166f949.zip
cpython-f24e7e6c4154178dc8409e4caee33777e166f949.tar.gz
cpython-f24e7e6c4154178dc8409e4caee33777e166f949.tar.bz2
Merge 3.2: issue #2892
Diffstat (limited to 'Modules/_elementtree.c')
-rw-r--r--Modules/_elementtree.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 1fb6038..884e50d 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -3016,6 +3016,7 @@ PyInit__elementtree(void)
" self._file = file\n"
" self._events = []\n"
" self._index = 0\n"
+ " self._error = None\n"
" self.root = self._root = None\n"
" b = cElementTree.TreeBuilder()\n"
" self._parser = cElementTree.XMLParser(b)\n"
@@ -3024,24 +3025,31 @@ PyInit__elementtree(void)
" while 1:\n"
" try:\n"
" item = self._events[self._index]\n"
+ " self._index += 1\n"
+ " return item\n"
" except IndexError:\n"
- " if self._parser is None:\n"
- " self.root = self._root\n"
- " if self._close_file:\n"
- " self._file.close()\n"
- " raise StopIteration\n"
- " # load event buffer\n"
- " del self._events[:]\n"
- " self._index = 0\n"
- " data = self._file.read(16384)\n"
- " if data:\n"
+ " pass\n"
+ " if self._error:\n"
+ " e = self._error\n"
+ " self._error = None\n"
+ " raise e\n"
+ " if self._parser is None:\n"
+ " self.root = self._root\n"
+ " if self._close_file:\n"
+ " self._file.close()\n"
+ " raise StopIteration\n"
+ " # load event buffer\n"
+ " del self._events[:]\n"
+ " self._index = 0\n"
+ " data = self._file.read(16384)\n"
+ " if data:\n"
+ " try:\n"
" self._parser.feed(data)\n"
- " else:\n"
- " self._root = self._parser.close()\n"
- " self._parser = None\n"
+ " except SyntaxError as exc:\n"
+ " self._error = exc\n"
" else:\n"
- " self._index = self._index + 1\n"
- " return item\n"
+ " self._root = self._parser.close()\n"
+ " self._parser = None\n"
" def __iter__(self):\n"
" return self\n"
"cElementTree.iterparse = iterparse\n"