Skip to content

argparse: relative include of config files #74606

Open

Description

@efficiosoft
BPO 30421
Nosy @mlouielu, @efficiosoft
PRs
  • gh-74606: Add fromfile_parent_relative parameter to argparse.ArgumentParser #1698
  • Files
  • argparse_relative_includes.patch
  • argparse_relative_includes2.patch: Fixed reference to os.
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2017-05-21.08:15:42.296>
    labels = ['3.7', 'type-bug', 'library']
    title = 'argparse: relative include of config files'
    updated_at = <Date 2017-09-02.16:37:28.005>
    user = 'https://github.com/efficiosoft'

    bugs.python.org fields:

    activity = <Date 2017-09-02.16:37:28.005>
    actor = 'paul.j3'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2017-05-21.08:15:42.296>
    creator = 'roschi'
    dependencies = []
    files = ['46881', '46882']
    hgrepos = []
    issue_num = 30421
    keywords = ['patch']
    message_count = 3.0
    messages = ['294086', '294096', '294098']
    nosy_count = 4.0
    nosy_names = ['bethard', 'paul.j3', 'louielu', 'roschi']
    pr_nums = ['1698']
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue30421'
    versions = ['Python 3.6', 'Python 3.7']

    Activity

    1. efficiosoft commented on May 21, 2017

      efficiosoftmannequin
      MannequinAuthor

      Hi,

      When one includes an argument file at the command line using argparse and that file contains another include statement, the inner include path is treated as relative to os.getcwd(), what is not the way people expect it to be, I guess.

      This patch modifies argparse so that it treats paths of files to include as relative to the location of the file the include was made from.

      I also pulled statements that I think should not be enclosed by the try/except out of it and changed the workflow so that the file descriptor of an include file is closed before another one is opened by the recursive call to _read_args_from_files again.. That way, the number of file descriptors open at a time is kept low.

      Best regards
      Robert

    2. added
      3.7 (EOL)
      stdlib
      type-bug
      on May 21, 2017
    3. changed the title [-]Relative include of config files[/-] [+]argparse: relative include of config files[/+] on May 21, 2017
    4. mlouielu commented on May 21, 2017

      mlouielumannequin
      Mannequin

      Hi Robert, the submit flow has migrate to GitHub pull requests workflow, and it is strongly preferred to used GitHub PR workflow, do you mind to convert your patch to GitHub?

    5. efficiosoft commented on May 21, 2017

      efficiosoftmannequin
      MannequinAuthor

      I didn't notice that. But that's great news. I'll send a PR soon.

    6. transferred this issue fromon Apr 10, 2022
    7. added
      type-feature
      and removed
      type-bug
      on Feb 3, 2023
    8. moved this from Bugs to Features in Argparse issueson Feb 3, 2023
    9. terryjreedy commented on Feb 3, 2023

      @terryjreedy
      Member

      The issue and PR author is Robert Schindler. He was roschi on bpo and is called efficiosoft - mannequin above but is bob1de on github and the PR.

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

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)stdlibtype-feature

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions