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.

Author f.de.kruijf
Recipients f.de.kruijf
Date 2020-09-11.09:22:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1599816171.47.0.67185595118.issue41759@roundup.psfhosted.org>
In-reply-to
Content
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 <module>
     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.
History
Date User Action Args
2020-09-11 09:22:51f.de.kruijfsetrecipients: + f.de.kruijf
2020-09-11 09:22:51f.de.kruijfsetmessageid: <1599816171.47.0.67185595118.issue41759@roundup.psfhosted.org>
2020-09-11 09:22:51f.de.kruijflinkissue41759 messages
2020-09-11 09:22:51f.de.kruijfcreate