@@ -30,6 +30,7 @@ from util cimport (is_integer_object, is_float_object, is_datetime64_object,
30
30
is_timedelta64_object, INT64_MAX)
31
31
cimport util
32
32
33
+ from cpython.datetime cimport PyTZInfo_Check
33
34
# this is our datetime.pxd
34
35
from datetime cimport (
35
36
pandas_datetimestruct,
@@ -68,7 +69,7 @@ from .tslibs.parsing import parse_datetime_string
68
69
69
70
cimport cython
70
71
71
- from pandas.compat import iteritems, callable
72
+ from pandas.compat import iteritems
72
73
73
74
import collections
74
75
import warnings
@@ -373,8 +374,24 @@ class Timestamp(_Timestamp):
373
374
FutureWarning )
374
375
freq = offset
375
376
377
+ if tzinfo is not None :
378
+ if not PyTZInfo_Check(tzinfo):
379
+ # tzinfo must be a datetime.tzinfo object, GH#17690
380
+ raise TypeError (' tzinfo must be a datetime.tzinfo object, '
381
+ ' not %s ' % type (tzinfo))
382
+ elif tz is not None :
383
+ raise ValueError (' Can provide at most one of tz, tzinfo' )
384
+ elif ts_input is not _no_input:
385
+ raise ValueError (' When creating a Timestamp with this type '
386
+ ' of inputs, the `tzfinfo` argument is '
387
+ ' ignored. Use `tz` instead.' )
388
+
376
389
if ts_input is _no_input:
377
390
# User passed keyword arguments.
391
+ if tz is not None :
392
+ raise ValueError (' When creating a Timestamp from component '
393
+ ' elements, the `tz` argument is ignored. '
394
+ ' Use `tzinfo` instead.' )
378
395
return Timestamp(datetime(year, month, day, hour or 0 ,
379
396
minute or 0 , second or 0 ,
380
397
microsecond or 0 , tzinfo),
0 commit comments