From d9680fca7e55f0119a0c40b6b49d26c5e68f54b0 Mon Sep 17 00:00:00 2001 From: Yusuke Shinyama Date: Sat, 14 Jun 2014 14:44:53 +0900 Subject: [PATCH] Plane: preserve the object order so that the test result is always consistent. --- pdfminer/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pdfminer/utils.py b/pdfminer/utils.py index 3e85cba..f83f6cf 100644 --- a/pdfminer/utils.py +++ b/pdfminer/utils.py @@ -245,6 +245,7 @@ def matrix2str((a, b, c, d, e, f)): class Plane(object): def __init__(self, bbox, gridsize=50): + self._seq = [] # preserve the object order. self._objs = set() self._grid = {} self.gridsize = gridsize @@ -255,7 +256,7 @@ class Plane(object): return ('' % list(self)) def __iter__(self): - return iter(self._objs) + return ( obj for obj in self._seq if obj in self._objs ) def __len__(self): return len(self._objs) @@ -290,6 +291,7 @@ class Plane(object): else: r = self._grid[k] r.append(obj) + self._seq.append(obj) self._objs.add(obj) return