Skip to content

Commit

Permalink
Fix get_best_auth for Python 3
Browse files Browse the repository at this point in the history
All self.entries items are byte strings, but get_best_auth receives
Unicode strings. Convert them to bytes before comparing.

This fixes a bug that prevented python3-xlib to find X11 cookies in
Xauthority, thus not allowing to use it without `xhost +`.
  • Loading branch information
ntrrgc committed Feb 23, 2014
1 parent db36d6c commit 59da845
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Xlib/xauth.py
Expand Up @@ -97,7 +97,7 @@ def __getitem__(self, i):
return self.entries[i]

def get_best_auth(self, family, address, dispno,
types = ( "MIT-MAGIC-COOKIE-1", )):
types = ( b"MIT-MAGIC-COOKIE-1", )):

"""Find an authentication entry matching FAMILY, ADDRESS and
DISPNO.
Expand All @@ -110,7 +110,8 @@ def get_best_auth(self, family, address, dispno,
otherwise XNoAuthError is raised.
"""

num = str(dispno)
num = str(dispno).encode()
address = address.encode()

matches = {}

Expand Down

0 comments on commit 59da845

Please sign in to comment.