Skip to content

Commit

Permalink
Make _cleanup more robust, fixes timClicks#12
Browse files Browse the repository at this point in the history
At times, PDFMiner does not initialise all of the cleanup attributes. This can lead to subtle `AttributeError` 
bugs that application devs can't fix. Instead of using `del self.attr`, we now simply assign all attributes to 
`None`. This has the effect of freeing memory upon garbage collection while avoiding tedious errors being
thrown.
  • Loading branch information
timClicks committed Nov 24, 2014
1 parent 759fb3b commit 78da0c5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/slate/slate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from operator import attrgetter
try:
from cStringIO import StringIO
except ImportError:
Expand Down Expand Up @@ -60,11 +61,11 @@ def _cleanup(self):
and images and the objects that were needed to parse the
PDF.
"""
del self.device
del self.doc
del self.parser
del self.resmgr
del self.interpreter
self.device = None
self.doc = None
self.parser = None
self.resmgr = None
self.interpreter = None

def text(self, clean=True):
"""
Expand Down

0 comments on commit 78da0c5

Please sign in to comment.