colors.py icon indicating copy to clipboard operation
colors.py copied to clipboard

Blendmode didn't work correctly in Python 3.6

Open 2hands10fingers opened this issue 7 years ago • 5 comments

h = hex('54a050').overlay(rgb(76, 83, 10)).hex
print(h)

produced this error:

Traceback (most recent call last):
  File "testing.py", line 18, in <module>
    h = rgb('768310').hex
  File "/Library/Python/2.7/site-packages/colors/base.py", line 194, in __init__
    raise ValueError('Color values must be between 0 and 255')
ValueError: Color values must be between 0 and 255

It worked fine in Python 2.7.10

2hands10fingers avatar Dec 16 '17 17:12 2hands10fingers

It looks like you’re just using it wrong? Unless I’m misunderstanding.

rgb('768310') isn’t the right input for rgb() at all.

mattrobenolt avatar Dec 16 '17 18:12 mattrobenolt

And also, you say 3.6, but your stacktrace is 2.7.

mattrobenolt avatar Dec 16 '17 18:12 mattrobenolt

Thank you for getting back to me. I tried it again making sure I'm using Python 3.

Traceback (most recent call last):
  File "testing.py", line 24, in <module>
    h = hex('54a050').overlay(rgb(76, 83, 10)).hex
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/colors/base.py", line 114, in overlay
    return self.screen(self.multiply(other))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/colors/base.py", line 53, in multiply
    self_rgb.red * other_rgb.red / 255.0,
AttributeError: 'RGBColor' object has no attribute 'red'

I also don't see any instance of me typing rgb('768310'). I have separated those out clearly into integers with commas as the code shows.

2hands10fingers avatar Dec 16 '17 19:12 2hands10fingers

Ok, that looks like a better stacktrace. This is because of the way I'm using metaclasses which have changed for python3. Are you willing to submit a PR? If not, I can try it out this weekend. I'm not a python3 user myself yet. :(

mattrobenolt avatar Dec 16 '17 22:12 mattrobenolt

Let me put it this way:

Uh, what's a metaclass?

2hands10fingers avatar Dec 17 '17 05:12 2hands10fingers