Skip to content

Commit 904a2ef

Browse files
committed
Issue python#20900: distutils register command now decodes HTTP responses correctly
Initial patch by ingrid.
1 parent 87a8bcc commit 904a2ef

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎Lib/distutils/command/register.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ def post_to_server(self, data, auth=None):
296296
result = 500, str(e)
297297
else:
298298
if self.show_response:
299-
data = result.read()
299+
data = self._read_pypi_response(result)
300300
result = 200, 'OK'
301301
if self.show_response:
302-
dashes = '-' * 75
303-
self.announce('%s%r%s' % (dashes, data, dashes))
302+
msg = '\n'.join(('-' * 75, data, '-' * 75))
303+
self.announce(msg, log.INFO)
304304
return result

‎Lib/distutils/tests/test_register.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,20 @@ def test_list_classifiers(self):
301301
results = self.get_logs(INFO)
302302
self.assertEqual(results, ['running check', 'xxx'])
303303

304+
def test_show_response(self):
305+
# test that the --show-response option return a well formatted response
306+
cmd = self._get_cmd()
307+
inputs = Inputs('1', 'tarek', 'y')
308+
register_module.input = inputs.__call__
309+
cmd.show_response = 1
310+
try:
311+
cmd.run()
312+
finally:
313+
del register_module.input
314+
315+
results = self.get_logs(INFO)
316+
self.assertEqual(results[3], 75 * '-' + '\nxxx\n' + 75 * '-')
317+
304318

305319
def test_suite():
306320
return unittest.makeSuite(RegisterTestCase)

‎Lib/distutils/tests/test_upload.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def test_upload(self):
140140

141141
# The PyPI response body was echoed
142142
results = self.get_logs(INFO)
143-
self.assertIn('xyzzy\n', results[-1])
143+
self.assertEqual(results[-1], 75 * '-' + '\nxyzzy\n' + 75 * '-')
144144

145145
def test_upload_fails(self):
146146
self.next_msg = "Not Found"

‎Misc/NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ Core and Builtins
139139
Library
140140
-------
141141

142+
- Issue #20900: distutils register command now decodes HTTP responses
143+
correctly. Initial patch by ingrid.
144+
142145
- A new version of typing.py provides several new classes and
143146
features: @overload outside stubs, Reversible, DefaultDict, Text,
144147
ContextManager, Type[], NewType(), TYPE_CHECKING, and numerous bug

0 commit comments

Comments
 (0)