From 8f326b23695dc4996327da8477e11aad42c61953 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 13 Dec 2009 02:10:36 +0000 Subject: Merged revisions 76052,76522,76591,76689,76697,76733 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r76052 | gregory.p.smith | 2009-11-01 20:02:38 -0600 (Sun, 01 Nov 2009) | 5 lines see issue1006238, this merges in the following patch to ease cross compiling the printf %zd check. http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-lang/python/files/python-2.5-cross-printf.patch?rev=1.1&view=markup ........ r76522 | barry.warsaw | 2009-11-25 12:38:32 -0600 (Wed, 25 Nov 2009) | 2 lines Add mktime_tz to __all__. It's documented as being available in email.utils. ........ r76591 | benjamin.peterson | 2009-11-29 16:26:26 -0600 (Sun, 29 Nov 2009) | 4 lines now that deepcopy can handle instance methods, this hack can be removed #7409 Thanks Robert Collins ........ r76689 | benjamin.peterson | 2009-12-06 11:37:48 -0600 (Sun, 06 Dec 2009) | 1 line rewrite translate_newlines for clarity ........ r76697 | benjamin.peterson | 2009-12-06 15:24:30 -0600 (Sun, 06 Dec 2009) | 2 lines fix test_parser from tokenizer tweak ........ r76733 | benjamin.peterson | 2009-12-09 21:37:59 -0600 (Wed, 09 Dec 2009) | 1 line substitute PyDict_Check() for PyObject_IsInstance ........ --- Lib/test/test_parser.py | 8 ++++---- Lib/unittest/case.py | 15 ++------------- Objects/abstract.c | 2 +- Parser/tokenizer.c | 23 +++++++++++------------ configure | 10 ++++------ configure.in | 15 ++++++--------- 6 files changed, 28 insertions(+), 45 deletions(-) diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index d8df6a8..10d6fe2 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -208,7 +208,7 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase): def test_position(self): # An absolutely minimal test of position information. Better # tests would be a big project. - code = "def f(x):\n return x + 1\n" + code = "def f(x):\n return x + 1" st1 = parser.suite(code) st2 = st1.totuple(line_info=1, col_info=1) @@ -237,9 +237,9 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase): (14, '+', 2, 13), (2, '1', 2, 15), (4, '', 2, 16), - (6, '', 3, -1), - (4, '', 3, -1), - (0, '', 3, -1)], + (6, '', 2, -1), + (4, '', 2, -1), + (0, '', 2, -1)], terminals) def test_extended_unpacking(self): diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py index 4f9c496..daade71 100644 --- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -130,17 +130,6 @@ class _AssertRaisesContext(object): return True -class _AssertWrapper(object): - """Wrap entries in the _type_equality_funcs registry to make them deep - copyable.""" - - def __init__(self, function): - self.function = function - - def __deepcopy__(self, memo): - memo[id(self)] = self - - class TestCase(object): """A class whose instances are single test cases. @@ -214,7 +203,7 @@ class TestCase(object): msg= argument that raises self.failureException with a useful error message when the two arguments are not equal. """ - self._type_equality_funcs[typeobj] = _AssertWrapper(function) + self._type_equality_funcs[typeobj] = function def addCleanup(self, function, *args, **kwargs): """Add a function, with arguments, to be called when the test is @@ -437,7 +426,7 @@ class TestCase(object): if type(first) is type(second): asserter = self._type_equality_funcs.get(type(first)) if asserter is not None: - return asserter.function + return asserter return self._baseAssertEqual diff --git a/Objects/abstract.c b/Objects/abstract.c index 5247824..d4cba74 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -1453,7 +1453,7 @@ PyNumber_ToBase(PyObject *n, int base) int PySequence_Check(PyObject *s) { - if (PyObject_IsInstance(s, (PyObject *)&PyDict_Type)) + if (PyDict_Check(s)) return 0; return s != NULL && s->ob_type->tp_as_sequence && s->ob_type->tp_as_sequence->sq_item != NULL; diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index f3ef1cb..5a1c268 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -652,20 +652,20 @@ translate_into_utf8(const char* str, const char* enc) { static char * translate_newlines(const char *s, int exec_input, struct tok_state *tok) { - int skip_next_lf = 0, length = strlen(s), final_length; + int skip_next_lf = 0, needed_length = strlen(s) + 2, final_length; char *buf, *current; - char c; - buf = PyMem_MALLOC(length + 2); + char c = '\0'; + buf = PyMem_MALLOC(needed_length); if (buf == NULL) { tok->done = E_NOMEM; return NULL; } - for (current = buf; (c = *s++);) { + for (current = buf; *s; s++, current++) { + c = *s; if (skip_next_lf) { skip_next_lf = 0; if (c == '\n') { - c = *s; - s++; + c = *++s; if (!c) break; } @@ -675,19 +675,18 @@ translate_newlines(const char *s, int exec_input, struct tok_state *tok) { c = '\n'; } *current = c; - current++; } - /* If this is exec input, add a newline to the end of the file if + /* If this is exec input, add a newline to the end of the string if there isn't one already. */ - if (exec_input && *current != '\n') { + if (exec_input && c != '\n') { *current = '\n'; current++; } *current = '\0'; - final_length = current - buf; - if (final_length < length && final_length) + final_length = current - buf + 1; + if (final_length < needed_length && final_length) /* should never fail */ - buf = PyMem_REALLOC(buf, final_length + 1); + buf = PyMem_REALLOC(buf, final_length); return buf; } diff --git a/configure b/configure index e4c88f4..f6a675e 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 76637 . +# From configure.in Revision: 76645 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.2. # @@ -26672,7 +26672,8 @@ if test "${ac_cv_have_size_t_format+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then - ac_cv_have_size_t_format=no + ac_cv_have_size_t_format="cross -- assuming yes" + else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -26750,13 +26751,10 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$a fi - fi - { echo "$as_me:$LINENO: result: $ac_cv_have_size_t_format" >&5 echo "${ECHO_T}$ac_cv_have_size_t_format" >&6; } -if test $ac_cv_have_size_t_format = yes -then +if test "$ac_cv_have_size_t_format" != no ; then cat >>confdefs.h <<\_ACEOF #define PY_FORMAT_SIZE_T "z" diff --git a/configure.in b/configure.in index 45601d5..711856d 100644 --- a/configure.in +++ b/configure.in @@ -3905,9 +3905,8 @@ then LIBS="$LIBS -framework CoreFoundation" fi -AC_MSG_CHECKING(for %zd printf() format support) -AC_CACHE_VAL(ac_cv_have_size_t_format, -AC_TRY_RUN([[ +AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl +AC_TRY_RUN([ #include #include #include @@ -3942,13 +3941,11 @@ int main() return 0; } -]], ac_cv_have_size_t_format=yes, +], ac_cv_have_size_t_format=yes, ac_cv_have_size_t_format=no, - ac_cv_have_size_t_format=no) -) -AC_MSG_RESULT($ac_cv_have_size_t_format) -if test $ac_cv_have_size_t_format = yes -then + [ac_cv_have_size_t_format="cross -- assuming yes"] +)]) +if test "$ac_cv_have_size_t_format" != no ; then AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t]) fi -- cgit v0.12