From b0bc0b9a2f0e39bf936a7b89b10eae3f218bf674 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Wed, 24 Mar 2021 17:54:10 -0400 Subject: [PATCH] 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. --- python/lammps/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/lammps/__init__.py b/python/lammps/__init__.py index 48839273c5..e6ffd779a9 100644 --- a/python/lammps/__init__.py +++ b/python/lammps/__init__.py @@ -15,7 +15,7 @@ from .pylammps import * # convert module string version to numeric version def get_version_number(): - from datetime import datetime + import time from sys import version_info vstring = None if version_info.major == 3 and version_info.minor >= 8: @@ -32,7 +32,7 @@ def get_version_number(): if not vstring: return 0 - d = datetime.strptime(vstring, "%d%b%Y") - return d.year*10000 + d.month*100 + d.day + t = time.strptime(vstring, "%d%b%Y") + return t.tm_year*10000 + t.tm_mon*100 + t.tm_mday __version__ = get_version_number()