diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ast.py | 1 | ||||
-rw-r--r-- | Lib/bdb.py | 2 | ||||
-rw-r--r-- | Lib/inspect.py | 2 | ||||
-rwxr-xr-x | Lib/pdb.py | 8 | ||||
-rwxr-xr-x | Lib/platform.py | 33 | ||||
-rw-r--r-- | Lib/test/test_platform.py | 34 | ||||
-rw-r--r-- | Lib/test/test_urllib.py | 4 |
7 files changed, 41 insertions, 43 deletions
@@ -26,6 +26,7 @@ :license: Python License. """ from _ast import * +from _ast import __version__ def parse(expr, filename='<unknown>', mode='exec'): @@ -319,6 +319,8 @@ class Bdb: while t is not None: stack.append((t.tb_frame, t.tb_lineno)) t = t.tb_next + if f is None: + i = max(0, len(stack) - 1) return stack, i # diff --git a/Lib/inspect.py b/Lib/inspect.py index 2b0f96e..df1d4b6 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -826,7 +826,7 @@ def getargvalues(frame): 'varargs' and 'varkw' are the names of the * and ** arguments or None. 'locals' is the locals dictionary of the given frame.""" args, varargs, varkw = getargs(frame.f_code) - return args, varargs, varkw, frame.f_locals + return ArgInfo(args, varargs, varkw, frame.f_locals) def joinseq(seq): if len(seq) == 1: @@ -1220,9 +1220,7 @@ def post_mortem(t=None): p = Pdb() p.reset() - while t.tb_next is not None: - t = t.tb_next - p.interaction(t.tb_frame, t) + p.interaction(None, t) def pm(): post_mortem(sys.last_traceback) @@ -1285,9 +1283,7 @@ def main(): print("Uncaught exception. Entering post mortem debugging") print("Running 'cont' or 'step' will restart the program") t = sys.exc_info()[2] - while t.tb_next is not None: - t = t.tb_next - pdb.interaction(t.tb_frame,t) + pdb.interaction(None, t) print("Post mortem debugger finished. The "+mainpyfile+" will be restarted") diff --git a/Lib/platform.py b/Lib/platform.py index 740983b..c898dd1 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -266,24 +266,6 @@ def _parse_release_file(firstline): id = '' return '', version, id -def _test_parse_release_file(): - - for input, output in ( - # Examples of release file contents: - ('SuSE Linux 9.3 (x86-64)', ('SuSE Linux ', '9.3', 'x86-64')) - ('SUSE LINUX 10.1 (X86-64)', ('SUSE LINUX ', '10.1', 'X86-64')) - ('SUSE LINUX 10.1 (i586)', ('SUSE LINUX ', '10.1', 'i586')) - ('Fedora Core release 5 (Bordeaux)', ('Fedora Core', '5', 'Bordeaux')) - ('Red Hat Linux release 8.0 (Psyche)', ('Red Hat Linux', '8.0', 'Psyche')) - ('Red Hat Linux release 9 (Shrike)', ('Red Hat Linux', '9', 'Shrike')) - ('Red Hat Enterprise Linux release 4 (Nahant)', ('Red Hat Enterprise Linux', '4', 'Nahant')) - ('CentOS release 4', ('CentOS', '4', None)) - ('Rocks release 4.2.1 (Cydonia)', ('Rocks', '4.2.1', 'Cydonia')) - ): - parsed = _parse_release_file(input) - if parsed != output: - print((input, parsed)) - def linux_distribution(distname='', version='', id='', supported_dists=_supported_dists, @@ -1357,21 +1339,6 @@ def _sys_version(sys_version=None): _sys_version_cache[sys_version] = result return result -def _test_sys_version(): - - _sys_version_cache.clear() - for input, output in ( - ('2.4.3 (#1, Jun 21 2006, 13:54:21) \n[GCC 3.3.4 (pre 3.3.5 20040809)]', - ('CPython', '2.4.3', '', '', '1', 'Jun 21 2006 13:54:21', 'GCC 3.3.4 (pre 3.3.5 20040809)')), - ('IronPython 1.0.60816 on .NET 2.0.50727.42', - ('IronPython', '1.0.60816', '', '', '', '', '.NET 2.0.50727.42')), - ('IronPython 1.0 (1.0.61005.1977) on .NET 2.0.50727.42', - ('IronPython', '1.0.0', '', '', '', '', '.NET 2.0.50727.42')), - ): - parsed = _sys_version(input) - if parsed != output: - print((input, parsed)) - def python_implementation(): """ Returns a string identifying the Python implementation. diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 4b4c0fa..a18d48b 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -115,6 +115,40 @@ class PlatformTest(unittest.TestCase): executable = executable + '.exe' res = platform.libc_ver(sys.executable) + def test_parse_release_file(self): + + for input, output in ( + # Examples of release file contents: + ('SuSE Linux 9.3 (x86-64)', ('SuSE Linux ', '9.3', 'x86-64')), + ('SUSE LINUX 10.1 (X86-64)', ('SUSE LINUX ', '10.1', 'X86-64')), + ('SUSE LINUX 10.1 (i586)', ('SUSE LINUX ', '10.1', 'i586')), + ('Fedora Core release 5 (Bordeaux)', ('Fedora Core', '5', 'Bordeaux')), + ('Red Hat Linux release 8.0 (Psyche)', ('Red Hat Linux', '8.0', 'Psyche')), + ('Red Hat Linux release 9 (Shrike)', ('Red Hat Linux', '9', 'Shrike')), + ('Red Hat Enterprise Linux release 4 (Nahant)', ('Red Hat Enterprise Linux', '4', 'Nahant')), + ('CentOS release 4', ('CentOS', '4', None)), + ('Rocks release 4.2.1 (Cydonia)', ('Rocks', '4.2.1', 'Cydonia')), + ): + self.assertEqual(platform._parse_release_file(input), output) + + def test_sys_version(self): + + platform._sys_version_cache.clear() + for input, output in ( + ('2.4.3 (#1, Jun 21 2006, 13:54:21) \n[GCC 3.3.4 (pre 3.3.5 20040809)]', + ('CPython', '2.4.3', '', '', '1', 'Jun 21 2006 13:54:21', 'GCC 3.3.4 (pre 3.3.5 20040809)')), + ('IronPython 1.0.60816 on .NET 2.0.50727.42', + ('IronPython', '1.0.60816', '', '', '', '', '.NET 2.0.50727.42')), + ('IronPython 1.0 (1.0.61005.1977) on .NET 2.0.50727.42', + ('IronPython', '1.0.0', '', '', '', '', '.NET 2.0.50727.42')), + ): + # branch and revision are not "parsed", but fetched + # from sys.subversion. Ignore them + (name, version, branch, revision, buildno, builddate, compiler) \ + = platform._sys_version(input) + self.assertEqual( + (name, version, '', '', buildno, builddate, compiler), output) + def test_main(): support.run_unittest( PlatformTest diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index 8576347..6568732 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -117,7 +117,6 @@ class urlopen_FileTests(unittest.TestCase): class ProxyTests(unittest.TestCase): def setUp(self): - unittest.TestCase.setUp(self) # Save all proxy related env vars self._saved_environ = dict([(k, v) for k, v in os.environ.items() if k.lower().find('proxy') >= 0]) @@ -126,9 +125,8 @@ class ProxyTests(unittest.TestCase): del os.environ[k] def tearDown(self): - unittest.TestCase.tearDown(self) # Restore all proxy related env vars - for k, v in self._saved_environ: + for k, v in self._saved_environ.items(): os.environ[k] = v def test_getproxies_environment_keep_no_proxies(self): |