python-kyototycoon icon indicating copy to clipboard operation
python-kyototycoon copied to clipboard

python 3

Open bsapiro opened this issue 12 years ago • 0 comments

to make this library work in python 3, run 2to3 over the code then modify the code starting at line 563 of kt_http.py (the function called _tsv_to_dict ) so that the byte array (which is returned by python 3's urllib) is converted to a string.

def _tsv_to_dict(self, tsv_str):
    rv = {}
    tsv_str = str(tsv_str, encoding='utf8') # <-- this line
    for row in tsv_str.split('\n'):
        kv = row.split('\t')
        if len(kv) == 2:
            rv[kv[0]] = kv[1]
    return rv

bsapiro avatar Jul 28 '13 00:07 bsapiro