Resync optparse with Optik 1.5.3: minor tweaks for/to tests.
diff --git a/Lib/optparse.py b/Lib/optparse.py
index ef382aa..62d2f7e 100644
--- a/Lib/optparse.py
+++ b/Lib/optparse.py
@@ -16,7 +16,7 @@
# Python developers: please do not make changes to this file, since
# it is automatically generated from the Optik source code.
-__version__ = "1.5.1+"
+__version__ = "1.5.3"
__all__ = ['Option',
'SUPPRESS_HELP',
@@ -75,9 +75,9 @@
# This file was generated from:
-# Id: option_parser.py 522 2006-06-11 16:22:03Z gward
+# Id: option_parser.py 527 2006-07-23 15:21:30Z greg
# Id: option.py 522 2006-06-11 16:22:03Z gward
-# Id: help.py 509 2006-04-20 00:58:24Z gward
+# Id: help.py 527 2006-07-23 15:21:30Z greg
# Id: errors.py 509 2006-04-20 00:58:24Z gward
try:
@@ -1631,7 +1631,10 @@
# used by test suite
def _get_encoding(self, file):
- return getattr(file, "encoding", sys.getdefaultencoding())
+ encoding = getattr(file, "encoding", None)
+ if not encoding:
+ encoding = sys.getdefaultencoding()
+ return encoding
def print_help(self, file=None):
"""print_help(file : file = stdout)
diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py
index 9fcbe85..4582fa7 100644
--- a/Lib/test/test_optparse.py
+++ b/Lib/test/test_optparse.py
@@ -1460,10 +1460,11 @@
make_option("--foo", action="append", type="string", dest='foo',
help="store FOO in the foo list for later fooing"),
]
- # The parser constructor looks at the COLUMNS envar. We need to
- # restore the original value after the parser is constructed, else
- # that's a permanent change possibly affecting other tests, and
- # definitely affecting these tests when they're run multiple times.
+
+ # We need to set COLUMNS for the OptionParser constructor, but
+ # we must restore its original value -- otherwise, this test
+ # screws things up for other tests when it's part of the Python
+ # test suite.
orig_columns = os.environ.get('COLUMNS')
os.environ['COLUMNS'] = str(columns)
try: