reverted distutils its 3.1 state. All new work is now happening in disutils2, and distutils is now feature-frozen.
diff --git a/Lib/distutils/config.py b/Lib/distutils/config.py
index fe41ce9..5b625f3 100644
--- a/Lib/distutils/config.py
+++ b/Lib/distutils/config.py
@@ -4,6 +4,7 @@
 that uses .pypirc in the distutils.command package.
 """
 import os
+import sys
 from configparser import ConfigParser
 
 from distutils.cmd import Command
@@ -59,6 +60,8 @@
         if os.path.exists(rc):
             self.announce('Using PyPI login from %s' % rc)
             repository = self.repository or self.DEFAULT_REPOSITORY
+            realm = self.realm or self.DEFAULT_REALM
+
             config = ConfigParser()
             config.read(rc)
             sections = config.sections()