[issue45485] datetime.strptime issues message attribute of type 'NoneType' is not callableTraceback
New submission from Freek de Kruijf : 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]): not 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. -- components: Interpreter Core messages: 404018 nosy: f.de.kruijf priority: normal severity: normal status: open title: datetime.strptime issues message attribute of type 'NoneType' is not callableTraceback type: behavior ___ Python tracker <https://bugs.python.org/issue45485> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45485] datetime.strptime issues message attribute of type 'NoneType' is not callableTraceback
Freek de Kruijf added the comment: The python program is called from a surrounding system called domoticz. I will include the python program. -- Added file: https://bugs.python.org/file50360/plugin.py ___ Python tracker <https://bugs.python.org/issue45485> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45485] datetime.strptime issues message attribute of type 'NoneType' is not callableTraceback
Freek de Kruijf added the comment: 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 ; in the bigger context type(a[0]) reports . 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. -- ___ Python tracker <https://bugs.python.org/issue45485> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45485] datetime.strptime issues message attribute of type 'NoneType' is not callableTraceback
Freek de Kruijf added the comment: 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. -- ___ Python tracker <https://bugs.python.org/issue45485> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45485] datetime.strptime issues message attribute of type 'NoneType' is not callableTraceback
Freek de Kruijf added the comment: The content of a[0] is something like '2021-10-15T15:02:11.486' -- ___ Python tracker <https://bugs.python.org/issue45485> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45485] datetime.strptime issues message attribute of type 'NoneType' is not callableTraceback
Freek de Kruijf added the comment: Op zaterdag 16 oktober 2021 00:03:41 CEST schreef u: > Eric V. Smith 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 -- ___ Python tracker <https://bugs.python.org/issue45485> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41759] ElementTree.parse gives error message about missing1 required positional argument: 'source' but it is there
New submission from Freek de Kruijf : In a function definition I have the following piece of code: try: with open(requests,'rt') as f: tree = ElementTree.parse(f) On execution I got: Traceback (most recent call last): File "/srv/www/bin/web.py", line 362, in build_db() File "/srv/www/bin/web.py", line 58, in build_db db_builder.build_DB() File "/srv/www/bin/db_builder.py", line 190, in build_DB tree = ElementTree.parse(f) TypeError: parse() missing 1 required positional argument: 'source' There is an assignment for requests like requests = '..' + os.path.sep + "/etc/signatures.xml" This gives requests the value ..//etc/signatures.xml while the program runs in /srv/www/bin/ When I run the small python script like: import xml.etree.ElementTree as ElementTree with open('/srv/www/etc/signatures.xml','rt') as f: tree = ElementTree.parse(f) all is well. Apparently open(requests,'rt') does not raise an error. -- components: Extension Modules messages: 376706 nosy: f.de.kruijf priority: normal severity: normal status: open title: ElementTree.parse gives error message about missing1 required positional argument: 'source' but it is there type: behavior versions: Python 3.8 ___ Python tracker <https://bugs.python.org/issue41759> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41759] ElementTree.parse gives error message about missing1 required positional argument: 'source' but it is there
Freek de Kruijf added the comment: Op vrijdag 11 september 2020 11:31:29 CEST schreef u: > Serhiy Storchaka added the comment: > > parse() is an instance method. It should be called as tree.parse(f) (where > tree is an instance of ElementTree), not ElementTree.parse(f). > > -- I have no idea how to make tree an instance. Reading the documentation, https://docs.python.org/2/library/xml.etree.elementtree.html, it shows as an example: import xml.etree.ElementTree as ET tree = ET.parse('country_data.xml') which is exactly what the program looks like and what my small python script does without an error. -- fr.gr. Freek de Kruijf -- ___ Python tracker <https://bugs.python.org/issue41759> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41759] ElementTree.parse gives error message about missing1 required positional argument: 'source' but it is there
Freek de Kruijf added the comment: Op vrijdag 11 september 2020 17:06:43 CEST schreef u: > Serhiy Storchaka added the comment: > > It was not clear what you do without code and full traceback. > > The example uses *function* parse() from *module* ElementTree. Your code > seems uses *method* parse() of *class* ElementTree. > > https://docs.python.org/3/library/xml.etree.elementtree.html#xml.etree.Eleme > ntTree.parse > https://docs.python.org/3/library/xml.etree.elementtree.html#xml.etree.Elem > entTree.ElementTree.parse I have very little knowledge about class, instance and the other specific terms used in Python. I just try to use a Python script, I found and need, and ran into this problem. What it does looks simple to me. As simple as the 3 line script I showed, which works. Why does the larger script give this confusing error about a missing argument, which is present? It is a file name or file object as it should. What I understand is that tree becomes an instance. Of what? Is the problem caused by using ElementTree in "import xml.etree.ElementTree as ElementTree". Should I use "import xml.etree.ElementTree as ET" and "tree = ET.parse(f)"? -- fr.gr. Freek de Kruijf -- ___ Python tracker <https://bugs.python.org/issue41759> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com