mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-14 00:21:08 +00:00
Decode name from environment or from gecos with the locale's encoding and add
corresponding regression test; fixes handling of non-ascii developer name like mine with e.g. syncpackage using it with dpkg-genchanges -e.
This commit is contained in:
parent
bcdc6abbf8
commit
0aaa0f1f4a
@ -21,6 +21,7 @@ import re
|
||||
import shlex
|
||||
import socket
|
||||
import sys
|
||||
import locale
|
||||
|
||||
from ubuntutools.logger import Logger
|
||||
|
||||
@ -173,4 +174,9 @@ def ubu_email(name=None, email=None, export=True):
|
||||
if export:
|
||||
os.environ['DEBFULLNAME'] = name
|
||||
os.environ['DEBEMAIL'] = email
|
||||
|
||||
# decode env var or gecos raw string with the current locale's encoding
|
||||
encoding = locale.getdefaultlocale()[1]
|
||||
if encoding:
|
||||
name = name.decode(encoding)
|
||||
return name, email
|
||||
|
@ -1,4 +1,5 @@
|
||||
# test_config.py - Test suite for ubuntutools.config
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2010, Stefano Rivera <stefanor@ubuntu.com>
|
||||
#
|
||||
@ -210,3 +211,8 @@ class UbuEmailTestCase(unittest.TestCase):
|
||||
os.environ['DEBEMAIL'] = orig = '%s <%s>' % (name, email)
|
||||
self.assertEqual(ubu_email(), (name, email))
|
||||
self.assertEqual(os.environ['DEBEMAIL'], orig)
|
||||
|
||||
def test_unicode_name(self):
|
||||
os.environ['DEBFULLNAME'] = name = 'Jöe Déveloper'
|
||||
os.environ['DEBEMAIL'] = email = 'joe@example.net'
|
||||
self.assertEqual(ubu_email(), (name.decode('utf-8'), email))
|
||||
|
Loading…
x
Reference in New Issue
Block a user