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

NewPyBuildSupport: Add build matrix entries for 3.11 and 3.12 #77

Merged
merged 4 commits into from
Feb 19, 2024

Conversation

gabe-l-hart
Copy link
Collaborator

No description provided.

# If all else fails, we'll just return a sentinel string. This will fail to
# match in the below check for builtin modules
return "BADPATH" # pragma: no cover
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to get rid of # pragma: no cover here with a little inlining

def _get_exception_table(dis_lines: List[str]) -> Dict[int, int]:
"""For 3.11+ exception handling, parse the Exception Table"""
table_start = [i for i, line in enumerate(dis_lines) if line == "ExceptionTable:"]
assert len(table_start) <= 1, "Found multiple exception tables!"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not encountered a case where this is larger than 1 and can't imagine a circumstance under which it would be, but I haven't exhaustively read the spec either, so if this ever trips, we may need to investigate this further.

@@ -377,7 +413,7 @@ def _figure_out_import(
log.debug3("Module file: %s", getattr(mod, "__file__", None))
if not import_name:
import_name = root_mod_name
else:
elif root_mod_name:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change showed up as I was trying to understand why some modules were not identified as optional. I believe this was a bug since the resulting name could be ".foobar" which would not show up in sys.modules when "foobar" would.

@@ -419,15 +455,23 @@ def _get_imports(mod: ModuleType) -> Tuple[Set[ModuleType], Set[ModuleType]]:
open_import = False
open_tries = set()
log.debug4("Byte Code:")
for line in bcode.dis().split("\n"):
dis_lines = bcode.dis().split("\n")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the need to iterate the lines twice, but this should be a pretty small performance penalty

@gabe-l-hart gabe-l-hart merged commit 89db745 into main Feb 19, 2024
7 checks passed
@gabe-l-hart gabe-l-hart deleted the NewPyBuildSupport branch February 19, 2024 21:04
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.

1 participant