Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when outputting special characters to shell #67

Closed
rtphokie opened this issue Apr 27, 2019 · 9 comments
Closed

Bug when outputting special characters to shell #67

rtphokie opened this issue Apr 27, 2019 · 9 comments

Comments

@rtphokie
Copy link

Noticed this error while snooping on a function that handles Unicode strings, pysnooper seems unhappy about the degree symbol here:

File "weather.py", line 390, in graphic_single
'location 1': u"%dºC / %dºF" % (round(data[sol]['max_temp']),
File "/Users/userid/Library/Python/2.7/lib/python/site-packages/pysnooper/tracer.py", line 184, in trace
'{frame.f_lineno:4} {source_line}'.format(**locals()))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xba' in position 33: ordinal not in range(128)

@cool-RR cool-RR changed the title Feature request: unicode support Bug when outputting special characters to shell Apr 27, 2019
@cool-RR
Copy link
Owner

cool-RR commented Apr 27, 2019

I think this isn't about PySnooper and unicode, it's about your shell not supporting the unicode characters. Please give a full reproduceable example.

@cool-RR
Copy link
Owner

cool-RR commented Apr 27, 2019

Also, your Python version.

@cc20101001
Copy link

I had the same problem before in python2.7 before,give a full reproduceable example,let me try it,thanks

@cc20101001
Copy link

cc20101001 commented May 2, 2019

d = "s*&F.。、]}】df"

in python2.7,Sometimes format not easy to use than %

use % replace format can resolve the problem or use format with unicode characters

@cool-RR
Copy link
Owner

cool-RR commented May 2, 2019

I reject #77. I won't change my string formatting method without proof that it's the cause of the problem. I'm waiting for a full reproducible example.

@cc20101001
Copy link

cc20101001 commented May 2, 2019

# coding=utf-8
from pysnooper import pysnooper


@pysnooper.snoop()
def test_format():
    d = "s*&F.。、]}】df"
    return d


test_format()

you can try it in python2.7,format Imperfect support for character sets。it is the same as 93edf6f

@alexmojaki
Copy link
Collaborator

I think it makes sense to add the u prefix as you've done in #77. I think you're confusing everyone by talking about the .format method and %, which is unrelated.

@cc20101001
Copy link

cc20101001 commented May 2, 2019

I think it makes sense to add the u prefix as you've done in #77. I think you're confusing everyone by talking about the .format method and %, which is unrelated.

i'm sorry

@cool-RR
Copy link
Owner

cool-RR commented May 2, 2019

I was able to replicate the problem on my machine, thank you @cc20101001 . I'll give it a think.

@cool-RR cool-RR closed this as completed in b8dec67 May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants