Skip to content

Commit

Permalink
Catch AttributeError in Python 2.6.
Browse files Browse the repository at this point in the history
  • Loading branch information
James Socol committed Jul 11, 2012
1 parent 1d0e907 commit fefe5d8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bleach/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@

DEFAULT_CALLBACKS = [linkify_callbacks.nofollow]

PY_26 = (sys.version_info < (2, 7))
RECURSION_EXCEPTION = RuntimeError if not PY_26 else AttributeError


def clean(text, tags=ALLOWED_TAGS, attributes=ALLOWED_ATTRIBUTES,
styles=ALLOWED_STYLES, strip=False, strip_comments=True):
Expand Down Expand Up @@ -289,7 +292,7 @@ def link_repl(match):

try:
linkify_nodes(forest)
except RuntimeError, e:
except (RECURSION_EXCEPTION), e:
# If we hit the max recursion depth, just return what we've got.
log.error('Probable recursion error: %r' % e, exc_info=sys.exc_info())

Expand Down

0 comments on commit fefe5d8

Please sign in to comment.