nghung270192 / colorama

Automatically exported from code.google.com/p/colorama
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

colorama 0.1.18 throws AssertionError #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Probably something ignorant I did or did not do. 
Any help appreciated
emayo7x24@gmail.com

What steps will reproduce the problem?
1.Installed using easy_install
2.Ran attached test
3.

What is the expected output? What do you see instead?
see below

What version of the product are you using? On what operating system?
* colorama 0.1.18
* XP Professional version 2002 Service Pack 3
* Python 2.6.4

Please provide any additional information below.

==Output from colorama test================================

IDLE 2.6.4     
>>> from colorama import init
>>> init()
>>> from colorama import Fore, Back, Style
>>> print Fore.RED + 'some red text'

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    print Fore.RED + 'some red text'
  File "C:\Program Files\Python26\lib\site-packages\colorama\ansitowin32.py", line 34, in write
    self.__convertor.write(text)
  File "C:\Program Files\Python26\lib\site-packages\colorama\ansitowin32.py", line 115, in write
    self.write_and_convert(text)
  File "C:\Program Files\Python26\lib\site-packages\colorama\ansitowin32.py", line 140, in write_and_convert
    self.convert_ansi(*match.groups())
  File "C:\Program Files\Python26\lib\site-packages\colorama\ansitowin32.py", line 154, in convert_ansi
    self.call_win32(command, params)
  File "C:\Program Files\Python26\lib\site-packages\colorama\ansitowin32.py", line 175, in call_win32
    func(*args, **kwargs)
  File "C:\Program Files\Python26\lib\site-packages\colorama\winterm.py", line 48, in fore
    self.set_console(on_stderr=on_stderr)
  File "C:\Program Files\Python26\lib\site-packages\colorama\winterm.py", line 68, in set_console
    win32.SetConsoleTextAttribute(handle, attrs)
  File "C:\Program Files\Python26\lib\site-packages\colorama\win32.py", line 66, in SetConsoleTextAttribute
    assert success
AssertionError
>>>
=========================================================

==Installation output from DOS command window=========================
C:\Program Files\Python26\Scripts>easy_install colorama
Searching for colorama
Best match: colorama 0.1.18
Adding colorama 0.1.18 to easy-install.pth file

Using c:\program files\python26\lib\site-packages
Processing dependencies for colorama
Finished processing dependencies for colorama
=========================================================

Original issue reported on code.google.com by emayo7...@gmail.com on 11 Oct 2010 at 10:18

GoogleCodeExporter commented 9 years ago
Thanks for reporting this error. I've confirmed that I can reproduce the 
problem here.

I'd never tried using colorama from IDLE before - I've only ever run it from a 
'cmd' text console window, or a text terminal on Linux.

The traceback shows that the Win32 library is refusing the set the console text 
color, presumably because it does not recognize IDLE as a text console.

I don't know how to fix this, so unless I have any bright ideas, I'm 
regretfully going to add 'does not work in IDLE' to the documentation, clarify 
how to run colorama in a text terminal, and then mark this defect as 'will not 
fix' or somesuch.

Your efforts are much appreciated, many thanks.

Original comment by tart...@gmail.com on 15 Oct 2010 at 2:02

GoogleCodeExporter commented 9 years ago
The problem is that IDLE reports that it is a tty, when it is not:

-------------------
IDLE 1.2.2
>>> import sys
>>> sys.stdout.isatty()
True
>>>
-------------------

If I try the same code in, for example PSPad (running a simple test.py, 
capturing the output) it returns False.

Trying that on PyScripter's Python shell fails because it replaces sys.stdout 
with an object that doesn't has an isatty() method.

Sort version: I agree with the "will not fix".

Original comment by oscar.le...@gmail.com on 15 Oct 2010 at 7:57

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago

Original comment by tart...@gmail.com on 19 Jun 2011 at 6:48