Skip to content
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

configparser.ConfigParser.read() does not accept Pathlib path as a single argument. #73809

Closed
DavidCEllis mannequin opened this issue Feb 22, 2017 · 3 comments
Closed
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@DavidCEllis
Copy link
Mannequin

DavidCEllis mannequin commented Feb 22, 2017

BPO 29623
Nosy @mcepl, @berkerpeksag, @DavidCEllis
PRs
  • bpo-29623: Make pathlib objects work with ConfigParser.read. #242
  • [3.6] bpo-29623: Make PathLike objects work with ConfigParser.read() (#242) #432
  • 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 = <Date 2017-03-03.18:25:22.565>
    created_at = <Date 2017-02-22.18:48:55.601>
    labels = ['3.7', 'type-bug', 'library']
    title = 'configparser.ConfigParser.read() does not accept Pathlib path as a single argument.'
    updated_at = <Date 2018-03-06.19:26:27.420>
    user = 'https://github.com/DavidCEllis'

    bugs.python.org fields:

    activity = <Date 2018-03-06.19:26:27.420>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-03-03.18:25:22.565>
    closer = 'berker.peksag'
    components = ['Library (Lib)']
    creation = <Date 2017-02-22.18:48:55.601>
    creator = 'David Ellis'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 29623
    keywords = []
    message_count = 3.0
    messages = ['288378', '290326', '290328']
    nosy_count = 3.0
    nosy_names = ['mcepl', 'berker.peksag', 'David Ellis']
    pr_nums = ['242', '432']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue29623'
    versions = ['Python 3.6', 'Python 3.7']

    @DavidCEllis
    Copy link
    Mannequin Author

    DavidCEllis mannequin commented Feb 22, 2017

    Trying to use configparser.ConfigParser.read on a pathlib object results in a TypeError. If supplied in a list it works as expected.

    Repro:
        >>> import pathlib, configparser
        >>> configparser.ConfigParser().read(pathlib.Path('some.ini'))
    TypeError: 'PosixPath' object is not iterable
    

    The issue appears to be line 690 which checks for str before attempting to iterate and doesn't check for os.PathLike (or bytes?).

    This was actually mentioned as an example where pathlib did not work here: https://bugs.python.org/issue22570

    @DavidCEllis DavidCEllis mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Feb 22, 2017
    @berkerpeksag
    Copy link
    Member

    New changeset 21ce65a by Berker Peksag in branch '3.6':
    [3.6] bpo-29623: Make PathLike objects work with ConfigParser.read() (#242) (#432)
    21ce65a

    @berkerpeksag
    Copy link
    Member

    New changeset 85b8d01 by Berker Peksag (David Ellis) in branch 'master':
    bpo-29623: Make PathLike objects work with ConfigParser.read() (#242)
    85b8d01

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant