Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-120906: Support arbitrary hashable keys in FrameLocalsProxy #122309

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

Merged
merged 10 commits into from
Jul 30, 2024
Prev Previous commit
Next Next commit
Handle hidden values in the short-circuit
  • Loading branch information
encukou committed Jul 29, 2024
commit f5df751f1088678050b471e908969b1e746a09ff
7 changes: 5 additions & 2 deletions 7 Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ framelocalsproxy_getkeyindex(PyFrameObject *frame, PyObject* key, bool read)
if (key_hash == -1) {
return -2;
}
bool found = false;

// We do 2 loops here because it's highly possible the key is interned
// and we can do a pointer comparison.
Expand All @@ -82,9 +83,12 @@ framelocalsproxy_getkeyindex(PyFrameObject *frame, PyObject* key, bool read)
return i;
}
}
return -1;
found = true;
}
}
if (found) {
return -1;
encukou marked this conversation as resolved.
Show resolved Hide resolved
}
// This is unlikely, but we need to make sure. This means the key
// is not interned.
for (int i = 0; i < co->co_nlocalsplus; i++) {
Expand All @@ -108,7 +112,6 @@ framelocalsproxy_getkeyindex(PyFrameObject *frame, PyObject* key, bool read)
return i;
}
}
return -1;
}
}

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.