]> granicus.if.org Git - python/commitdiff
Merged revisions 60383-60407 via svnmerge from
authorChristian Heimes <christian@cheimes.de>
Tue, 29 Jan 2008 12:18:50 +0000 (12:18 +0000)
committerChristian Heimes <christian@cheimes.de>
Tue, 29 Jan 2008 12:18:50 +0000 (12:18 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r60388 | thomas.heller | 2008-01-28 09:44:13 +0100 (Mon, 28 Jan 2008) | 1 line

  Revert rev. 59925, it breaks comtypes (I need to further examine this).
........
  r60397 | raymond.hettinger | 2008-01-28 21:34:33 +0100 (Mon, 28 Jan 2008) | 5 lines

  Make PySet_Add() work with frozensets.
  Works like PyTuple_SetItem() to build-up values in a brand new frozenset.
  Also, PyFrozenSet_New() is now guaranteed to produce a distinct new frozenset.
........
  r60398 | raymond.hettinger | 2008-01-28 22:34:30 +0100 (Mon, 28 Jan 2008) | 1 line

  Let marshal built-up sets and frozensets one element at a time (without creating an intermediate tuple).
........
  r60399 | raymond.hettinger | 2008-01-28 22:47:42 +0100 (Mon, 28 Jan 2008) | 1 line

  Factor-out common code with a new macro
........
  r60400 | raymond.hettinger | 2008-01-28 22:48:07 +0100 (Mon, 28 Jan 2008) | 1 line

  Factor-out common code with a new macro
........
  r60401 | raymond.hettinger | 2008-01-28 22:51:25 +0100 (Mon, 28 Jan 2008) | 1 line

  Removed unnecessary conditional (spotted by Neal Norwitz).
........
  r60403 | gregory.p.smith | 2008-01-29 00:21:00 +0100 (Tue, 29 Jan 2008) | 4 lines

  Disable use of BerkeleyDB 4.6.x to see what the odd platform buildbots
  think.  In particular, neal norwitz has traced an Ubuntu sparc64 crash
  to the Lib/test/bsddb/test_basics.py test when opening a db with DB_THREAD.
........
  r60405 | brett.cannon | 2008-01-29 05:13:07 +0100 (Tue, 29 Jan 2008) | 2 lines

  Fix the reindent rule to use $(BUILDPYTHON).
........
  r60406 | brett.cannon | 2008-01-29 05:18:04 +0100 (Tue, 29 Jan 2008) | 3 lines

  Update Vim syntax highlighting to specify what revision was used to generate
  the file.
........
  r60407 | brett.cannon | 2008-01-29 05:20:56 +0100 (Tue, 29 Jan 2008) | 2 lines

  Ignore .pyc and .pyo files.
........

Doc/c-api/set.rst
Include/setobject.h
Lib/ctypes/test/test_funcptr.py
Makefile.pre.in
Misc/Vim/python.vim
Misc/Vim/syntax_test.py
Misc/Vim/vim_syntax.py
Modules/_ctypes/_ctypes.c
Objects/setobject.c
Python/marshal.c
setup.py

index 3d8cf87fc7359e9d050b4802d0caa93f3da67985..83d95328eaba564336bc38abfb28604143c9e4d4 100644 (file)
@@ -50,6 +50,12 @@ The following type check macros work on pointers to any Python object. Likewise,
 the constructor functions work with any iterable Python object.
 
 
+.. cfunction:: int PySet_Check(PyObject *p)
+
+   Return true if *p* is a :class:`set` object or an instance of a subtype.
+
+   .. versionadded:: 2.6
+
 .. cfunction:: int PyAnySet_Check(PyObject *p)
 
    Return true if *p* is a :class:`set` object, a :class:`frozenset` object, or an
@@ -84,6 +90,11 @@ the constructor functions work with any iterable Python object.
    set on success or *NULL* on failure.  Raise :exc:`TypeError` if *iterable* is
    not actually iterable.
 
+   .. versionchanged:: 2.6
+      Now guaranteed to return a brand-new :class:`frozenset`.  Formerly,
+      frozensets of zero-length were a singleton.  This got in the way of 
+      building-up new frozensets with :meth:`PySet_Add`.
+
 The following functions and macros are available for instances of :class:`set`
 or :class:`frozenset` or instances of their subtypes.
 
@@ -110,9 +121,6 @@ or :class:`frozenset` or instances of their subtypes.
    the *key* is unhashable. Raise :exc:`PyExc_SystemError` if *anyset* is not a
    :class:`set`, :class:`frozenset`, or an instance of a subtype.
 
-The following functions are available for instances of :class:`set` or its
-subtypes but not for instances of :class:`frozenset` or its subtypes.
-
 
 .. cfunction:: int PySet_Add(PyObject *set, PyObject *key)
 
@@ -122,6 +130,14 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
    Raise a :exc:`SystemError` if *set* is an not an instance of :class:`set` or its
    subtype.
 
+   .. versionchanged:: 2.6
+      Now works with instances of :class:`frozenset` or its subtypes.
+      Like :cfunc:`PyTuple_SetItem` in that it can be used to fill-in the
+      values of brand new frozensets before they are exposed to other code.
+
+The following functions are available for instances of :class:`set` or its
+subtypes but not for instances of :class:`frozenset` or its subtypes.
+
 
 .. cfunction:: int PySet_Discard(PyObject *set, PyObject *key)
 
index 5b7fb7e6b59b32dee20bb353465cc535315637fe..e21100a5b31939f58776f284654b7f9146047e6a 100644 (file)
@@ -74,6 +74,8 @@ PyAPI_DATA(PyTypeObject) PySetIter_Type;
        (Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type || \
          PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \
          PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type))
+#define PySet_Check(ob) \
+       (Py_TYPE(ob) == &PySet_Type || PyType_IsSubtype(Py_TYPE(ob), &PySet_Type))
 
 PyAPI_FUNC(PyObject *) PySet_New(PyObject *);
 PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *);
index 7ddf3199108882d09b470495828a38614d0dc003..56099cc89a9dc037a77ac0f98665783b7bddda89 100644 (file)
@@ -123,11 +123,5 @@ class CFuncPtrTestCase(unittest.TestCase):
         self.failUnlessEqual(strtok(None, b"\n"), "c")
         self.failUnlessEqual(strtok(None, b"\n"), None)
 
-    def test_NULL_funcptr(self):
-        tp = CFUNCTYPE(c_int)
-        func = tp() # NULL function pointer
-        # raise a ValueError when we try to call it
-        self.assertRaises(ValueError, func)
-
 if __name__ == '__main__':
     unittest.main()
index 0a03d87ab676fda8b322f20c67cf3974112a9589..91f791ded991007d58e2427ce80257227d01aa32 100644 (file)
@@ -1043,7 +1043,7 @@ config.status:    $(srcdir)/configure
 
 # Run reindent on the library
 reindent:
-       ./python$(EXEEXT) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib
+       ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib
 
 # Rerun configure with the same options as it was run last time,
 # provided the config.status script exists
index 130b699a75acad1c7e3d52969436099f360f306e..11ee7eb2eb00a05e26132da292de76a0a412fd22 100644 (file)
@@ -1,4 +1,4 @@
-" Auto-generated Vim syntax file for Python
+" Auto-generated Vim syntax file for Python (trunk: r60376M).
 "
 " To use: copy or symlink to ~/.vim/syntax/python.vim
 
@@ -63,7 +63,7 @@ endif
 
 if exists("python_highlight_builtins")
   syn keyword pythonBuiltin    Ellipsis False None NotImplemented True __debug__
-  syn keyword pythonBuiltin    __import__ abs all any basestring bool
+  syn keyword pythonBuiltin    __import__ abs all any bool
   syn keyword pythonBuiltin    buffer callable chr classmethod cmp
   syn keyword pythonBuiltin    complex copyright credits delattr dict
   syn keyword pythonBuiltin    dir divmod enumerate eval exec exit
@@ -73,7 +73,8 @@ if exists("python_highlight_builtins")
   syn keyword pythonBuiltin    max min object oct open ord pow property quit
   syn keyword pythonBuiltin    range reload repr reversed round
   syn keyword pythonBuiltin    set setattr slice sorted staticmethod str sum
-  syn keyword pythonBuiltin    super tuple type unichr unicode vars zip
+  syn keyword pythonBuiltin    super trunc tuple type unicode vars 
+  syn keyword pythonBuiltin    zip
 
 endif
 
index ccc7f309c611121e31dccaa66915a26e944f44f1..1d208668d065fb569829ae39fa8c6b8b1fba5b19 100644 (file)
@@ -4,9 +4,8 @@ Meant to cover a wide range of different types of statements and expressions.
 Not necessarily sensical or comprehensive (assume that if one exception is
 highlighted that all are, for instance).
 
-Highlighting extraneous whitespace at the end of the line is not represented
-here as all trailing whitespace is automatically removed from .py files in the
-repository.
+Extraneous trailing whitespace can't be tested because of svn pre-commit hook
+checks for such things.
 
 """
 # Comment
index 14c551271588aaa705bb83b0d46caeb6c0c8e41a..172b350c39225f3418b070a00e2d7849f0466a4a 100644 (file)
@@ -6,8 +6,9 @@ import keyword
 import exceptions
 import builtins
 from string import Template
+from sys import subversion
 
-comment_header = '''" Auto-generated Vim syntax file for Python.
+comment_header = '''" Auto-generated Vim syntax file for Python (%s: r%s).
 "
 " To use: copy or symlink to ~/.vim/syntax/python.vim'''
 
@@ -162,7 +163,7 @@ FILL = 80
 def main(file_path):
     with open(file_path, 'w') as FILE:
         # Comment for file
-        print>>FILE, comment_header
+        print>>FILE, comment_header % subversion[1:]
         print>>FILE, ''
         # Statements at start of file
         print>>FILE, statement_header
index c10f627ed7579a89cb5a22b75b46b6952a5b5cf0..a4400cf20e7705632c9d0f1a125ee9e6dd17216c 100644 (file)
@@ -3414,11 +3414,6 @@ CFuncPtr_call(CFuncPtrObject *self, PyObject *inargs, PyObject *kwds)
 
 
        pProc = *(void **)self->b_ptr;
-       if (pProc == NULL) {
-               PyErr_SetString(PyExc_ValueError,
-                               "attempt to call NULL function pointer");
-               return NULL;
-       }
 #ifdef MS_WIN32
        if (self->index) {
                /* It's a COM method */
index b37db4453883242db33463b13f7c1a96a5250341..d97dc2874b72db299daa6c4132810e2402dc9fc3 100644 (file)
@@ -2127,17 +2127,7 @@ PySet_New(PyObject *iterable)
 PyObject *
 PyFrozenSet_New(PyObject *iterable)
 {
-       PyObject *args, *result;
-
-       if (iterable == NULL)
-               args = PyTuple_New(0);
-       else
-               args = PyTuple_Pack(1, iterable);
-       if (args == NULL)
-               return NULL;
-       result = frozenset_new(&PyFrozenSet_Type, args, NULL);
-       Py_DECREF(args);
-       return result;
+       return make_new_set(&PyFrozenSet_Type, iterable);
 }
 
 Py_ssize_t
@@ -2153,7 +2143,7 @@ PySet_Size(PyObject *anyset)
 int
 PySet_Clear(PyObject *set)
 {
-       if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
+       if (!PySet_Check(set)) {
                PyErr_BadInternalCall();
                return -1;
        }
@@ -2173,7 +2163,7 @@ PySet_Contains(PyObject *anyset, PyObject *key)
 int
 PySet_Discard(PyObject *set, PyObject *key)
 {
-       if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
+       if (!PySet_Check(set)) {
                PyErr_BadInternalCall();
                return -1;
        }
@@ -2181,13 +2171,13 @@ PySet_Discard(PyObject *set, PyObject *key)
 }
 
 int
-PySet_Add(PyObject *set, PyObject *key)
+PySet_Add(PyObject *anyset, PyObject *key)
 {
-       if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
+       if (!PyAnySet_Check(anyset)) {
                PyErr_BadInternalCall();
                return -1;
        }
-       return set_add_key((PySetObject *)set, key);
+       return set_add_key((PySetObject *)anyset, key);
 }
 
 int
@@ -2224,7 +2214,7 @@ _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, long *hash)
 PyObject *
 PySet_Pop(PyObject *set)
 {
-       if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
+       if (!PySet_Check(set)) {
                PyErr_BadInternalCall();
                return NULL;
        }
@@ -2234,7 +2224,7 @@ PySet_Pop(PyObject *set)
 int
 _PySet_Update(PyObject *set, PyObject *iterable)
 {
-       if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
+       if (!PySet_Check(set)) {
                PyErr_BadInternalCall();
                return -1;
        }
@@ -2330,7 +2320,6 @@ test_c_api(PySetObject *so)
        f = PyFrozenSet_New(dup);
        assert(PySet_Size(f) == 3);
        assert(PyFrozenSet_CheckExact(f));
-       assertRaises(PySet_Add(f, elem) == -1, PyExc_SystemError);
        assertRaises(PySet_Discard(f, elem) == -1, PyExc_SystemError);
        assertRaises(PySet_Pop(f) == NULL, PyExc_SystemError);
        Py_DECREF(f);
index 4ea43da55292d23f5b15cdd77a5a4b3859cd344e..4c0f088cae39e0722dd0591d9d7db3287676b18c 100644 (file)
@@ -812,7 +812,7 @@ r_object(RFILE *p)
                        retval = NULL;
                        break;
                }
-               v = PyTuple_New((int)n);
+                v = (type == TYPE_SET) ? PySet_New(NULL) : PyFrozenSet_New(NULL);
                if (v == NULL) {
                        retval = NULL;
                        break;
@@ -827,18 +827,14 @@ r_object(RFILE *p)
                                v = NULL;
                                break;
                        }
-                       PyTuple_SET_ITEM(v, (int)i, v2);
-               }
-               if (v == NULL) {
-                       retval = NULL;
-                       break;
+                       if (PySet_Add(v, v2) == -1) {
+                                Py_DECREF(v);
+                                Py_DECREF(v2);
+                                v = NULL;
+                                break;
+                        }
                }
-               if (type == TYPE_SET)
-                       v3 = PySet_New(v);
-               else
-                       v3 = PyFrozenSet_New(v);
-               Py_DECREF(v);
-               retval = v3;
+               retval = v;
                break;
 
        case TYPE_CODE:
index 92f6f912d90a36d1c9e4402c3aa2cc77a3b32ebd..4cae0bebbefe6a6838c8be20f5ba41100578a642 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -652,7 +652,10 @@ class PyBuildExt(build_ext):
         # a release.  Most open source OSes come with one or more
         # versions of BerkeleyDB already installed.
 
-        max_db_ver = (4, 6)
+        max_db_ver = (4, 5)  # XXX(gregory.p.smith): 4.6 "works" but seems to
+                             # have issues on many platforms.  I've temporarily
+                             # disabled 4.6 to see what the odd platform
+                             # buildbots say.
         min_db_ver = (3, 3)
         db_setup_debug = False   # verbose debug prints from this script?