[New-bugs-announce] [issue27400] Datetime NoneType after calling Py_Finalize and Py_Initialize

Denny Weinberg report at bugs.python.org
Mon Jun 27 09:49:18 EDT 2016


New submission from Denny Weinberg:

After calling Py_Finalize and Py_Initialize I get the message "attribute of type 'NoneType' is not callable" on the datetime.strptime method.

Example:
from datetime import datetime
s = '20160505 160000'
refdatim = datetime.strptime(s, '%Y%m%d %H%M%S')

The first call works fine but it crashes after the re initialization.

Workaround:
from datetime import datetime
s = '20160505 160000'
try:
    refdatim = datetime.strptime(s, '%Y%m%d %H%M%S')
except TypeError:
    import time
    refdatim = datetime.fromtimestamp(time.mktime(time.strptime(s, '%Y%m%d %H%M%S')))

Related Issue: Issue17408 ("second python execution fails when embedding")

----------
components: Interpreter Core
messages: 269379
nosy: Denny Weinberg, palm.kevin
priority: normal
severity: normal
status: open
title: Datetime NoneType after calling Py_Finalize and Py_Initialize
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27400>
_______________________________________


More information about the New-bugs-announce mailing list