Fix win_pageant for Python 3 #320

wants to merge 1 commit into


None yet

6 participants


Previously _get_pageant_window_object always returned 0, so pageant was silently ignored.


#56 might be related. Without this patch then pageant definitely doesn't work under Python 3, but #56 doesn't specify which python version.


👍, works fine on Python 3.4

@sherbang @sherbang sherbang Fix win_pageant for Python 3
Previously _get_pageant_window_object always returned 0, so pageant was silently ignored.

Coverage Status

Coverage decreased (-0.12%) when pulling 7461738 on sherbang:patch-1 into e811e71 on paramiko:master.


+1 This is a fix for me too. Tested with 1.15.1

Not sure how this will affect a python2.6 install though.


I don't Python on Windows but yea, we still need to support Python 2.6 (@adamkerz). Should hopefully be as simple as importing the relevant bits from paramiko.py3compat (mostly b() and whatever array operation is most appropriate).

I'll merge this once somebody can +1 a version of the patch that works on 2.6 through 3.4. Thanks!


Ugh, why do people still use and/or care about 2.6? Especially on windows where there are no "enterprisey" distributions forcing you to use ancient versions?


@ThiefMaster There are still plenty of people downloading Python packages on 2.6 according to stats I've seen from PyPI, and a number of stable Linux distributions still in heavy use like CentOS 5/6 also still use them. It's also very little extra work re: 2+3 support, over 2.7.

adamkerz commented Oct 1, 2014

OK, tested with Python 2.6.6, 2.7.6 and 3.4.1. Patch against Paramiko 1.15.1.

Hmm, am I able to upload a patch here? Or do I need to do the GIT push/pull thing (I'm not a GIT user yet)?

lndbrg commented Oct 1, 2014

It would be preferable to do a pull request. But if you just have the diff of your changes you can add them as a comment.

adamkerz commented Oct 1, 2014

OK, in the interest of getting this in, I'll comment the diff. I have a feature to add to fabric (user/group for the put operation) that I will use as a task to get my self "git" sorted.

---  Wed Oct 01 13:45:59 2014
+++  Wed Oct 01 13:12:50 2014
@@ -26,6 +26,7 @@
 import platform
 import struct
 from paramiko.util import *
+from paramiko.py3compat import b

     import _thread as thread # Python 3.x
@@ -43,7 +44,7 @@

 def _get_pageant_window_object():
-    return ctypes.windll.user32.FindWindowA('Pageant', 'Pageant')
+    return ctypes.windll.user32.FindWindowA(b('Pageant'), b('Pageant'))

 def can_talk_to_agent():
@@ -90,7 +91,7 @@
     with pymap:
         # Create an array buffer containing the mapped filename
-        char_buffer = array.array("c", b(map_name) + zero_byte)
+        char_buffer = array.array("b", b(map_name) + zero_byte)
         char_buffer_address, char_buffer_size = char_buffer.buffer_info()
         # Create a string to use for the SendMessage function call
         cds = COPYDATASTRUCT(_AGENT_COPYDATA_ID, char_buffer_size,

Thanks for accepting it in a less desirable way!

lndbrg commented Oct 1, 2014

Created a real PR from the patch.


Rolling into that PR, thanks as usual @lndbrg!

@bitprophet bitprophet closed this Oct 1, 2014
@lndbrg lndbrg added a commit that referenced this pull request Oct 1, 2014
@lndbrg @bitprophet lndbrg + bitprophet Make sure we pass parameters as binary on windows.
This fixes #320 (thanks @adamkerz).
@bitprophet bitprophet added a commit that referenced this pull request Oct 1, 2014
@bitprophet bitprophet Changelog re #320
Closes #409
@sherbang sherbang deleted the sherbang:patch-1 branch Oct 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment