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)
(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):
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.
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
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
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;
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;
}
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;
}
#! /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.
#
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. */
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"
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>
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