NisHera
8 years agoValued Contributor
python error in datetime
have a function
import datetime def myfun(): string_date = '2016-11-03' myTime =datetime.datetime.strptime(string_date, "%Y-%m-%d")
in TC 12 (nothing else in the script)
This gives me error:-
TypeError attribute of type 'NoneType' is not callable
this dos not happen only for first time I open TC
any Idea?
It is known Python problem not related to TestComplete.
https://bugs.python.org/issue27400
The workaround is to use alternate version of strptime. It is mentionned in documentation :
Conversely, the datetime.strptime() class method creates a datetime object from a string representing a date and time and a corresponding format string. datetime.strptime(date_string, format) is equivalent to datetime(*(time.strptime(date_string, format)[0:6])).import datetime import time def myfun(): string_date = "2016-11-03" format = "%Y-%m-%d" try: res = datetime.datetime.strptime(string_date, format) except TypeError: res = datetime.datetime(*(time.strptime(string_date, format)[0:6])) Log.Message(res)