GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stdlib: resolve absolute script paths independently of sys.path by ac1982 · Pull Request #261 · go-python/gpython

Conversation

@ac1982

@ac1982 ac1982 commented Oct 11, 2026

Copy link
Copy Markdown

RunFile fails to open an existing absolute script path with the default compile options: resolveRunPath joins it to "." first, which removes the leading slash before the absolute-path check. With an empty sys.path, it never attempts the file at all.

Resolve absolute inputs independently of search directories by joining them only to an empty prefix. Relative-path search and existing error handling are unchanged. Add an execution regression using a real temporary script with both default options and an empty sys.path.

Fixes #259. This is independent of the nil-module-pointer fix in #260 and is based directly on main.

Validation on Linux/arm64:

  • Both absolute-path cases fail with FileNotFoundError before the fix and pass afterward.
  • Go 1.27.1 full project runner with -tags=ci -race -coverpkg=github.com/go-python/gpython/... passes.
  • Go 1.18.10 targeted test and Staticcheck 2022.1.3 across all packages pass.
  • goimports and git diff --check pass. Windows/macOS runtime behavior was not tested.

Author registration: go-python/license#24.

AI assistance: this fix and its regression tests were developed and verified with an AI coding agent.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ac1982
stdlib: resolve absolute script paths independently of sys.path
e53e007
@drew-512

drew-512 commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Tested against main (444ae5e): path.Join(".", "/tmp/script.py") cleans to tmp/script.py, so the absolute path gets retried under CurDir and the working directory and fails with FileNotFoundError, and with an empty sys.path nothing is tried at all. With this change, absolute paths resolve with CompileOpts{} and with UseSysPaths, a script run by absolute path can still import a module next to it, and relative paths with CurDir behave as before. The new test fails on main and passes here.

One coordination note: this PR and my #268 both added stdlib/stdlib_test.go, so whichever merged second would have conflicted. I've renamed the test in #268 to stdlib/moduleinit_test.go; the two now merge cleanly in either order.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

stdlib: RunFile fails to resolve absolute script paths

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@ac1982 @drew-512
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.