[Python-checkins] r86396 - in python/branches/release31-maint: Lib/test/script_helper.py Lib/test/test_warnings.py Misc/NEWS
antoine.pitrou
python-checkins at python.org
Wed Nov 10 15:01:16 CET 2010
Author: antoine.pitrou
Date: Wed Nov 10 15:01:16 2010
New Revision: 86396
Log:
I'm only backporting the tests (which run fine), as well as
a shortened version of Lib/test/script_helper.py.
Merged revisions 86395 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r86395 | antoine.pitrou | 2010-11-10 14:55:25 +0100 (mer., 10 nov. 2010) | 4 lines
Issue #10372: Import the warnings module only after the IO library is
initialized, so as to avoid bootstrap issues with the '-W' option.
........
Added:
python/branches/release31-maint/Lib/test/script_helper.py
- copied, changed from r86395, /python/branches/py3k/Lib/test/script_helper.py
Modified:
python/branches/release31-maint/ (props changed)
python/branches/release31-maint/Lib/test/test_warnings.py
python/branches/release31-maint/Misc/NEWS
Copied: python/branches/release31-maint/Lib/test/script_helper.py (from r86395, /python/branches/py3k/Lib/test/script_helper.py)
==============================================================================
--- /python/branches/py3k/Lib/test/script_helper.py (original)
+++ python/branches/release31-maint/Lib/test/script_helper.py Wed Nov 10 15:01:16 2010
@@ -11,8 +11,6 @@
import shutil
import zipfile
-from imp import source_from_cache
-from test.support import make_legacy_pyc
# Executing the interpreter in a subprocess
def _assert_python(expected_success, *args, **env_vars):
@@ -89,27 +87,6 @@
script_file.close()
return script_name
-def make_zip_script(zip_dir, zip_basename, script_name, name_in_zip=None):
- zip_filename = zip_basename+os.extsep+'zip'
- zip_name = os.path.join(zip_dir, zip_filename)
- zip_file = zipfile.ZipFile(zip_name, 'w')
- if name_in_zip is None:
- parts = script_name.split(os.sep)
- if len(parts) >= 2 and parts[-2] == '__pycache__':
- legacy_pyc = make_legacy_pyc(source_from_cache(script_name))
- name_in_zip = os.path.basename(legacy_pyc)
- script_name = legacy_pyc
- else:
- name_in_zip = os.path.basename(script_name)
- zip_file.write(script_name, name_in_zip)
- zip_file.close()
- #if test.support.verbose:
- # zip_file = zipfile.ZipFile(zip_name, 'r')
- # print 'Contents of %r:' % zip_name
- # zip_file.printdir()
- # zip_file.close()
- return zip_name, os.path.join(zip_name, name_in_zip)
-
def make_pkg(pkg_dir, init_source=''):
os.mkdir(pkg_dir)
make_script(pkg_dir, '__init__', init_source)
Modified: python/branches/release31-maint/Lib/test/test_warnings.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_warnings.py (original)
+++ python/branches/release31-maint/Lib/test/test_warnings.py Wed Nov 10 15:01:16 2010
@@ -7,6 +7,7 @@
import tempfile
import subprocess
from test import support
+from test.script_helper import assert_python_ok
from test import warning_tests
@@ -394,6 +395,22 @@
self.module._setoption('error::Warning::0')
self.assertRaises(UserWarning, self.module.warn, 'convert to error')
+ def test_improper_option(self):
+ # Same as above, but check that the message is printed out when
+ # the interpreter is executed. This also checks that options are
+ # actually parsed at all.
+ rc, out, err = assert_python_ok("-Wxxx", "-c", "pass")
+ self.assertIn(b"Invalid -W option ignored: invalid action: 'xxx'", err)
+
+ def test_warnings_bootstrap(self):
+ # Check that the warnings module does get loaded when -W<some option>
+ # is used (see issue #10372 for an example of silent bootstrap failure).
+ rc, out, err = assert_python_ok("-Wi", "-c",
+ "import sys; sys.modules['warnings'].warn('foo', RuntimeWarning)")
+ # '-Wi' was observed
+ self.assertFalse(out.strip())
+ self.assertNotIn(b'RuntimeWarning', err)
+
class CWCmdLineTests(BaseTest, WCmdLineTests):
module = c_warnings
Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS (original)
+++ python/branches/release31-maint/Misc/NEWS Wed Nov 10 15:01:16 2010
@@ -10,6 +10,9 @@
Core and Builtins
-----------------
+- Issue #10372: Import the warnings module only after the IO library is
+ initialized, so as to avoid bootstrap issues with the '-W' option.
+
- Issue #10221: dict.pop(k) now has a key error message that includes the
missing key (same message d[k] returns for missing keys).
More information about the Python-checkins
mailing list