Comments (9)
Let me look into this :)
from better-exceptions.
I think this has to do with cmd. Maybe the encoding is messing up the escape sequence, or it needs to output slightly differently on windows?
from better-exceptions.
Hello,
My cmd CP is 850.
Python's locale.getpreferredencoding() output is 'cp1252'.
If it helps, on my colorama game I use these (that work) to show color/brightness and change position:
from colorama import init, Style, Fore, Back
DOCK = Style.BRIGHT + Fore.YELLOW + '===' + Style.RESET_ALL
SEA = (Back.BLUE + ' ' * 51 + Back.RESET)
print(Style.BRIGHT + ''.join(items) + Style.DIM) # show bright items
print('\x1b[%d;%dH' % (line, col)) # set print pos at line, col
print('\x1b[%d;%dH%s' % (line, col, text)) # print text at pos line, col
Best regards,
JM
from better-exceptions.
Hi - can you try the branch fix-windows-encoding
?
The tricky part about this bug is that the ANSI escapes were being encoded, too. This might require a much larger overhaul of output building since we'd still want to encode the text but not the color escapes.
from better-exceptions.
from better-exceptions.
@jcrmatos try
pip install https://github.com/qix-/better-exceptions/archive/fix-windows-encoding.tar.gz
from better-exceptions.
Hello,
It uninstalled version 0.1.6 and installed your tgz file.
when I run the following script
import better_exceptions
def a():
a = 5
b = 'aaa'
print(a + b)
a()
it returns these errors
C:\Users\JMatos\OneDrive\JMatos-P\Desktop>python teste.py
Error in sys.excepthook:
Traceback (most recent call last):
File "C:\Python35-32\lib\site-packages\better_exceptions\__init__.py", line 30
5, in excepthook
write_stream(full_trace)
File "C:\Python35-32\lib\site-packages\better_exceptions\__init__.py", line 29
4, in write_stream
STREAM.buffer.write(data)
TypeError: a bytes-like object is required, not 'str'
Original exception was:
Traceback (most recent call last):
File "teste.py", line 8, in <module>
a()
File "teste.py", line 6, in a
print(a + b)
TypeError: unsupported operand type(s) for +: 'int' and 'str'
Best regards,
JM
from better-exceptions.
Alright I'll get to fixing this later today. I'm going to need to fix how ANSI codes are built up.
Thanks for bringing this to my attention :)
from better-exceptions.
With Windows 10 Anniversary update and above, you can
import ctypes
kernel32 = ctypes.windll.kernel32
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
(-11 is the standard out constant, 7 is the new ansi color support)
I put this in my better-exceptions hook, made my console cp65001 by default, and modified __init__.py
as such
try:
PIPE_CHAR.encode(sys.stdout.encoding)
except UnicodeEncodeError:
PIPE_CHAR = '|'
CAP_CHAR = '->'
from better-exceptions.
Related Issues (20)
- FileNotFoundError on PyPy HOT 4
- TERM setting of tmux-256color vs screen… HOT 3
- Not working with ~/.python_history
- threading.excepthook new in python 3.8
- Include Django middleware in better-exceptions HOT 3
- ModuleNotFoundError: No module named 'better_exceptions.integrations' HOT 3
- weird escape chars instead of lines HOT 5
- why "export BETTER_EXCEPTIONS=1" works? HOT 1
- terminfo (tmux-256color, xterm-256color) not considered to be valid HOT 6
- Don't print stack frames from certain libraries HOT 5
- How to hide sensibles data like passwords, tokens, ... HOT 1
- 0.3.3: pytest is failing HOT 3
- Installing from pip triggers a "WARNING: There was an error checking the latest version of pip." HOT 1
- f_lineno not an attribute on traceback
- Define license on pypi HOT 2
- Add environment variable support for MAX_LENGTH initialization
- How to use better-exceptions in pytest?
- Can't work in child process HOT 3
- python3.11 traceback raise StopIteration
- How do I get the colors ro work in Django?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from better-exceptions.