-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-115419: Change default sym to not_null #116562
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
Changes from 3 commits
0400f56
d71527b
ae58883
be261d9
4ae1f9f
3d28b37
8316cb0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -449,6 +449,14 @@ dummy_func(void) { | |
} | ||
} | ||
|
||
op(_LOAD_ATTR, (owner -- attr, self_or_null if (oparg & 1))) { | ||
(void)owner; | ||
OUT_OF_SPACE_IF_NULL(attr = sym_new_not_null(ctx)); | ||
if (oparg & 1) { | ||
OUT_OF_SPACE_IF_NULL(self_or_null = sym_new_unknown(ctx)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At some point in the future we will be able to tell whether the attribute is a method or not, and hence we will be able to set it to either There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No not for _LOAD_ATTR - this opcode is special, it means we dont know anything and it's only decideable at runtime. |
||
} | ||
} | ||
|
||
op(_LOAD_ATTR_MODULE, (index/1, owner -- attr, null if (oparg & 1))) { | ||
(void)index; | ||
OUT_OF_SPACE_IF_NULL(null = sym_new_null(ctx)); | ||
|
@@ -515,11 +523,24 @@ dummy_func(void) { | |
|
||
|
||
op(_CHECK_FUNCTION_EXACT_ARGS, (func_version/2, callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) { | ||
if (sym_is_const(callable) && | ||
sym_matches_type(callable, &PyFunction_Type) && | ||
(sym_is_null(self_or_null) || sym_is_not_null(self_or_null))) { | ||
assert(PyFunction_Check(sym_get_const(callable))); | ||
PyFunctionObject *func = (PyFunctionObject *)sym_get_const(callable); | ||
if (func->func_version != func_version) { | ||
goto hit_bottom; | ||
} | ||
PyCodeObject *code = (PyCodeObject *)func->func_code; | ||
int argcount = oparg + sym_is_not_null(self_or_null); | ||
if (code->co_argcount != argcount) { | ||
goto hit_bottom; | ||
} | ||
REPLACE_OP(this_instr, _NOP, 0, 0); | ||
} | ||
if (!sym_set_type(callable, &PyFunction_Type)) { | ||
goto hit_bottom; | ||
} | ||
(void)self_or_null; | ||
(void)func_version; | ||
} | ||
|
||
op(_CHECK_CALL_BOUND_METHOD_EXACT_ARGS, (callable, null, unused[oparg] -- callable, null, unused[oparg])) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I betcha you can do without a subprocess. Instead, just create a namespace and use that, like several other tests do. The namespace directory acts as the globals for the function defined in it. Try it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry my Python is actually somewhat rusty -- which namespace are you referring to? I don't remember
types.SimpleNamespace
being that powerful.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a dict -- look at
test_type_inconsistency()
in the same file for a complete example. Because it saysexec(src, ns, ns)
thens
dict is used as the globals for the function, and you can add/update its "globals" usingns["some_name"] = some_value
.