Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c3b6ac7

Browse files
committed
Fix libc_ver(): libc_ver() was reading sys.executable
in binary mode and comparing the content to strings, which failed. Now the bytes get decoded into unicode using latin-1 (the comparison compares ASCII strings only anyway, and we don't want the decoding to fail).
1 parent 94093ff commit c3b6ac7

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Lib/platform.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ def libc_ver(executable=sys.executable,lib='',version='',
145145
# able to open symlinks for reading
146146
executable = os.path.realpath(executable)
147147
f = open(executable,'rb')
148-
binary = f.read(chunksize)
148+
binary = f.read(chunksize).decode('latin-1')
149149
pos = 0
150150
while 1:
151151
m = _libc_search.search(binary,pos)
152152
if not m:
153-
binary = f.read(chunksize)
153+
binary = f.read(chunksize).decode('latin-1')
154154
if not binary:
155155
break
156156
pos = 0

0 commit comments

Comments
 (0)