1
votes

I'm currently loading a color value from a text file, and pygame is giving me errors with it. It works fine on my Windows computer, but not on my Linux with identical code. Here's an example of what sort of shenanigans this code is pulling:

color = getSetting('playerColor')  //reads a .ini from SafeConfigParser
print color                        //prints: #f54e4e
print pygame.Color('#f54e4e')      //prints: (245, 78, 78, 255)
print pygame.Color(color)          //throws invalid argument error

The linux-only nature of this leads me to believe it's something to do with encoding. I've heard pygame.Color breaks if future unicode_literals is imported, but it isn't. I'm in python 2.7, pygame 1.9.1

Any string I try to pass directly seems to work just fine.

1

1 Answers

3
votes

It is possible that color is not a str but a unicode object. Try

print pygame.Color(str(color))

You can debug it by printing the type of color object:

print type(color)