<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
David,
<p>In object dict_base::get(object_cref k) const
<br>isn't it better to have expect_non_null?
<br>Because otherwise wrong key leads to access violation.
<p>Best regards.
<br>Nikolay
<p>David Abrahams wrote:
<blockquote TYPE=CITE>Nikolay Mladenov &lt;nickm@sitius.com> writes:
<p>> I am going to read the PEP.
<br>> But I think I am getting closer with:
<br>>&nbsp;&nbsp;&nbsp;&nbsp; self&amp; staticmethod(char const* name)
<br>>&nbsp;&nbsp;&nbsp;&nbsp; {
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PyObject *method
= pytype_check(&amp;PyMethod_Type, ((object)(this->attr(name))).ptr());
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this->attr(name)
= object(handle&lt;>(
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
PyStaticMethod_New(PyMethod_GET_FUNCTION(method) )
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
));
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return *this;
<br>>&nbsp;&nbsp;&nbsp;&nbsp; }
<p>> I guess PyMethod_GET_FUNCTION corresponds to "C.__dict__['f']" since
<br>> it extracts the function from the PyMethod Descriptor .
<p>It's similar, but I would prefer it if you would get it from the
<br>class' __dict__.&nbsp; One day I may have a reason not to build a true
<br>Python Method wrapper, and use something else instead; that would
<br>break your code.
<p>You can reach the class' dict very simply via:
<p>&nbsp;&nbsp; detail::downcast&lt;PyTypeObject>(this->ptr())->tp_dict
<p>--
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
David Abrahams
<br>&nbsp;&nbsp; dave@boost-consulting.com * <a href="http://www.boost-consulting.com">http://www.boost-consulting.com</a>
<br>Boost support, enhancements, training, and commercial distribution</blockquote>
</html>