diff options
-rw-r--r-- | Doc/ACKS.txt | 1 | ||||
-rw-r--r-- | Include/compile.h | 2 | ||||
-rw-r--r-- | Lib/modulefinder.py | 5 | ||||
-rw-r--r-- | Lib/test/test_descr.py | 10 | ||||
-rw-r--r-- | Lib/test/test_io.py | 1 | ||||
-rw-r--r-- | Lib/test/test_modulefinder.py | 16 | ||||
-rw-r--r-- | Lib/test/test_parser.py | 2 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Modules/_fileio.c | 2 | ||||
-rw-r--r-- | Modules/parsermodule.c | 4 | ||||
-rw-r--r-- | Python/future.c | 2 | ||||
-rwxr-xr-x | Tools/scripts/findnocoding.py | 2 |
12 files changed, 34 insertions, 14 deletions
diff --git a/Doc/ACKS.txt b/Doc/ACKS.txt index 965358d..4537c65 100644 --- a/Doc/ACKS.txt +++ b/Doc/ACKS.txt @@ -16,6 +16,7 @@ docs@python.org), and we'll be glad to correct the problem. * A. Amoroso * Pehr Anderson * Oliver Andrich + * Heidi Annexstad * Jesús Cea Avión * Daniel Barclay * Chris Barker diff --git a/Include/compile.h b/Include/compile.h index d24cad7..d78f824 100644 --- a/Include/compile.h +++ b/Include/compile.h @@ -32,8 +32,6 @@ PyAPI_FUNC(PyCodeObject *) PyAST_Compile(struct _mod *, const char *, PyCompilerFlags *, PyArena *); PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *); -#define ERR_LATE_FUTURE \ -"from __future__ imports must occur at the beginning of the file" #ifdef __cplusplus } diff --git a/Lib/modulefinder.py b/Lib/modulefinder.py index e4184a1..989172a 100644 --- a/Lib/modulefinder.py +++ b/Lib/modulefinder.py @@ -310,7 +310,10 @@ class ModuleFinder: def _add_badmodule(self, name, caller): if name not in self.badmodules: self.badmodules[name] = {} - self.badmodules[name][caller.__name__] = 1 + if caller: + self.badmodules[name][caller.__name__] = 1 + else: + self.badmodules[name]["-"] = 1 def _safe_import_hook(self, name, caller, fromlist, level=-1): # wrapper for self.import_hook() that won't raise ImportError diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 85df9dc..0e1f7c3 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -1020,14 +1020,10 @@ order (MRO) for bases """ def __del__(self_): self.assertEqual(self_.a, 1) self.assertEqual(self_.b, 2) - - save_stderr = sys.stderr - sys.stderr = sys.stdout - h = H() - try: + with test_support.captured_output('stderr') as s: + h = H() del h - finally: - sys.stderr = save_stderr + self.assertEqual(s.getvalue(), '') def test_slots_special(self): # Testing __dict__ and __weakref__ in __slots__... diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index ea965d7..f28bade 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -1245,6 +1245,7 @@ class MiscIOTest(unittest.TestCase): self.assertRaises(ValueError, io.FileIO, "/some/invalid/name", "rt") self.assertEqual(w.warnings, []) + def test_main(): support.run_unittest(IOTest, BytesIOTest, StringIOTest, BufferedReaderTest, BufferedWriterTest, diff --git a/Lib/test/test_modulefinder.py b/Lib/test/test_modulefinder.py index 85bc669..bee2abb 100644 --- a/Lib/test/test_modulefinder.py +++ b/Lib/test/test_modulefinder.py @@ -190,6 +190,19 @@ a/b/c/e.py a/b/c/f.py """] +relative_import_test_3 = [ + "a.module", + ["a", "a.module"], + ["a.bar"], + [], + """\ +a/__init__.py + def foo(): pass +a/module.py + from . import foo + from . import bar +"""] + def open_file(path): ##print "#", os.path.abspath(path) dirname = os.path.dirname(path) @@ -256,6 +269,9 @@ class ModuleFinderTest(unittest.TestCase): def test_relative_imports_2(self): self._do_test(relative_import_test_2) + def test_relative_imports_3(self): + self._do_test(relative_import_test_3) + def test_main(): distutils.log.set_threshold(distutils.log.WARN) support.run_unittest(ModuleFinderTest) diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index cec4c70..4490052 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -1,4 +1,5 @@ import parser +import os import unittest import sys from test import support @@ -172,6 +173,7 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase): "from sys.path import (dirname, basename as my_basename)") self.check_suite( "from sys.path import (dirname, basename as my_basename,)") + self.check_suite("from .bogus import x") def test_basic_import_statement(self): self.check_suite("import sys") @@ -61,6 +61,7 @@ Eric Beser Steven Bethard Stephen Bevan Ron Bickers +David Binger Dominic Binks Philippe Biondi Stuart Bishop diff --git a/Modules/_fileio.c b/Modules/_fileio.c index 4b35194..a946ea5 100644 --- a/Modules/_fileio.c +++ b/Modules/_fileio.c @@ -251,7 +251,7 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) self->closefd = 1; if (!closefd) { PyErr_SetString(PyExc_ValueError, - "Cannot use closefd=True with file name"); + "Cannot use closefd=False with file name"); goto error; } diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c index 652b07c..58d7dfb 100644 --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -1710,10 +1710,10 @@ static int count_from_dots(node *tree) { int i; - for (i = 0; i < NCH(tree); i++) + for (i = 1; i < NCH(tree); i++) if (TYPE(CHILD(tree, i)) != DOT) break; - return i; + return i-1; } /* 'from' ('.'* dotted_name | '.') 'import' ('*' | '(' import_as_names ')' | diff --git a/Python/future.c b/Python/future.c index e775384..1a2db1b 100644 --- a/Python/future.c +++ b/Python/future.c @@ -8,6 +8,8 @@ #include "symtable.h" #define UNDEFINED_FUTURE_FEATURE "future feature %.100s is not defined" +#define ERR_LATE_FUTURE \ +"from __future__ imports must occur at the beginning of the file" static int future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename) diff --git a/Tools/scripts/findnocoding.py b/Tools/scripts/findnocoding.py index 84dc3e0..78fc8ef 100755 --- a/Tools/scripts/findnocoding.py +++ b/Tools/scripts/findnocoding.py @@ -12,7 +12,7 @@ import sys, os, re, getopt # our pysource module finds Python source files try: import pysource -except: +except ImportError: # emulate the module with a simple os.walk class pysource: has_python_ext = looks_like_python = can_be_compiled = None |