Use time.strptime instead of datetime.strptime

Embedding the Python interpreter multiple times in the same process can
cause this issue due to import caching. https://bugs.python.org/issue27400
This seems to be avoidable by using the time module instead.
This commit is contained in:
Richard Berger
2021-03-24 17:54:10 -04:00
parent 81e8676c7e
commit b0bc0b9a2f

View File

@ -15,7 +15,7 @@ from .pylammps import *
# convert module string version to numeric version # convert module string version to numeric version
def get_version_number(): def get_version_number():
from datetime import datetime import time
from sys import version_info from sys import version_info
vstring = None vstring = None
if version_info.major == 3 and version_info.minor >= 8: if version_info.major == 3 and version_info.minor >= 8:
@ -32,7 +32,7 @@ def get_version_number():
if not vstring: if not vstring:
return 0 return 0
d = datetime.strptime(vstring, "%d%b%Y") t = time.strptime(vstring, "%d%b%Y")
return d.year*10000 + d.month*100 + d.day return t.tm_year*10000 + t.tm_mon*100 + t.tm_mday
__version__ = get_version_number() __version__ = get_version_number()