summaryrefslogtreecommitdiff
path: root/bs4/element.py
diff options
context:
space:
mode:
authorColin Watson <cjwatson@canonical.com>2019-11-10 21:23:01 +0000
committerColin Watson <cjwatson@canonical.com>2019-11-10 21:23:01 +0000
commit17ca4508af1ee8ad739b4cf8319e2313c91c5c86 (patch)
tree6dadb06c371b1dd2f7d148d1f99a84cb6f962e45 /bs4/element.py
parent8c57caece563f2c9aea0a6cc86bd5cee3c40877f (diff)
Fix deprecation warning with Python >= 3.7.
Python >= 3.7 issues a deprecation warning when using collections.Callable rather than collections.abc.Callable. Most of Beautiful Soup deals with this by using a conditional import, but the automatic Python 3 conversion apparently translates `callable(obj)` to `isinstance(obj, collections.Callable)` which trips this deprecation warning. `isinstance(obj, Callable)` works fine in Python 2 as well as 3, so just use it directly.
Diffstat (limited to 'bs4/element.py')
-rw-r--r--bs4/element.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/bs4/element.py b/bs4/element.py
index 2001ad5..8684870 100644
--- a/bs4/element.py
+++ b/bs4/element.py
@@ -163,7 +163,7 @@ class PageElement(object):
c = XMLFormatter
else:
c = HTMLFormatter
- if callable(formatter):
+ if isinstance(formatter, Callable):
return c(entity_substitution=formatter)
return c.REGISTRY[formatter]