Skip to content

Commit

Permalink
Merged revisions 60383-60407 via svnmerge from
Browse files Browse the repository at this point in the history
svn+ssh://[email protected]/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.
........
  • Loading branch information
tiran committed Jan 29, 2008
1 parent 1fd7770 commit fd66e51
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 55 deletions.
22 changes: 19 additions & 3 deletions Doc/c-api/set.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand All @@ -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)

Expand All @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions Include/setobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
6 changes: 0 additions & 6 deletions Lib/ctypes/test/test_funcptr.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,5 @@ def c_string(init):
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()
2 changes: 1 addition & 1 deletion Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions Misc/Vim/python.vim
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
5 changes: 2 additions & 3 deletions Misc/Vim/syntax_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
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
Expand Down
5 changes: 3 additions & 2 deletions Misc/Vim/vim_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
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'''

Expand Down Expand Up @@ -162,7 +163,7 @@ def fill_stmt(iterable, fill_len):
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
Expand Down
5 changes: 0 additions & 5 deletions Modules/_ctypes/_ctypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
27 changes: 8 additions & 19 deletions Objects/setobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -2173,21 +2163,21 @@ 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;
}
return set_discard_key((PySetObject *)set, 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
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
20 changes: 8 additions & 12 deletions Python/marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,10 @@ def detect_modules(self):
# 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?

Expand Down

0 comments on commit fd66e51

Please sign in to comment.