Skip to content

fix(parser-custom): handle relative parent directory paths to module file better #1142

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

Conversation

codejedi365
Copy link
Contributor

Purpose

  • Avoids any issues with dynamic importing given a file name with parent path traversals

Rationale

The dynamic import originally would just replace "/" with "." to make the import module name more pythonic, however this would be problematic in monorepos which would use "../../misc/commit_parser.py" to locate the parser and so the resulting sys.modules entry would have numerous periods (.) as a prefix. This removes that possibility. Still always an issue if the imported module name matches an existing module but the likelihood is low.

How did you test?

Used my codejedi365/psr-monorepo-poweralpha repository to test a custom monorepo parser and release

…file better

The dynamic import originally would just replace "/" with "." to make the
import module name more pythonic, however this would be problematic in
monorepos which would use "../../misc/commit_parser.py" to locate the parser
and so the resulting `sys.modules` entry would have numerous periods (.)
as a prefix. This removes that possibility. Still always an issue if the
imported module name matches an existing module but the likelihood is low.
@codejedi365 codejedi365 self-assigned this Jan 12, 2025
@codejedi365 codejedi365 merged commit c4056fc into python-semantic-release:master Jan 12, 2025
12 checks passed
@codejedi365 codejedi365 deleted the fix/parent-paths-in-dynamic-import branch January 12, 2025 19:49
@codejedi365
Copy link
Contributor Author

🎉 This PR has been published as part of Version 9.16.1 🎉

You can find more information about this release on the GitHub Releases page.

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