This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: datetime.strptime issues message attribute of type 'NoneType' is not callableTraceback
Type: behavior Stage: resolved
Components: Interpreter Core Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, f.de.kruijf
Priority: normal Keywords:

Created on 2021-10-15 13:59 by f.de.kruijf, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
plugin.py f.de.kruijf, 2021-10-15 21:23 python program with the problem part in line 259
Messages (9)
msg404018 - (view) Author: Freek de Kruijf (f.de.kruijf) * Date: 2021-10-15 13:59
In a piece of code I have
pT = datetime.strptime(a[0],"%Y-%m-%dT%H:%M:%S.%f")
When I check type(a[0]) I got type(a[0]): <class 'str'> not <type 'str'>
In this case I get: message attribute of type 'NoneType' is not callableTraceback
When I use str(a[0]) instead of a[0], the issue is gone.
a[0] behaves elsewhere as a string without the surrounding str().
This piece of code is rather local in a larger program.
msg404026 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-10-15 14:44
Please provide a code snippet we can run that demonstrates the problem.
msg404047 - (view) Author: Freek de Kruijf (f.de.kruijf) * Date: 2021-10-15 21:23
The python program is called from a surrounding system called domoticz. I will include the python program.
msg404049 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-10-15 21:28
If you want us to check if there's a bug in Python here, please reduce this to 5 or 10 lines, with no external dependencies. As it is, we cannot run this code.

You also need to show how you run the program, what version of Python you're using, and what system you're running this on.
msg404053 - (view) Author: Freek de Kruijf (f.de.kruijf) * Date: 2021-10-15 21:44
When I try it in a few lines, there is no problem. So it is an issue in this bigger context with class definitions.
In the few lines type(a[0]) reports <type 'str'>; in the bigger context type(a[0]) reports <class 'str´>. I have no idea how to reduce this issue in a few lines. It must have to do with the use of class in the bigger program, I assume. I found a workaround, so it up to you to analyze this further. I have only a vary basic knowledge about Python.
msg404054 - (view) Author: Freek de Kruijf (f.de.kruijf) * Date: 2021-10-15 21:48
About what version of Python is used, I don't know. Both 2.7.18 and 3.6.12 are installed. I use the program on a Raspberry Pi 4B with openSUSE Leap 15.3.
msg404055 - (view) Author: Freek de Kruijf (f.de.kruijf) * Date: 2021-10-15 21:53
The content of a[0] is something like '2021-10-15T15:02:11.486'
msg404056 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-10-15 22:03
It sounds like you're using python 2.7, which is unsupported.

You've not even shown us what line produces the error you're seeing. I don't see "type(a[0])" anywhere in the code you posted.

Lacking a way to reproduce this on our own with python 3.x, I'm going to have to close this issue.
msg404064 - (view) Author: Freek de Kruijf (f.de.kruijf) * Date: 2021-10-16 08:49
Op zaterdag 16 oktober 2021 00:03:41 CEST schreef u:
> Eric V. Smith <eric@trueblade.com> added the comment:
> 
> It sounds like you're using python 2.7, which is unsupported.
> 
> You've not even shown us what line produces the error you're seeing. I don't
> see "type(a[0])" anywhere in the code you posted.
> 
> Lacking a way to reproduce this on our own with python 3.x, I'm going to
> have to close this issue.

I am sorry I can't be of more help.

-- 
fr.gr.

Freek de Kruijf
History
Date User Action Args
2022-04-11 14:59:51adminsetgithub: 89648
2021-10-16 09:44:14eric.smithsetstatus: open -> closed
resolution: not a bug
stage: resolved
2021-10-16 08:49:07f.de.kruijfsetmessages: + msg404064
2021-10-15 22:03:41eric.smithsetmessages: + msg404056
2021-10-15 21:53:08f.de.kruijfsetmessages: + msg404055
2021-10-15 21:48:23f.de.kruijfsetmessages: + msg404054
2021-10-15 21:44:43f.de.kruijfsetmessages: + msg404053
2021-10-15 21:28:49eric.smithsetmessages: + msg404049
2021-10-15 21:23:07f.de.kruijfsetfiles: + plugin.py

messages: + msg404047
2021-10-15 14:44:37eric.smithsetnosy: + eric.smith
messages: + msg404026
2021-10-15 13:59:25f.de.kruijfcreate