summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_parser.py8
-rw-r--r--Lib/unittest/case.py15
-rw-r--r--Objects/abstract.c2
-rw-r--r--Parser/tokenizer.c23
-rwxr-xr-xconfigure10
-rw-r--r--configure.in15
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 <stdio.h>
#include <stddef.h>
#include <string.h>
@@ -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