Opened 5 years ago

Closed 5 years ago

#8265 closed defect (fixed)

UnicodeEncodeError: 'ascii' codec can't encode character u'\xab' in position 950: ordinal not in range(128)

Reported by: gsathya Owned by: atagar
Priority: Medium Milestone:
Component: Core Tor/Stem Version:
Severity: Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

"malformed" contact line causes stem to break when printing that desc(stem parses it fine). Attached descriptor.

Child Tickets

Attachments (1)

desc.txt (1.6 KB) - added by gsathya 5 years ago.

Download all attachments as: .zip

Change History (4)

Changed 5 years ago by gsathya

Attachment: desc.txt added

comment:1 Changed 5 years ago by atagar

Status: newneeds_information

Hi Sathyanarayanan. The contact address is parsed by stem as a unicode string. It can be printed, you just need to be careful because str() will fail to convert it...

>>> from stem.descriptor import parse_file

>>> with open('desc.txt') as descriptor_file:
...   desc = next(parse_file(descriptor_file))
... 

>>> desc.contact
u'1024D/070E3F2D Marcus Griep \xabtormaster%xpdm%us\xbb'

>>> print desc.contact
1024D/070E3F2D Marcus Griep «tormaster%xpdm%us»

>>> str(desc.contact)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xab' in position 28: ordinal not in range(128)

Did you have any other questions?

comment:2 Changed 5 years ago by gsathya

Aha thanks!

Is there a way to fix Descriptor.str so that it doesn't break?

comment:3 Changed 5 years ago by atagar

Resolution: fixed
Status: needs_informationclosed
Note: See TracTickets for help on using tickets.