From: Barry S. <ba...@ba...> - 2015-09-01 16:04:49
|
Vivian, I think I have 2 patches to work on from you. * Add the ability to react to PySequence_DelItem() * Make py2 and py3 handling of Py::Object( NULL ) consistent I was worried that someone might be relying on being able to use detect the NULL value in sequence_ass_item(). Given that Py2 cannot call the sequence_ass_item() because of the NULL check. I will take your patch to all sequence_ass_del(). It is a nice API. My feeling that it should be possible to create Py::Object from NULL. But there are clearly cases when its not a reasonable thing to do. I wondering what the API should look like. Adding another bool to the c’tor is possible. Py::Object( PyObject *, bool owner, bool accept_null ); Then have validate() change behaviour on accept_null. Or use two classes: * a Py::Object which Allows Null * a Py::Object which Disallows Null Take the current Py::Object and rename to Py::ObjectAllowNull. class Py::ObjectAllowNull; with validate() { return true; } add new predicate hasObject() { return p != NULL; } Then derive Py::Object from Py::ObjectAllowNull. class Py::Object(Py::ObjectALllowNull); with validate() { return p!=NULL; } All the existing classes like Py::Int, Py::List derive from Py::Object that rejects Null. With the accept_null c’tor it would be possible to have a Py::Int that accepts NULL. Any thoughts? Barry |