diff options
author | Christian Heimes <christian@cheimes.de> | 2008-01-29 12:18:50 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-01-29 12:18:50 (GMT) |
commit | fd66e51c4c1ff9293b0f332d6ebc8093b2ef12bb (patch) | |
tree | 33e303619714002b5554c6e93e839fa51250458a | |
parent | 1fd77708e3813a28f023671c112231a81bb631f0 (diff) | |
download | cpython-fd66e51c4c1ff9293b0f332d6ebc8093b2ef12bb.zip cpython-fd66e51c4c1ff9293b0f332d6ebc8093b2ef12bb.tar.gz cpython-fd66e51c4c1ff9293b0f332d6ebc8093b2ef12bb.tar.bz2 |
Merged revisions 60383-60407 via svnmerge from
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.
........
-rw-r--r-- | Doc/c-api/set.rst | 22 | ||||
-rw-r--r-- | Include/setobject.h | 2 | ||||
-rw-r--r-- | Lib/ctypes/test/test_funcptr.py | 6 | ||||
-rw-r--r-- | Makefile.pre.in | 2 | ||||
-rw-r--r-- | Misc/Vim/python.vim | 7 | ||||
-rw-r--r-- | Misc/Vim/syntax_test.py | 5 | ||||
-rw-r--r-- | Misc/Vim/vim_syntax.py | 5 | ||||
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 5 | ||||
-rw-r--r-- | Objects/setobject.c | 27 | ||||
-rw-r--r-- | Python/marshal.c | 20 | ||||
-rw-r--r-- | setup.py | 5 |
11 files changed, 51 insertions, 55 deletions
diff --git a/Doc/c-api/set.rst b/Doc/c-api/set.rst index 3d8cf87..83d9532 100644 --- a/Doc/c-api/set.rst +++ b/Doc/c-api/set.rst @@ -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) diff --git a/Include/setobject.h b/Include/setobject.h index 5b7fb7e..e21100a 100644 --- a/Include/setobject.h +++ b/Include/setobject.h @@ -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 *); diff --git a/Lib/ctypes/test/test_funcptr.py b/Lib/ctypes/test/test_funcptr.py index 7ddf319..56099cc 100644 --- a/Lib/ctypes/test/test_funcptr.py +++ b/Lib/ctypes/test/test_funcptr.py @@ -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() diff --git a/Makefile.pre.in b/Makefile.pre.in index 0a03d87..91f791d 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -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 diff --git a/Misc/Vim/python.vim b/Misc/Vim/python.vim index 130b699..11ee7eb 100644 --- a/Misc/Vim/python.vim +++ b/Misc/Vim/python.vim @@ -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 diff --git a/Misc/Vim/syntax_test.py b/Misc/Vim/syntax_test.py index ccc7f30..1d20866 100644 --- a/Misc/Vim/syntax_test.py +++ b/Misc/Vim/syntax_test.py @@ -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 diff --git a/Misc/Vim/vim_syntax.py b/Misc/Vim/vim_syntax.py index 14c5512..172b350 100644 --- a/Misc/Vim/vim_syntax.py +++ b/Misc/Vim/vim_syntax.py @@ -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 diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index c10f627..a4400cf 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -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 */ diff --git a/Objects/setobject.c b/Objects/setobject.c index b37db44..d97dc28 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -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); diff --git a/Python/marshal.c b/Python/marshal.c index 4ea43da..4c0f088 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -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: @@ -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? |