[Ironpython-users] issue with chardtect.detect with unicode type
Daniel Fernandez
fernandez_dan2 at hotmail.com
Thu Jun 4 13:17:22 CEST 2015
Hi All,
I'm playing with request but running into an issue with chardet.detect call.
def detect(aBuf):
if ((version_info < (3, 0) and isinstance(aBuf, unicode)) or
(version_info >= (3, 0) and not isinstance(aBuf, bytes))):
raise ValueError('Expected a bytes object, not a unicode object')
from . import universaldetector
u = universaldetector.UniversalDetector()
u.reset()
u.feed(aBuf)
u.close()
return u.result
It always throws ValueError exception 'Expected a bytes object, not a unicode object'. The problem is the isinstance(aBuff,unicode) which returns True for IronPython and not CPython. I guess in IronPython strings are both a str and unicode types
>>> v = 'value'
>>> isinstance(v,unicode)
True
>>> isinstance(v,str)
True
I was wondering if this is expected behavior for IronPython? At the moment I just removed this check in my local copy so I get pass this issue with requests.
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20150604/2dfcac96/attachment.html>
More information about the Ironpython-users
mailing list