Pastebin

Paste #1555: python traceback

< previous paste - next paste>

Pasted by chrivers

Download View as text

#!/usr/bin/python
#encoding=utf-8

class test(object):

    x = u"filename.dat"

    def __str__(self):
        print "str"
        return str(self.x)

    def __unicode__(self):
        print "unicode"
        return unicode(self.x)

t = test()

import os
os.stat(t)

------------------
Traceback (most recent call last):                                                                                                                                                                                                           
  File "test.py", line 19, in <module>                                                                                                                                                                                                       
    os.stat(t)                                                                                                                                                                                                                               
TypeError: coercing to Unicode: need string or buffer, test found                                                                                                                                                                            

New Paste


Do not write anything in this field if you're a human.

Go to most recent paste.