ssimunic / Daily-Reddit-Wallpaper

Change your wallpaper to the most upvoted image of the day from /r/wallpapers or any other subreddit on system startup
http://ssimunic.github.io/Daily-Reddit-Wallpaper/
GNU General Public License v3.0
306 stars 51 forks source link

Fix 'TypeError: initial_value must be unicode or None, not str' when … #18

Closed OuO closed 8 years ago

OuO commented 8 years ago

…load_config().

remggo commented 8 years ago

What exactly fixes this PR? If in the config unicode literals are?

OuO commented 8 years ago

First, Sorry for unfriendly PR message.

I use Ubuntu 14.04. (w/ python 2.7.6 ) I try to execute change_wallpaper_reddit.py without '~/.config/change_wallpaper_reddit.rc' and it works fine~ and also with command arguments too.

But I configured '~/.config/change_wallpaper_reddit.rc' as 'example' and then try to run it.

I got error message

$ ./change_wallpaper_reddit.py Traceback (most recent call last): File "./change_wallpaper_reddit.py", line 66, in config = load_config() File "./change_wallpaper_reddit.py", line 37, in load_config stream_read=stream.read())) TypeError: initial_value must be unicode or None, not str

So I try execute try: config = ConfigParser(default) with open(config_path, "r") as stream: stream = StringIO("[{section_name}]\n{stream_read}".format(section_name=section_name, stream_read=stream.read()))

with same string as 'example' in my system. it also raise exception.

I think 'config' string should be convert to unicode. ( https://docs.python.org/2/library/stringio.html )

So I think import 'future.unicode_literals' better than add 'u' simbol in StringIO().