Skip to content

Unicode assumption fails #4

@jaraco

Description

@jaraco

Original report by Klaus Alexander Seistrup (Bitbucket: kseistrup, GitHub: kseistrup).


Standing in a directory with a setup.cfg file, using python2.7:

#!python

>>> import configparser
>>> parser=configparser.ConfigParser()
>>> parser.read('setup.cfg')
[]
>>> parser.read(u'setup.cfg')
[u'setup.cfg']
>>>

So if there accidentally is a file byt the name of s, e, t, u, p, c, f, or g, that file will be read:

#!python

$ ln -s setup.cfg s
$ python2.7
>>> import configparser
>>> parser=configparser.ConfigParser()
>>> parser.read('setup.cfg')
['s']
>>>

Hint: ConfigParser()'s .read() method says that the filename should only be included in the file list if the name is a unicode instance, and thus a plain string object gets treated as a list.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmajor

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions