Colorama AssertionError in Python 3.2
Asked Answered
B

1

3

I've recently started using Python 3.2 and have never attempted programming before. I copied the colorama folder to the lib directory in C:\Python32\lib and then made the following code in my attempt at a text-based adventure game:

 import colorama
    from colorama import Fore, Back, Style
    colorama.init()

    notedaction = "You have gained a SWORD AND SHIELD!"
    uniqueskill = "strength"

        if 'strength' in uniqueskill.lower():
           time.sleep(3)
           print('As you are a Warrior, I shall supply you with the most basic tools every Warrior needs.')
           time.sleep(3)
           print('A sword and shield.')
           time.sleep(1)
           print(Fore.RED + notedaction)

However, whenever I reach this section of code, I am given the following error:

  File "<pyshell#10>", line 7, in <module>
    print(Fore.RED + notedaction)
  File "C:\Python32\lib\colorama\ansitowin32.py", line 34, in write
    self.__convertor.write(text)
  File "C:\Python32\lib\colorama\ansitowin32.py", line 115, in write
    self.write_and_convert(text)
  File "C:\Python32\lib\colorama\ansitowin32.py", line 140, in write_and_convert
    self.convert_ansi(*match.groups())
  File "C:\Python32\lib\colorama\ansitowin32.py", line 154, in convert_ansi
    self.call_win32(command, params)
  File "C:\Python32\lib\colorama\ansitowin32.py", line 175, in call_win32
    func(*args, **kwargs)
  File "C:\Python32\lib\colorama\winterm.py", line 48, in fore
    self.set_console(on_stderr=on_stderr)
  File "C:\Python32\lib\colorama\winterm.py", line 68, in set_console
    win32.SetConsoleTextAttribute(handle, attrs)
  File "C:\Python32\lib\colorama\win32.py", line 66, in SetConsoleTextAttribute
    assert success
AssertionError

Any ideas on what is wrong?

Bodoni answered 5/5, 2011 at 18:6 Comment(2)
code.google.com/p/colorama/issues/detail?id=19Arrest
Hey. I'm the author of Colorama. I don't know how to fix this bug in Colorama. It makes win32 calls which fail when called from within IDLE. It would perhaps be more useful if I were to simply stop performing the assertion for 'success' on the return value of the win32 call. That would make the exception go away (but of course, we still wouldn't have any colored output, which is the point of colorama.) Thoughts, anyone?Kesler
S
3

It seems to be an issue of : colorama 0.1.18 with IDLE try in the real python interpretor.

Storey answered 5/5, 2011 at 18:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.