summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/dist.py
diff options
context:
space:
mode:
authorTarek Ziadé <ziade.tarek@gmail.com>2010-01-24 00:33:32 (GMT)
committerTarek Ziadé <ziade.tarek@gmail.com>2010-01-24 00:33:32 (GMT)
commitf14c7fc33da8ba3aa28bbb7b0305ea12ab30be09 (patch)
treec3a88b29baa9ee925ad8181c4853afe0ed582987 /Lib/distutils/dist.py
parentaa98058cc44ba20f35c106d20918c6196b737561 (diff)
downloadcpython-f14c7fc33da8ba3aa28bbb7b0305ea12ab30be09.zip
cpython-f14c7fc33da8ba3aa28bbb7b0305ea12ab30be09.tar.gz
cpython-f14c7fc33da8ba3aa28bbb7b0305ea12ab30be09.tar.bz2
Fixed #7748: now upload and register commands don't need to force the encoding anymore : DistributionMetada returns utf8 strings
Diffstat (limited to 'Lib/distutils/dist.py')
-rw-r--r--Lib/distutils/dist.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
index f20a92a..5dbdaef 100644
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -1139,16 +1139,19 @@ class DistributionMetadata:
self._write_list(file, 'Obsoletes', self.get_obsoletes())
def _write_field(self, file, name, value):
- if isinstance(value, unicode):
- value = value.encode(PKG_INFO_ENCODING)
- else:
- value = str(value)
- file.write('%s: %s\n' % (name, value))
+ file.write('%s: %s\n' % (name, self._encode_field(value)))
def _write_list (self, file, name, values):
for value in values:
self._write_field(file, name, value)
+ def _encode_field(self, value):
+ if value is None:
+ return None
+ if isinstance(value, unicode):
+ return value.encode(PKG_INFO_ENCODING)
+ return str(value)
+
# -- Metadata query methods ----------------------------------------
def get_name(self):
@@ -1161,19 +1164,20 @@ class DistributionMetadata:
return "%s-%s" % (self.get_name(), self.get_version())
def get_author(self):
- return self.author or "UNKNOWN"
+ return self._encode_field(self.author) or "UNKNOWN"
def get_author_email(self):
return self.author_email or "UNKNOWN"
def get_maintainer(self):
- return self.maintainer or "UNKNOWN"
+ return self._encode_field(self.maintainer) or "UNKNOWN"
def get_maintainer_email(self):
return self.maintainer_email or "UNKNOWN"
def get_contact(self):
- return self.maintainer or self.author or "UNKNOWN"
+ return (self._encode_field(self.maintainer) or
+ self._encode_field(self.author) or "UNKNOWN")
def get_contact_email(self):
return self.maintainer_email or self.author_email or "UNKNOWN"
@@ -1186,10 +1190,10 @@ class DistributionMetadata:
get_licence = get_license
def get_description(self):
- return self.description or "UNKNOWN"
+ return self._encode_field(self.description) or "UNKNOWN"
def get_long_description(self):
- return self.long_description or "UNKNOWN"
+ return self._encode_field(self.long_description) or "UNKNOWN"
def get_keywords(self):
return self.keywords or []