mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
Merged revisions 77717 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r77717 | tarek.ziade | 2010-01-24 01:33:32 +0100 (Sun, 24 Jan 2010) | 1 line Fixed #7748: now upload and register commands don't need to force the encoding anymore : DistributionMetada returns utf8 strings ........
This commit is contained in:
parent
6411a53d7d
commit
495517cd38
5 changed files with 24 additions and 17 deletions
|
@ -261,7 +261,6 @@ Your selection [default 1]: ''', log.INFO)
|
||||||
if type(value) not in (type([]), type( () )):
|
if type(value) not in (type([]), type( () )):
|
||||||
value = [value]
|
value = [value]
|
||||||
for value in value:
|
for value in value:
|
||||||
value = unicode(value).encode("utf-8")
|
|
||||||
body.write(sep_boundary)
|
body.write(sep_boundary)
|
||||||
body.write('\nContent-Disposition: form-data; name="%s"'%key)
|
body.write('\nContent-Disposition: form-data; name="%s"'%key)
|
||||||
body.write("\n\n")
|
body.write("\n\n")
|
||||||
|
|
|
@ -133,7 +133,7 @@ class upload(PyPIRCCommand):
|
||||||
value = value[1]
|
value = value[1]
|
||||||
else:
|
else:
|
||||||
fn = ""
|
fn = ""
|
||||||
value = str(value)
|
|
||||||
body.write(sep_boundary)
|
body.write(sep_boundary)
|
||||||
body.write('\nContent-Disposition: form-data; name="%s"'%key)
|
body.write('\nContent-Disposition: form-data; name="%s"'%key)
|
||||||
body.write(fn)
|
body.write(fn)
|
||||||
|
|
|
@ -1114,18 +1114,20 @@ class DistributionMetadata:
|
||||||
self._write_list(file, 'Obsoletes', self.get_obsoletes())
|
self._write_list(file, 'Obsoletes', self.get_obsoletes())
|
||||||
|
|
||||||
def _write_field(self, file, name, value):
|
def _write_field(self, file, name, value):
|
||||||
|
file.write('%s: %s\n' % (name, self._encode_field(value)))
|
||||||
if isinstance(value, unicode):
|
|
||||||
value = value.encode(PKG_INFO_ENCODING)
|
|
||||||
else:
|
|
||||||
value = str(value)
|
|
||||||
file.write('%s: %s\n' % (name, value))
|
|
||||||
|
|
||||||
def _write_list (self, file, name, values):
|
def _write_list (self, file, name, values):
|
||||||
|
|
||||||
for value in values:
|
for value in values:
|
||||||
self._write_field(file, name, value)
|
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 ----------------------------------------
|
# -- Metadata query methods ----------------------------------------
|
||||||
|
|
||||||
def get_name (self):
|
def get_name (self):
|
||||||
|
@ -1138,21 +1140,20 @@ class DistributionMetadata:
|
||||||
return "%s-%s" % (self.get_name(), self.get_version())
|
return "%s-%s" % (self.get_name(), self.get_version())
|
||||||
|
|
||||||
def get_author(self):
|
def get_author(self):
|
||||||
return self.author or "UNKNOWN"
|
return self._encode_field(self.author) or "UNKNOWN"
|
||||||
|
|
||||||
def get_author_email(self):
|
def get_author_email(self):
|
||||||
return self.author_email or "UNKNOWN"
|
return self.author_email or "UNKNOWN"
|
||||||
|
|
||||||
def get_maintainer(self):
|
def get_maintainer(self):
|
||||||
return self.maintainer or "UNKNOWN"
|
return self._encode_field(self.maintainer) or "UNKNOWN"
|
||||||
|
|
||||||
def get_maintainer_email(self):
|
def get_maintainer_email(self):
|
||||||
return self.maintainer_email or "UNKNOWN"
|
return self.maintainer_email or "UNKNOWN"
|
||||||
|
|
||||||
def get_contact(self):
|
def get_contact(self):
|
||||||
return (self.maintainer or
|
return (self._encode_field(self.maintainer) or
|
||||||
self.author or
|
self._encode_field(self.author) or "UNKNOWN")
|
||||||
"UNKNOWN")
|
|
||||||
|
|
||||||
def get_contact_email(self):
|
def get_contact_email(self):
|
||||||
return (self.maintainer_email or
|
return (self.maintainer_email or
|
||||||
|
@ -1167,10 +1168,10 @@ class DistributionMetadata:
|
||||||
get_licence = get_license
|
get_licence = get_license
|
||||||
|
|
||||||
def get_description(self):
|
def get_description(self):
|
||||||
return self.description or "UNKNOWN"
|
return self._encode_field(self.description) or "UNKNOWN"
|
||||||
|
|
||||||
def get_long_description(self):
|
def get_long_description(self):
|
||||||
return self.long_description or "UNKNOWN"
|
return self._encode_field(self.long_description) or "UNKNOWN"
|
||||||
|
|
||||||
def get_keywords(self):
|
def get_keywords(self):
|
||||||
return self.keywords or []
|
return self.keywords or []
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""Tests for distutils.command.upload."""
|
"""Tests for distutils.command.upload."""
|
||||||
|
# -*- encoding: utf8 -*-
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
@ -95,7 +96,7 @@ class uploadTestCase(PyPIRCCommandTestCase):
|
||||||
self.write_file(self.rc, PYPIRC_LONG_PASSWORD)
|
self.write_file(self.rc, PYPIRC_LONG_PASSWORD)
|
||||||
|
|
||||||
# lets run it
|
# lets run it
|
||||||
pkg_dir, dist = self.create_dist(dist_files=dist_files)
|
pkg_dir, dist = self.create_dist(dist_files=dist_files, author=u'dédé')
|
||||||
cmd = upload(dist)
|
cmd = upload(dist)
|
||||||
cmd.ensure_finalized()
|
cmd.ensure_finalized()
|
||||||
cmd.run()
|
cmd.run()
|
||||||
|
@ -104,7 +105,8 @@ class uploadTestCase(PyPIRCCommandTestCase):
|
||||||
res = _CONNECTIONS[-1]
|
res = _CONNECTIONS[-1]
|
||||||
|
|
||||||
headers = res.headers
|
headers = res.headers
|
||||||
self.assertEquals(headers['Content-length'], '2086')
|
self.assert_('dédé' in res.body)
|
||||||
|
self.assertEquals(headers['Content-length'], '2085')
|
||||||
self.assertTrue(headers['Content-type'].startswith('multipart/form-data'))
|
self.assertTrue(headers['Content-type'].startswith('multipart/form-data'))
|
||||||
|
|
||||||
method, request = res.requests[-1]
|
method, request = res.requests[-1]
|
||||||
|
|
|
@ -53,6 +53,11 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #7748: Since unicode values are supported for some metadata options
|
||||||
|
in Distutils, the DistributionMetadata get_* methods will now return an utf-8
|
||||||
|
encoded string for them. This ensure that the upload and register commands
|
||||||
|
send the right values to PyPI without any error.
|
||||||
|
|
||||||
- Issue #1670765: Prevent email.generator.Generator from re-wrapping
|
- Issue #1670765: Prevent email.generator.Generator from re-wrapping
|
||||||
headers in multipart/signed MIME parts, which fixes one of the sources of
|
headers in multipart/signed MIME parts, which fixes one of the sources of
|
||||||
invalid modifications to such parts by Generator.
|
invalid modifications to such parts by Generator.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue