[Python-Dev] PySet API (original) (raw)
Barry Warsaw barry at python.org
Tue Mar 28 22:12:47 CEST 2006
- Previous message: [Python-Dev] PySet API
- Next message: [Python-Dev] PySet API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, 2006-03-28 at 17:28 +1200, Greg Ewing wrote:
Barry Warsaw wrote: > My PySetClear() raises a SystemError > and returns -1 when the object is a frozen set.
Isn't SystemError a bit drastic? TypeError would be sufficient here, surely.
Possibly, but all the other PySet_*() functions call PyErr_BadInternalCall() when they get a type they don't accept, so PySet_Clear() should be consistent.
> If PyObjectClear() is implemented something like > > int PyObjectClear(PyObject *o) > { > return (o->obtype->tpclear ? o->obtype->tpclear(o) : -1); > } > > then you /would/ be able to clear a frozen set.
Hmmm, the problem here, I think, is that tpclear is really only designed for use by the garbage collector. Giving anything else access to it is probably wrong.
Exactly.
Clearability is not a general feature in Python land -- a few types have a clear() method, but this is an ad hoc feature of the type concerned. I don't think it makes sense to have a general PyObjectClear function at all.
I'm thinking the same thing, which is why I'm now favoring PySet_Clear() again.
-Barry
-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 309 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/python-dev/attachments/20060328/1ff0835a/attachment.pgp
- Previous message: [Python-Dev] PySet API
- Next message: [Python-Dev] PySet API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]