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

Unicode assumption fails #4

Closed
jaraco opened this issue May 13, 2012 · 4 comments
Closed

Unicode assumption fails #4

jaraco opened this issue May 13, 2012 · 4 comments
Labels
bug Something isn't working major

Comments

@jaraco
Copy link
Owner

jaraco commented May 13, 2012

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.

@jaraco
Copy link
Owner Author

jaraco commented May 14, 2012

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


Possible fix

#!diff

--- a/configparser.py
+++ b/configparser.py
@@ -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:

@jaraco
Copy link
Owner Author

jaraco commented Jul 11, 2012

Original comment by Anonymous.


I am running into this bug also, please fix it.

@jaraco
Copy link
Owner Author

jaraco commented Dec 31, 2012

Original comment by Łukasz Langa (Bitbucket: ambv, GitHub: ambv).


Sorry to have kept you waiting for so long. I somehow missed notifications about that issue.

This is now fixed in version 3.3.0r1. Thank you for your feedback.

@jaraco jaraco closed this as completed Dec 31, 2012
@jaraco
Copy link
Owner Author

jaraco commented Dec 31, 2012

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


Cool, thanks — and happy new year! :)

@jaraco jaraco added major bug Something isn't working labels Jan 23, 2019
jaraco pushed a commit that referenced this issue Jan 23, 2019
jaraco pushed a commit that referenced this issue Jan 29, 2019
use spaces, fixed indentation, format using autopep8
jaraco added a commit that referenced this issue Jul 8, 2023
* Create SECURITY.md

Signed-off-by: Joyce <[email protected]>

* Remove the security contact from the README, as it's now redundant.

Closes jaraco/tidelift#3.

---------

Signed-off-by: Joyce <[email protected]>
Co-authored-by: Joyce <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working major
Projects
None yet
Development

No branches or pull requests

1 participant