GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Include `Pdb._exec_in_closure()` as code-path in `exec()` itself, or make it a public utility otherwise? · Issue #136280 · python/cpython Open Labels stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement DescriptionFeature or enhancementProposal:When IPython is embedded into a non-IPython interpreter, it evaluates code using frame locals ( This does not work with objects which require access to the closure scope:
This bug affected For example, the following does not work: import sys call_frame = sys._getframe(0).f_back local_ns = call_frame.f_locals exec('x = 1; sum(x * i for i in range(5))', locals=local_ns) Produces: Traceback (most recent call last): File "<python-input-0>", line 4, in <module> exec('x = 1; sum(x * i for i in range(5))', locals=local_ns) ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<string>", line 1, in <module> File "<string>", line 1, in <genexpr> NameError: name 'x' is not defined I know that I am coming here from IPython, to explore if the solution belongs in IPython, or in CPython repo:
The fix/workaround from #111094 is not perfect yet, though I think most of the problems could be resolved with a little bit more work. These issues were reported in: If On the other hand, if there are plans to inline generators in the future (I saw that PEP 709 leaved that as a possibility), maybe As an alternative to reusing However, if you all advise that Has this already been discussed elsewhere?This is a minor feature, which does not need previous discussion elsewhere Links to previous discussion of this feature:Not directly, but this is the third oldest unresolved issue in IPython dating back over 15 years:
CC @gaogaotiantian if I may, as author of #111094 and assignee on #126958 Activity
MetadataMetadataAssigneesLabelsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |