fixed #4394 make the storage of the password optional in .pypirc
diff --git a/Lib/distutils/command/register.py b/Lib/distutils/command/register.py
index bf7be96..40661d8 100644
--- a/Lib/distutils/command/register.py
+++ b/Lib/distutils/command/register.py
@@ -173,19 +173,23 @@
log.INFO)
# possibly save the login
- if not self.has_config and code == 200:
- self.announce(('I can store your PyPI login so future '
- 'submissions will be faster.'), log.INFO)
- self.announce('(the login will be stored in %s)' % \
- self._get_rc_file(), log.INFO)
-
- choice = 'X'
- while choice.lower() not in 'yn':
- choice = raw_input('Save your login (y/N)?')
- if not choice:
- choice = 'n'
- if choice.lower() == 'y':
- self._store_pypirc(username, password)
+ if code == 200:
+ if self.has_config:
+ # sharing the password in the distribution instance
+ # so the upload command can reuse it
+ self.distribution.password = password
+ else:
+ self.announce(('I can store your PyPI login so future '
+ 'submissions will be faster.'), log.INFO)
+ self.announce('(the login will be stored in %s)' % \
+ self._get_rc_file(), log.INFO)
+ choice = 'X'
+ while choice.lower() not in 'yn':
+ choice = raw_input('Save your login (y/N)?')
+ if not choice:
+ choice = 'n'
+ if choice.lower() == 'y':
+ self._store_pypirc(username, password)
elif choice == '2':
data = {':action': 'user'}
diff --git a/Lib/distutils/command/upload.py b/Lib/distutils/command/upload.py
index 8805d41..e30347e 100644
--- a/Lib/distutils/command/upload.py
+++ b/Lib/distutils/command/upload.py
@@ -50,6 +50,11 @@
self.repository = config['repository']
self.realm = config['realm']
+ # getting the password from the distribution
+ # if previously set by the register command
+ if not self.password and self.distribution.password:
+ self.password = self.distribution.password
+
def run(self):
if not self.distribution.dist_files:
raise DistutilsOptionError("No dist file created in earlier command")