Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ba5c31b

Browse files
committed
make one strptime call at import of jsonutil
avoids thread safety issues (Python bug #7980)
1 parent 0da2644 commit ba5c31b

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

IPython/utils/jsonutil.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
ISO8601 = "%Y-%m-%dT%H:%M:%S.%f"
3737
ISO8601_PAT=re.compile(r"^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(\.\d{1,6})?Z?([\+\-]\d{2}:?\d{2})?$")
3838

39+
# holy crap, strptime is not threadsafe.
40+
# Calling it once at import seems to help.
41+
datetime.strptime("1", "%d")
42+
3943
#-----------------------------------------------------------------------------
4044
# Classes and functions
4145
#-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)