Skip to content

Commit

Permalink
Merged revisions 76052,76522,76591,76689,76697,76733 via svnmerge from
Browse files Browse the repository at this point in the history
svn+ssh://[email protected]/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 python#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
........
  • Loading branch information
benjaminp committed Dec 13, 2009
1 parent 0496c9e commit 8f326b2
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 45 deletions.
8 changes: 4 additions & 4 deletions Lib/test/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def test_try_stmt(self):
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)

Expand Down Expand Up @@ -237,9 +237,9 @@ def walk(tree):
(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):
Expand Down
15 changes: 2 additions & 13 deletions Lib/unittest/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,6 @@ def __exit__(self, exc_type, exc_value, tb):
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.
Expand Down Expand Up @@ -214,7 +203,7 @@ def addTypeEqualityFunc(self, typeobj, function):
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
Expand Down Expand Up @@ -437,7 +426,7 @@ def _getAssertEqualityFunc(self, first, second):
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

Expand Down
2 changes: 1 addition & 1 deletion Objects/abstract.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 11 additions & 12 deletions Parser/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down
10 changes: 4 additions & 6 deletions configure
Original file line number Diff line number Diff line change
@@ -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.
#
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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"
Expand Down
15 changes: 6 additions & 9 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8f326b2

Please sign in to comment.