Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamicscope items, keys, values, update, and iter #566

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

frmdstryr
Copy link
Contributor

This at least fixes #565 and makes ipython embed work in an expression/event handler.

I don't think doing the full scope (walking parents and getting members) is necessary but I can try that if needed.

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.92%. Comparing base (3bcd2a4) to head (960a739).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #566   +/-   ##
=======================================
  Coverage   70.92%   70.92%           
=======================================
  Files         287      287           
  Lines       25710    25710           
  Branches     3643     3643           
=======================================
  Hits        18234    18234           
  Misses       6385     6385           
  Partials     1091     1091           

@sccolbert
Copy link
Member

Before we go this route, I'd like it if someone investigated the change between Py2 and Py3 to see if that really is the problem. It may be (but probably unlikely) that everyone assumes f_locals is a dict when that's really not the case. We really need to understand what protocol is expected of f_locals by the interpreter. Because if the interpreter is now expecting a proper dict actual, then we are in trouble, and will need to re-think all this magic we are doing.

@frmdstryr
Copy link
Contributor Author

frmdstryr commented Jan 11, 2025

Both frame.f_locals and PyFrame_GetLocals say mapping.

The traceback module uses list(frame.f_locals) and locals.items() which should be part of mapping at least according to collections.abc.

For reasons I don't understand the Dynamicscope has Py_TPFLAGS_DICT_SUBCLASS set but not Py_TPFLAGS_MAPPING so it is a dict according to PyDict_Check. Idk how it passes the PyMapping_Check yet. Edit: Looks like just having an mp_subscript makes it pass that.

Either way it at least needs to implement the tp_iter?

@sccolbert
Copy link
Member

sccolbert commented Jan 11, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Errors cannot be printed/formatted in 3.12+ because DynamicScope object is not iterable
2 participants