Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
longtraceback longtraceback
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Charles Ferguson
  • longtracebacklongtraceback
  • Merge requests
  • !3

Merged
Created Oct 04, 2026 by Charles Ferguson@gerphMaintainer

Run a module with the shell using -m, as 'python -m' does

  • Overview 0
  • Commits 1
  • Changes 4

Adds -m <module> to longtraceback.shell, using runpy so it behaves as python -m does on Python 2.7 and 3.8 to 3.14 (packages and their __main__, relative imports, sys.argv[0], arguments after the module name passed through, current directory searched).

Replaces the approach in module-script-loading, which imported imp (removed in Python 3.12), was Python 3 only, dropped option-like arguments and did not run packages.

Tested by running modules under both python -m and the shell and comparing what the module sees and its exit code (Shell_test.py). Pipeline 12475 passes: lint, docs, coverage, shell integration tests and the tests on Python 2.7 and 3.8-3.14.

Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: module-invocation