<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<STYLE><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></STYLE>
</HEAD>
<BODY class=hmmessage dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial'; COLOR: #000000">
<DIV>Yes, the unicode type in IronPython is is the same as string by
design,</DIV>
<DIV> </DIV>
<DIV>‘unicode == str’ will return True</DIV>
<DIV>
<DIV
style='FONT-SIZE: small; TEXT-DECORATION: none; FONT-FAMILY: "Calibri"; FONT-WEIGHT: normal; COLOR: #000000; FONT-STYLE: normal; DISPLAY: inline'><FONT
size=2 face=Arial></FONT></DIV>
<DIV style="FONT: 10pt tahoma">
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=fernandez_dan2@hotmail.com
href="mailto:fernandez_dan2@hotmail.com">Daniel Fernandez</A> </DIV>
<DIV><B>Sent:</B> Thursday, June 04, 2015 12:17 PM</DIV>
<DIV><B>To:</B> <A title=ironpython-users@python.org
href="mailto:ironpython-users@python.org">ironpython-users@python.org</A> </DIV>
<DIV><B>Subject:</B> [Ironpython-users] issue with chardtect.detect with unicode
type</DIV></DIV></DIV>
<DIV> </DIV></DIV>
<DIV
style='FONT-SIZE: small; TEXT-DECORATION: none; FONT-FAMILY: "Calibri"; FONT-WEIGHT: normal; COLOR: #000000; FONT-STYLE: normal; DISPLAY: inline'>
<DIV dir=ltr>Hi All,<BR> <BR>I'm playing with request but running into an
issue with chardet.detect call. <BR> <BR>def
detect(aBuf):<BR> if ((version_info < (3, 0) and
isinstance(aBuf, unicode))
or<BR>
(version_info >= (3, 0) and not isinstance(aBuf,
bytes))):<BR> raise
ValueError('Expected a bytes object, not a unicode
object')<BR> from . import
universaldetector<BR> u =
universaldetector.UniversalDetector()<BR>
u.reset()<BR> u.feed(aBuf)<BR>
u.close()<BR> return u.result<BR> <BR>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<BR> <BR>>>> v = 'value'<BR>>>>
isinstance(v,unicode)<BR>True<BR>>>>
isinstance(v,str)<BR>True<BR> <BR> <BR>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. <BR><BR>Thanks.<BR>
</DIV>
<P>
<HR>
_______________________________________________<BR>Ironpython-users mailing
list<BR>Ironpython-users@python.org<BR>https://mail.python.org/mailman/listinfo/ironpython-users<BR></DIV></DIV></DIV></BODY></HTML>