python-gnupg 0.4.1 and pathlib

38 views
Skip to first unread message

Maurice Kemmann

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

i am a Python newbie and playing around with python-gupg. Working on Linux and Windows 10 i use pathlib for os independent work with paths. My problem, python-gnupg seems not to work properly with pathlib (or it is my fault?):


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


 With this code i get the follwing 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


Could you give me a hint?

By the way, hard coding the path with Windows specific backslashes ( \\Users\\mucki\\Cert\\ ) works of course.

Thanks in advance,

Maurice

Vinay Sajip

unread,
Feb 5, 2018, 4:57:25 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
Reply all
Reply to author
Forward
0 new messages