manyixu / rssdler

Automatically exported from code.google.com/p/rssdler
0 stars 0 forks source link

TypeError not caught in bdecode() #49

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This is with 0.4.2.

Some torrent files seem to not decode correctly. In bdecode(), line 916 (of
version 0.4.2), this leans to the 'open' failing with TypeError.

Traceback is:
20091203.21:26 CRITICAL Unexpected Error: Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/rssdler.py", line 2044, in main
    run()
  File "/usr/local/lib/python2.6/dist-packages/rssdler.py", line 2016, in run
    rssparse(key)
  File "/usr/local/lib/python2.6/dist-packages/rssdler.py", line 1919, in
rssparse
    userFunctArgs = downloadFile(ppage['entries'][i]['link'], tName,
ppage['entries'][i], dirDict)
  File "/usr/local/lib/python2.6/dist-packages/rssdler.py", line 746, in
downloadFile
    size, data2 = getFileSize(data.info(), data)
  File "/usr/local/lib/python2.6/dist-packages/rssdler.py", line 610, in
getFileSize
    try: tparse = bdecode(data)
  File "/usr/local/lib/python2.6/dist-packages/rssdler.py", line 877, in
bdecode
    x = open(x, 'r').read()
TypeError: file() argument 1 must be encoded string without NULL bytes, not str

The fix is to catch TypeError:

    try:
        x = open(x, 'r').read()
        r, l = decode_func[x[0]](x,0)     
    except (OSError, IOError, IndexError, KeyError, TypeError): raise
ValueError

Original issue reported on code.google.com by don.wate...@gmail.com on 7 Dec 2009 at 5:50