<div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Sorry, I pasted a patch with changes unrelated to this discussion. This is the gist of the proposed change:<br><br><div style="margin-left:40px"><span style="font-family:monospace,monospace"> int<br> PyCallable_Check(PyObject *x)<br> {<br> if (x == NULL)<br> return 0;<br>- return x->ob_type->tp_call;<br>+ return x->ob_type->tp_call && _PyObject_HasAttrId(x, &PyId___call__);<br> }</span><br></div></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div><span style="font-family:trebuchet ms,sans-serif"><span style="color:rgb(51,51,51)"><br><font size="2"><span style="color:rgb(51,51,51)">Thanks,</span><br><span style="color:rgb(153,153,153)">-- Ionel</span></font></span><font size="2"><font style="color:rgb(153,153,153)"> Cristian Mărieș, <a href="http://blog.ionelmc.ro" target="_blank">http://blog.ionelmc.ro</a><br></font></font></span></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Sun, Apr 19, 2015 at 3:30 AM, Ionel Cristian Mărieș <span dir="ltr"><<a href="mailto:contact@ionelmc.ro" target="_blank">contact@ionelmc.ro</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Sun, Apr 19, 2015 at 2:09 AM, Paul Moore <span dir="ltr"><<a href="mailto:p.f.moore@gmail.com" target="_blank">p.f.moore@gmail.com</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow:hidden"><span class="">So I'm not clear what "small change" you're referring to here:<br>
<br>
* A change to CPython to reduce the number of false positives by<br>
making this case return False? If that, then no, I don't think a PEP<br>
is needed. But note that user code still can't assume that the above<br>
behaviour couldn't still happen in *other* cases, so the change would<br>
be of limited value (and whether it gets accepted depends on whether<br>
the complexity is justified by the benefit).<br>
* A change to the definition of callable() to remove the possibility<br>
of false positives at all? In that case, yes, a PEP probably *is*<br>
needed, as that's going to affect an awful lot of corner cases, and<br>
will impact all implementations. It's probably not correct to call<br>
this a "small change".<br>
* Something else?</span><div><div><img src=""></div></div></div></blockquote></div><br><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">The discussion was about this small change:<br><br><blockquote><span style="font-family:monospace,monospace"> int<br> PyCallable_Check(PyObject *x)<br> {<br>- if (x == NULL)<br>+ if (x == NULL) {<br> return 0;<br>- return x->ob_type->tp_call != NULL;<br>+ }<br>+<br>+ return Py_TYPE(x)->tp_call && _PyObject_HasAttrId(x, &PyId___call__);<br> }</span><br></blockquote>There are more explanations in the thread in case you want to know more.<br></div><span class=""><br><br clear="all"><div><div><div dir="ltr"><div><div dir="ltr"><div><div><span style="font-family:trebuchet ms,sans-serif"><span style="color:rgb(51,51,51)"><br><font size="2"><span style="color:rgb(51,51,51)">Thanks,</span><br><span style="color:rgb(153,153,153)">-- Ionel</span></font></span><font size="2"><font style="color:rgb(153,153,153)"> Cristian Mărieș, <a href="http://blog.ionelmc.ro" target="_blank">http://blog.ionelmc.ro</a><br></font></font></span></div></div></div></div></div></div></div>
</span></div></div>
</blockquote></div><br></div>