My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 85: "UnicodeDecodeError: 'utf8' codec can't decode bytes in position [...]" on logon
  Back to list
Status:  Fixed
Owner:  jadest...@gmail.com
Closed:  Jan 2008


 
Reported by jadest...@gmail.com, Dec 15, 2007
 Posted by guest at 2007-07-27 11:08:44

Hello everyone,

I use the newest svn-checkout of pyicq-t (but this happens also with version
0.8a and 0.8). 

When I try to connect my ICQ-account through the transport I instantly get the
following output on the command-line:

Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/twisted/python/log.py", line
53, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/lib/python2.4/site-packages/twisted/python/log.py", line
38, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/lib/python2.4/site-packages/twisted/python/context.py",
line 59, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/lib/python2.4/site-packages/twisted/python/context.py",
line 37, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File
"/usr/lib/python2.4/site-packages/twisted/internet/pollreactor.py",
line 164, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/lib/python2.4/site-packages/twisted/internet/tcp.py",
line 348, in doRead
    return self.protocol.dataReceived(data)
  File "/usr/lib/python2.4/site-packages/pyicq-t/src/tlib/oscar.py",
line 647, in dataReceived
    state=func(flap)
  File "/usr/lib/python2.4/site-packages/pyicq-t/src/tlib/oscar.py",
line 764, in oscar_Data
    func(snac)
  File "/usr/lib/python2.4/site-packages/pyicq-t/src/tlib/oscar.py",
line 1222, in oscar_03_0B
    self.updateBuddy(self.parseUser(snac[5]))
  File "/usr/lib/python2.4/site-packages/pyicq-t/src/legacy/icqt.py",
line 179, in updateBuddy
    status = status.encode("utf-8", "replace")
exceptions.UnicodeDecodeError: 'utf8' codec can't decode bytes in position
117-118: invalid data
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/twisted/python/log.py", line
53, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/lib/python2.4/site-packages/twisted/python/log.py", line
38, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/lib/python2.4/site-packages/twisted/python/context.py",
line 59, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/lib/python2.4/site-packages/twisted/python/context.py",
line 37, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File
"/usr/lib/python2.4/site-packages/twisted/internet/pollreactor.py",
line 164, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/lib/python2.4/site-packages/twisted/internet/tcp.py",
line 348, in doRead
    return self.protocol.dataReceived(data)
  File "/usr/lib/python2.4/site-packages/pyicq-t/src/tlib/oscar.py",
line 647, in dataReceived
    state=func(flap)
  File "/usr/lib/python2.4/site-packages/pyicq-t/src/tlib/oscar.py",
line 764, in oscar_Data
    func(snac)
  File "/usr/lib/python2.4/site-packages/pyicq-t/src/tlib/oscar.py",
line 1222, in oscar_03_0B
    self.updateBuddy(self.parseUser(snac[5]))
  File "/usr/lib/python2.4/site-packages/pyicq-t/src/legacy/icqt.py",
line 179, in updateBuddy
    status = status.encode("utf-8", "replace")
exceptions.UnicodeDecodeError: 'utf8' codec can't decode bytes in position
117-118: invalid data

I hope you are able to get enough information out of this to fix the bug as
I am
not able to produce more output - as I said: It happens directly when I
login to
the transport. :(

Thanks in advance

Posted by Funzi at 2007-08-04 22:00:52

Hi... I had the same (or a very similar problem) with my pyicq-t. The following
(dirty) patch (dumped via svn) fixed it for now... I don't give a warranty, but
hey - it works ;-)

Index: src/legacy/icqt.py
===================================================================
--- src/legacy/icqt.py  (revision 228)
+++ src/legacy/icqt.py  (working copy)
@@ -176,7 +176,10 @@

                if user.caps:
                        self.oscarcon.legacyList.setCapabilities(user.name,
user.caps)
-               status = status.encode("utf-8", "replace")
+               try:
+                       status = status.encode("utf-8",
"replace")
+               except UnicodeError:
+                       pass
                if user.flags.count("away"):
                       
self.getAway(user.name).addCallback(self.sendAwayPresence, user)
                else:
@@ -326,7 +329,10 @@
                                        charset = config.encoding
                                        status = msg[0] + ": " +
status

-                       status = status.decode(charset, 'replace')
+                       try:
+                               status = status.decode(charset, 'replace')
+                       except UnicodeError:
+                               pass
                        LogEvent(INFO, self.session.jabberID, "Away (%s,
%s) message %s" % (charset, msg[0], status))

                if status == "Away" or status=="I am currently
away from the computer." or status=="I am away from my computer right
now.":

Posted by guest at 2007-08-07 07:14:21

or you could replace the line 179 with
status = unicode(status, errors='replace')

Posted by guest at 2007-08-08 12:27:49

Thank you two :)

I already thought about the first solution by myself but didn't liked it very
much either :(

So the second solution is the way to go. If you replace line 77 with
userinfo[i] = unicode(userinfo[i], errors='replace')
you will have no more problems with invalid encoded characters in users
informations, too.

I hope these changes will be included in pyicq-t soon :)

Posted by maxbritov at 2007-08-08 17:48:06

pyicqt unmaintained atm.
and you may look another patchset from bug 316.

Posted by guest at 2007-08-16 13:36:35

I have tried a lot of patches cca from bug 299 and up (including russian
patchsets) .. and still not working, because of problems with decoding :(

is here anybody with fully functional pyicq-t without errors? Can help by
writing what version install and what patches use? :) 

thanks

Posted by maxbritov at 2007-08-20 08:07:05

Here pyicq 0.8a (==pyicqt AFAIK)  and it works fine for ~10 users (corporate).
I have twisted 2.5.0 + latest words/web  and i removed twistfix from main.py +
latest patch from #316.
Please describe your problems (with both #316 patchsets applied) with context
debug output. I wont support pyicq, but we may look some.

Posted by guest at 2007-11-09 04:01:19

grmpf .. that happens if you are too lazy 2 read comments.
i did research for the last 2h on python thow catch :)
came up with the same solution as above except i didnt pass but set the status
message to notify me about the incorrect string :)

also i killed the lines after 301 now knowing why i never saw those nice
standard away messages ^^

hope pyicqt will be fixed sometime. 


Jan 12, 2008
Project Member #1 volk...@gmail.com
This may be fixed by the latest "don't crash on weird encoding" patches.
Status: Fixed

Powered by Google Project Hosting