Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Trac Trac
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Issues 246
    • Issues 246
    • List
    • Boards
    • Service Desk
    • Milestones
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
  • Wiki
    • Wiki
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • Legacy
  • TracTrac
  • Issues
  • #8755

Closed
Open
Created Apr 21, 2013 by Trac@tracbot

Controller handles content as unicode in python 3.x

I am getting some errors when using Stem with Python 3 when iterating though all values return from controller.get_server_descriptors(). The error happens in /usr/local/lib/python3.2/dist-packages/stem/descriptor/server_descriptor.py . I have fixed some of these errors (see attached file) but I think there are more problems with the way the "digest" variable is created. For example, if self.digest() returns 0222F10950D2177B99288E9D133FAB1B0848AE70, the digest variable is given the value

b'{q#a3l\xb9\xa7,\xb5\xf0EX\xa9\xca\xd6\xe1\xae!\x10'

but the proper encoding would be

b'\x02"\xf1\tP\xd2\x17{\x99(\x8e\x9d\x13?\xab\x1b\x08H\xaep'

I should also note that I have not tested this patch with Python 2.x yet.

This is the error which still happens with some digests:

Traceback (most recent call last): File "./xxx.py", line 32, in for each in server_descriptors: File "/usr/local/lib/python3.2/dist-packages/stem/control.py", line 1121, in get_server_descriptors raise exc File "/usr/local/lib/python3.2/dist-packages/stem/control.py", line 1117, in get_server_descriptors for desc in stem.descriptor.server_descriptor._parse_file(io.BytesIO(str_tools._to_bytes(desc_content))): File "/usr/local/lib/python3.2/dist-packages/stem/descriptor/server_descriptor.py", line 137, in _parse_file yield RelayDescriptor(descriptor_text, validate, annotations) File "/usr/local/lib/python3.2/dist-packages/stem/descriptor/server_descriptor.py", line 646, in !init! self._validate_content() File "/usr/local/lib/python3.2/dist-packages/stem/descriptor/server_descriptor.py", line 697, in _validate_content self._verify_digest(key_as_bytes) File "/usr/local/lib/python3.2/dist-packages/stem/descriptor/server_descriptor.py", line 768, in _verify_digest raise ValueError("Decrypted digest does not match local digest") ValueError: Decrypted digest does not match local digest

Feel free to contact me if you have any questions.

Trac:
Username: aj00200

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking