cjlucas/rtorrent-python — Issue #2: TorrentParser is broken under Python2
Author: cjlucas
Created: 2011-11-07 23:54:10+00:00
State: open
Labels: Priority - High, Type - Defect

```
>>> import rtorrent
>>> rtorrent.lib.torrentparser.TorrentParser("Ubuntu.torrent")
Traceback (most recent call last):
File "tests/load_torrent_test.py", line 23, in
main()
File "tests/load_torrent_test.py", line 17, in main
t = r.load_torrent(os.path.abspath(torrent))
File "/Users/chris/Dropbox/code/python/rtorrent-python/rtorrent/__init__.py", line 200, in load_torrent
tp = TorrentParser(torrent)
File "/Users/chris/Dropbox/code/python/rtorrent-python/rtorrent/lib/torrentparser.py", line 49, in __init__
if self._torrent_decoded is None: self._decode_torrent()
File "/Users/chris/Dropbox/code/python/rtorrent-python/rtorrent/lib/torrentparser.py", line 82, in _decode_torrent
self._torrent_decoded = bencode.decode(raw_torrent)
File "/Users/chris/Dropbox/code/python/rtorrent-python/rtorrent/lib/bencode.py", line 170, in decode
data = data.encode()
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa7 in position 70899: ordinal not in range(128)
```

I got this result with both Python 2.6.7 and 2.7.1. It loads fine with 3.2.2 though.