Package: dh-python
Version: 3.20180326
Severity: normal
Tags: patch

Hi, I was checking if the python package python-logbook was reproducible using
reprotest and the gitlab pipeline was failing randomly (as you can see
here[0]). So, I've dug into it a little bit and I found the function so2pyver
was converting the bytes into string using the hardcoded `utf-8` as encoding.
As it's a process output which depends on the current locale settings, it's
mandatory use that encoding to get a proper transformation from bytes to string.
Please find the patch attached, I've tried using salsa and propose an MR but it
seems to be disabled.

Cheers,

[0] https://salsa.debian.org/debian/logbook/-/jobs/22804

-- 
TiN
From 7b8b7d2b3fff2fa310963afa9d0484026c3bb206 Mon Sep 17 00:00:00 2001
From: Agustin Henze <t...@aayy.com.ar>
Date: Thu, 7 Jun 2018 18:16:27 -0300
Subject: [PATCH] Use current locale for encoding the output process

---
 dhpython/tools.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/dhpython/tools.py b/dhpython/tools.py
index c2d0c2b..142b5b0 100644
--- a/dhpython/tools.py
+++ b/dhpython/tools.py
@@ -22,6 +22,7 @@
 import logging
 import os
 import re
+import locale
 from datetime import datetime
 from glob import glob
 from pickle import dumps
@@ -134,7 +135,8 @@ def so2pyver(fpath):
 
     cmd = "readelf -Wd '%s'" % fpath
     process = Popen(cmd, stdout=PIPE, shell=True)
-    match = SHAREDLIB_RE.search(str(process.stdout.read(), encoding='utf-8'))
+    encoding = locale.getdefaultlocale()[1]
+    match = SHAREDLIB_RE.search(str(process.stdout.read(), encoding=encoding))
     if match:
         return Version(match.groups()[0])
 
-- 
2.17.1

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to