summaryrefslogtreecommitdiff
path: root/bs4/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'bs4/__init__.py')
-rw-r--r--bs4/__init__.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/bs4/__init__.py b/bs4/__init__.py
index b74acee..a53048d 100644
--- a/bs4/__init__.py
+++ b/bs4/__init__.py
@@ -186,6 +186,8 @@ class BeautifulSoup(Tag):
# system. Just let it go.
pass
if is_file:
+ if isinstance(markup, unicode):
+ markup = markup.encode("utf8")
warnings.warn(
'"%s" looks like a filename, not markup. You should probably open this file and pass the filehandle into Beautiful Soup.' % markup)
if markup[:5] == "http:" or markup[:6] == "https:":
@@ -193,6 +195,8 @@ class BeautifulSoup(Tag):
# Python 3 otherwise.
if ((isinstance(markup, bytes) and not b' ' in markup)
or (isinstance(markup, unicode) and not u' ' in markup)):
+ if isinstance(markup, unicode):
+ markup = markup.encode("utf8")
warnings.warn(
'"%s" looks like a URL. Beautiful Soup is not an HTTP client. You should probably use an HTTP client to get the document behind the URL, and feed that document to Beautiful Soup.' % markup)