Message242878
| Author |
rhettinger |
| Recipients |
behzad.nouri, docs@python, rhettinger |
| Date |
2015年05月11日.01:33:29 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1431308010.41.0.831246479822.issue24161@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
> but then, what would be the use case of PyIter_Check
> outside of python core?
You could still use it anywhere. It will give a correct result in the cases of extension modules, builtin types, and new-style classes. It will give a false positive in the case of old-style classes. The latter case doesn't seem to be of much consequence (there is a still a TypeError raised when next() is called), so you just find out a bit later than you otherwise would (I believe that is why this is why we haven't gotten a bug report in the 13+ years this code has existed).
The feature is imperfect, incomplete and not as useful as it could be.
But this ship sailed a long time ago. It is far too late for redesign (and risking unintended breakage).
FWIW, PyIter_Check() is used several times in the Python core: sqlite, cPickle, and iter(). In those examples, there seem to be no adverse consequences for the false positive because we still get a TypeError downstream when the actual call is made to next(). |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2015年05月11日 01:33:30 | rhettinger | set | recipients:
+ rhettinger, docs@python, behzad.nouri |
| 2015年05月11日 01:33:30 | rhettinger | set | messageid: <1431308010.41.0.831246479822.issue24161@psf.upfronthosting.co.za> |
| 2015年05月11日 01:33:30 | rhettinger | link | issue24161 messages |
| 2015年05月11日 01:33:29 | rhettinger | create |
|