Skip to content

Commit 2e3c4ea

Browse files
committed
BUG: fix html reading for bytes types in py3
1 parent ffc819e commit 2e3c4ea

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pandas/io/html.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
from pandas.io.common import _is_url, urlopen, parse_url
1717
from pandas.io.parsers import TextParser
18-
from pandas.compat import (lrange, lmap, u, string_types, iteritems, text_type,
19-
raise_with_traceback)
18+
from pandas.compat import (lrange, lmap, u, string_types, iteritems,
19+
raise_with_traceback, binary_type)
2020
from pandas.core import common as com
2121
from pandas import Series
2222

@@ -51,6 +51,9 @@
5151
_RE_WHITESPACE = re.compile(r'[\r\n]+|\s{2,}')
5252

5353

54+
char_types = string_types + (binary_type,)
55+
56+
5457
def _remove_whitespace(s, regex=_RE_WHITESPACE):
5558
"""Replace extra whitespace inside of a string with a single space.
5659
@@ -114,13 +117,13 @@ def _read(obj):
114117
text = url.read()
115118
elif hasattr(obj, 'read'):
116119
text = obj.read()
117-
elif isinstance(obj, string_types):
120+
elif isinstance(obj, char_types):
118121
text = obj
119122
try:
120123
if os.path.isfile(text):
121124
with open(text, 'rb') as f:
122125
return f.read()
123-
except TypeError:
126+
except (TypeError, ValueError):
124127
pass
125128
else:
126129
raise TypeError("Cannot read object of type %r" % type(obj).__name__)

0 commit comments

Comments
 (0)