roadmap: record the extern import-prefix bug - #45
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reported from the dogfooded app. Recorded as dogfooding finding #7 rather than fixed, per the instruction to look at it after the current sweep.
A dotted
externtarget emits the wrong import when a lowercase segment is an object rather than a submodule.lowering::extern_importtakes the maximal leading run of lowercase-initial segments, following PEP 8, so it works exactly when that run happens to be a real module:pathlib.Path.write_textimport pathlibPathis capitalised so the run stopsos.path.joinimport os.pathos.pathreally is a submodulesys.stdout.flushimport sys.stdoutstdoutis an objectThe emitted call is always correct; only the import line is wrong.
There is a working workaround today, verified:
extern import sysis consulted before the heuristic and emitsimport sys, after whichsys.stdout.flushresolves. Worth knowing while the fix waits.The suggested fix needs amending. "Import the longest importable prefix" is not statically decidable — whether
urllib.requestorsys.stdoutis a module is a property of the target environment, not of the text. "Always import the top-level package" only trades one broken case for another; verified on CPython 3.14:So the entry records three candidates instead: a guarded deeper import (
try/except ImportError, correct everywhere, mildly ugly, once per module); rejecting the ambiguous shape at compile time with a fix-it naming theextern importto add (fits "the compiler is the gatekeeper", no runtime cost); or both.Docs only.