-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-104635: Add NO_EXCEPTION flag to opcode metadata #106394
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 all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,6 +252,7 @@ class InstructionFlags: | |
HAS_CONST_FLAG: bool | ||
HAS_NAME_FLAG: bool | ||
HAS_JUMP_FLAG: bool | ||
NO_EXCEPTION_FLAG: bool | ||
|
||
def __post_init__(self): | ||
self.bitmask = { | ||
|
@@ -265,11 +266,12 @@ def fromInstruction(instr: "AnyInstruction"): | |
HAS_CONST_FLAG=variable_used(instr, "FRAME_CO_CONSTS"), | ||
HAS_NAME_FLAG=variable_used(instr, "FRAME_CO_NAMES"), | ||
HAS_JUMP_FLAG=variable_used(instr, "JUMPBY"), | ||
NO_EXCEPTION_FLAG=no_exception(instr), | ||
) | ||
|
||
@staticmethod | ||
def newEmpty(): | ||
return InstructionFlags(False, False, False, False) | ||
return InstructionFlags(False, False, False, False, False) | ||
|
||
def add(self, other: "InstructionFlags") -> None: | ||
for name, value in dataclasses.asdict(other).items(): | ||
|
@@ -1585,6 +1587,19 @@ def variable_used(node: parser.Node, name: str) -> bool: | |
) | ||
|
||
|
||
def no_exception(node: parser.Node) -> bool: | ||
if node.name.startswith("JUMP"): | ||
return False | ||
for token in node.tokens: | ||
token_text = token.text.lower() | ||
if token.kind == "IDENTIFIER": | ||
if token_text == "error_if": | ||
return False | ||
if token_text.startswith("py") or token_text.startswith("_py"): | ||
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. There are static helper functions in 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. I guess the Maybe checking for both Existing macros that implicitly |
||
return False | ||
return True | ||
|
||
|
||
def main(): | ||
"""Parse command line, parse input, analyze, write output.""" | ||
args = arg_parser.parse_args() # Prints message and sys.exit(2) on error | ||
|
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.
Negative flags tend to lead to confusing double-negative code constructs. So I would prefer for the flag to be
CAN_RAISE_FLAG
thanNO_EXCEPTION_FLAG
, and similar throughout the PR.