File tree 1 file changed +13
-10
lines changed
1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -686,16 +686,19 @@ def construct_from_string(cls, string):
686
686
>>> DatetimeTZDtype.construct_from_string('datetime64[ns, UTC]')
687
687
datetime64[ns, UTC]
688
688
"""
689
- msg = "Could not construct DatetimeTZDtype from '{}'"
690
- try :
691
- match = cls ._match .match (string )
692
- if match :
693
- d = match .groupdict ()
694
- return cls (unit = d ['unit' ], tz = d ['tz' ])
695
- except Exception :
696
- # TODO(py3): Change this pass to `raise TypeError(msg) from e`
697
- pass
698
- raise TypeError (msg .format (string ))
689
+ if isinstance (string , compat .string_types ):
690
+ msg = "Could not construct DatetimeTZDtype from '{}'"
691
+ try :
692
+ match = cls ._match .match (string )
693
+ if match :
694
+ d = match .groupdict ()
695
+ return cls (unit = d ['unit' ], tz = d ['tz' ])
696
+ except Exception :
697
+ # TODO(py3): Change this pass to `raise TypeError(msg) from e`
698
+ pass
699
+ raise TypeError (msg .format (string ))
700
+ else :
701
+ raise TypeError ("Could not construct DatetimeTZDtype" )
699
702
700
703
def __unicode__ (self ):
701
704
return "datetime64[{unit}, {tz}]" .format (unit = self .unit , tz = self .tz )
You can’t perform that action at this time.
0 commit comments