[diffoscope] 01/01: Tidy diffoscope.locale module and add logging message.

Chris Lamb chris at chris-lamb.co.uk
Sun Jan 1 15:58:22 CET 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit 484d9c2ab00aeab25c5a0971fd199fd38fd5c094
Author: Chris Lamb <lamby at debian.org>
Date:   Sun Jan 1 14:04:30 2017 +0000

    Tidy diffoscope.locale module and add logging message.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 diffoscope/locale.py | 41 ++++++++++++++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/diffoscope/locale.py b/diffoscope/locale.py
index 0131ef5..6919f9b 100644
--- a/diffoscope/locale.py
+++ b/diffoscope/locale.py
@@ -20,18 +20,37 @@
 import os
 import time
 
+from .logging import logger
+
 
 def set_locale():
-    """Normalize locale so external tool gives us stable and properly
-    encoded output"""
-
-    for var in ['LANGUAGE', 'LC_ALL']:
-        if var in os.environ:
-            del os.environ[var]
-    for var in ['LANG', 'LC_NUMERIC', 'LC_TIME', 'LC_COLLATE', 'LC_MONETARY',
-                'LC_MESSAGES', 'LC_PAPER', 'LC_NAME', 'LC_ADDRESS',
-                'LC_TELEPHONE', 'LC_MEASUREMENT', 'LC_IDENTIFICATION']:
-        os.environ[var] = 'C'
-    os.environ['LC_CTYPE'] = 'C.UTF-8'
+    """
+    Normalise locale so external tool gives us stable and properly encoded
+    output.
+    """
+
+    logger.debug("Normalising locale, timezone, etc.")
+
+    for x in ('LANGUAGE', 'LC_ALL'):
+        os.environ.pop(x, None)
+
+    for x in (
+        'LANG',
+        'LC_NUMERIC',
+        'LC_TIME',
+        'LC_COLLATE',
+        'LC_MONETARY',
+        'LC_MESSAGES',
+        'LC_PAPER',
+        'LC_NAME',
+        'LC_ADDRESS',
+        'LC_TELEPHONE',
+        'LC_MEASUREMENT',
+        'LC_IDENTIFICATION',
+    ):
+        os.environ[x] = 'C'
+
     os.environ['TZ'] = 'UTC'
+    os.environ['LC_CTYPE'] = 'C.UTF-8'
+
     time.tzset()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list