Issue #4 resolved

Unicode assumption fails

Klaus Alexander Seistrup
created an issue

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



import configparser parser=configparser.ConfigParser()'setup.cfg') []'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:



$ ln -s setup.cfg s $ python2.7

import configparser parser=configparser.ConfigParser()'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.

Comments (4)

  1. Klaus Alexander Seistrup reporter

    Possible fix

    --- a/
    +++ b/
    @@ -701,7 +701,7 @@ class RawConfigParser(MutableMapping):
             Return list of successfully read files.
    -        if isinstance(filenames, unicode):
    +        if isinstance(filenames, unicode) or isinstance(filenames, str):
                 filenames = [filenames]
             read_ok = []
             for filename in filenames:
  2. Log in to comment