Showing content from http://mail.python.org/pipermail/python-dev/attachments/20150714/2bc35a6e/attachment.html below:
<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Jul 14, 2015 at 11:39 AM Matthew Keeter <<a href="mailto:matt.j.keeter@gmail.com">matt.j.keeter@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">The docs for PyRun_String say that both globals and locals should be dictionaries [1].<div><br><div>However, digging into the source [2] shows me that locals doesnât need to be a dictionary;</div><div>it just needs to implement the mapping protocol. Is it a bad idea to rely on this fact?</div><div><br></div><div>(Context: Iâm plugging a custom object into locals that uses __getitem__ to track lookups.)</div></div></div></blockquote><div><br></div><div>As you pointed out in the code, that's in the frame creation code and not directly the PyRun_StringFlags code, so technically there is a chance for us to insert a PyDict_CheckExact() call before hitting the code you linked to.</div><div><br></div><div>As to whether we could loosen the documented restrictions so they are guaranteed, it would be best to file an issue at <a href="http://bugs.python.org">bugs.python.org</a> requesting the restriction be officially loosened and if people are amenable then a test to make sure no one accidentally breaks the API promise. </div></div></div>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4