Skip to content

Commit

Permalink
Merge pull request #526 from fortable1999/master
Browse files Browse the repository at this point in the history
SegmentWriter.__repr__ support printing unsuceesful initialized object
  • Loading branch information
fortable1999 authored Jan 9, 2019
2 parents 441f729 + b43e5a4 commit f4e4ea9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ formats = zip,gztar
push = sdist bdist_wheel upload
pushdocs = build_sphinx upload_sphinx

[pytest]
[tool:pytest]
; --tb= traceback print mode (long/short/line/native/no)
addopts = -rs --tb=native

Expand Down
7 changes: 6 additions & 1 deletion src/whoosh/writing.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,12 @@ def __init__(self, ix, poolclass=None, timeout=0.0, delay=0.1, _lk=True,
self.mergetype = None

def __repr__(self):
return "<%s %r>" % (self.__class__.__name__, self.newsegment)
# Author: Ronald Evers
# Origin bitbucket issue: https://bitbucket.org/mchaput/whoosh/issues/483
# newsegment might not be set due to LockError
# so use getattr to be safe
return "<%s %r>" % (self.__class__.__name__,
getattr(self, 'newsegment', None))

def _check_state(self):
if self.is_closed:
Expand Down

0 comments on commit f4e4ea9

Please sign in to comment.