nghung270192 / colorama

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

'\033[2J' error in FillConsoleOutputCharacter #35

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When trying to execute following sequence

print '\033[2J'

On Windows 7 I get the following error:

Traceback (most recent call last):
  File "C:\Development\Python\Outlook2Files\test_colorizer.py", line 13, in <module> 
    print '\033[2J'
  File "C:\Development\Python\Outlook2Files\colorama\ansitowin32.py", line 34, in write
    self.__convertor.write(text)
  File "C:\Development\Python\Outlook2Files\colorama\ansitowin32.py", line 115, in write
    self.write_and_convert(text)
  File "C:\Development\Python\Outlook2Files\colorama\ansitowin32.py", line 140, in write_an
d_convert
    self.convert_ansi(*match.groups())
  File "C:\Development\Python\Outlook2Files\colorama\ansitowin32.py", line 154, in convert_
ansi
    self.call_win32(command, params)
  File "C:\Development\Python\Outlook2Files\colorama\ansitowin32.py", line 181, in call_win
32
    func(params, on_stderr=self.on_stderr)
  File "C:\Development\Python\Outlook2Files\colorama\winterm.py", line 116, in erase_data
    win32.FillConsoleOutputCharacter(handle, ord(' '), dw_con_size, coord_screen)
  File "C:\Development\Python\Outlook2Files\colorama\win32.py", line 92, in FillConsoleOutp
utCharacter
    char = TCHAR(char)
TypeError: one character string expected

Error is not reproduced when output of the file is redirected.
Other functions of the module work fine.
I have come up with forcible conversion of the parameter to char in function 
FillConsoleOutputCharacter file win32.py line 92), where parameter char was 
transferred as int.

What version of the product are you using? On what operating system?
Version - latest - from repository of 6-Dec-2011. Operating system Window 7.

I attach changed file win32.py, which solved the issue for me.

Original issue reported on code.google.com by vaal1239@gmail.com on 6 Jan 2012 at 12:26

Attachments:

GoogleCodeExporter commented 9 years ago
Same problem, fixed by changing line 98 of winterm.py to have ' ', not ord(' 
'); this was on version 0.2.4 [2010].

Original comment by dave.mc...@gmail.com on 21 Feb 2012 at 1:18

GoogleCodeExporter commented 9 years ago
Thanks for the report and the fix, people! I've been getting hold of a Windows 
7 machine, and will incorporate the fix and make a new release in the next few 
days.

Original comment by tart...@gmail.com on 21 Feb 2012 at 11:45

GoogleCodeExporter commented 9 years ago
Also reported by Lackner Kristof: k.lackner@holografika.com, who suggested the 
same fix.

File "C:\Python27\lib\site-packages\colorama\ansitowin32.py", line 34, in write
    self.__convertor.write(text)

  File "C:\Python27\lib\site-packages\colorama\ansitowin32.py", line 115, in write
    self.write_and_convert(text)

  File "C:\Python27\lib\site-packages\colorama\ansitowin32.py", line 140, in write_and_convert
    self.convert_ansi(*match.groups())

  File "C:\Python27\lib\site-packages\colorama\ansitowin32.py", line 154, in convert_ansi
    self.call_win32(command, params)

  File "C:\Python27\lib\site-packages\colorama\ansitowin32.py", line 181, in call_win32
    func(params, on_stderr=self.on_stderr)

  File "C:\Python27\lib\site-packages\colorama\winterm.py", line 98, in erase_data
    win32.FillConsoleOutputCharacter(handle, ord(' '), dw_con_size, coord_screen)

  File "C:\Python27\lib\site-packages\colorama\win32.py", line 92, in FillConsoleOutputCharacter
    char = TCHAR(char)

Original comment by Jonat...@rangespan.com on 24 Jan 2013 at 5:46

GoogleCodeExporter commented 9 years ago

Original comment by tart...@gmail.com on 24 Jan 2013 at 5:47

GoogleCodeExporter commented 9 years ago
I'm going to just push this change based on the 3 reports that it works. I 
don't currently have a windows machine on which to test. Fingers crossed. 
Thanks all.

Original comment by tart...@gmail.com on 20 Feb 2013 at 8:02

GoogleCodeExporter commented 9 years ago
Fix pushed. Bumped version to 0.2.5 and uploaded a new release. Yay, thanks all.

Original comment by tart...@gmail.com on 20 Feb 2013 at 8:10