Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Catch AttributeError in Python 2.6.

  • Loading branch information...
commit fefe5d864665d07d7254df0dad0cbbc4e19cbc7a 1 parent 1d0e907
James Socol authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 bleach/__init__.py
View
5 bleach/__init__.py
@@ -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):
@@ -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())
Please sign in to comment.
Something went wrong with that request. Please try again.