Fix win_pageant for Python 3 #320

Closed
wants to merge 1 commit into
from

Projects

None yet

6 participants

@sherbang

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

@sherbang

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

@ThiefMaster
Contributor

👍, 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.
7461738
@coveralls

Coverage Status

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

@adamkerz

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

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

@bitprophet
Member

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!

@ThiefMaster
Contributor

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?

@bitprophet
Member

@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
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
Contributor
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
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.

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

 try:
     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:
         pymap.write(msg)
         # 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
Contributor
lndbrg commented Oct 1, 2014

Created a real PR from the patch.

@bitprophet
Member

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).
a381b08
@bitprophet bitprophet added a commit that referenced this pull request Oct 1, 2014
@bitprophet bitprophet Changelog re #320
Closes #409
cf8921e
@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