Skip to content

Commit 646ff0b

Browse files
jorisvandenbosschejreback
authored andcommitted
PERF: avoid printing object in Dtype.construct_from_string message (#26776)
1 parent 8ff488a commit 646ff0b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pandas/core/dtypes/base.py

+2
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ def construct_from_string(cls, string: str):
214214
... raise TypeError("Cannot construct a '{}' from "
215215
... "'{}'".format(cls.__name__, string))
216216
"""
217+
if not isinstance(string, str):
218+
raise TypeError("Expects a string, got {}".format(type(string)))
217219
if string != cls.name:
218220
raise TypeError("Cannot construct a '{}' from '{}'".format(
219221
cls.__name__, string))

0 commit comments

Comments
 (0)