python-gnupg 0.4.1 & pathlib

175 views
Skip to first unread message

Maurice Kemmann

unread,
Feb 5, 2018, 4:51:35 PM2/5/18
to python-gnupg
Hello,

there seems to be a problem with the combination in the subject. The following code:


import gnupg
from pathlib import Path
gpg = gnupg.GPG(gnupghome = Path("/Users/mucki/Cert/"))

produces the follwowing error:

>> python.exe .\gnupg-test.py

Traceback (most recent call last):
  File ".\gnupg-test.py", line 3, in <module>
    gpg = gnupg.GPG(gnupghome = Path("/Users/mucki/Cert/"))
  File "C:\Users\mucki\AppData\Local\Programs\Python\Python36\lib\site-packages\gnupg.py", line 755, in __init__
    p = self._open_subprocess(["--version"])
  File "C:\Users\mucki\AppData\Local\Programs\Python\Python36\lib\site-packages\gnupg.py", line 831, in _open_subprocess
    startupinfo=si)
  File "C:\Users\mucki\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\mucki\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 964, in _execute_child
    args = list2cmdline(args)
  File "C:\Users\mucki\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 461, in list2cmdline
    needquote = (" " in arg) or ("\t" in arg) or not arg
TypeError: argument of type 'WindowsPath' is not iterable

I use pathlib for correct ans os independent handling of paths. The example was with Windows 10, on a linux box i got a similiar error "PosixPath is not iterable".

Is there something wrong with my code?

Thanks in advance,

Maurice

Vinay Sajip

unread,
Feb 5, 2018, 4:56:53 PM2/5/18
to python-gnupg
You will see that the error occurs in the Python standard library - in the standard library subprocess module. I don't think you can pass in path instances. I don't believe your problem is related to python-gnupg. Try a test case with just subprocess and see how you get on. Ask for help on the python-list mailing list.

Regards,

Vinay Sajip

Maurice Kemmann

unread,
Feb 6, 2018, 3:12:59 AM2/6/18
to python-gnupg
Dear Vinay,


Am Montag, 5. Februar 2018 22:56:53 UTC+1 schrieb Vinay Sajip:

You will see that the error occurs in the Python standard library - in the standard library subprocess module. I don't think you can pass in path instances. I don't believe your problem is related to python-gnupg. Try a test case with just subprocess and see how you get on. Ask for help on the python-list mailing list.

as a beginner in Python i am not understanding the subprocess module yet but you are right as show in the error message.

Thanks for the quick response.

Maurice

Vinay Sajip

unread,
Feb 7, 2018, 3:37:35 AM2/7/18
to python-gnupg
Just convert it (the Path instance) to a string before passing it in.

Regards,

Vinay Sajip

Maurice Kemmann

unread,
Feb 7, 2018, 9:48:10 AM2/7/18
to python-gnupg
Hi Vinay,


Am Mittwoch, 7. Februar 2018 09:37:35 UTC+1 schrieb Vinay Sajip:
Just convert it (the Path instance) to a string before passing it in.

yes right, got it yesterday. I read the documentation not deep enough. :-) Sorry.

Thx 4 help,

Maurice
Reply all
Reply to author
Forward
0 new messages