/usr/share/doc/python-jabber/patches/unused/JacobLundqvist/ustr_v0.3.1.diff is in python-jabber 0.5.0-1.6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | --- diffed/getSetList 2003-01-12 22:16:24.000000000 +0100
+++ jabber.py 2003-01-12 22:38:49.000000000 +0100
@@ -73,6 +73,9 @@
False = 0;
True = 1;
+USTR_ENCODING='iso-8859-1'
+
+
#
# JANA core namespaces
# from http://www.jabber.org/jana/namespaces.php as of 2003-01-12
@@ -163,6 +166,40 @@
#############################################################################
+def ustr(what, encoding=USTR_ENCODING):
+ """
+ If sending object is already a unicode str, just
+ return it, otherwise convert it using encoding
+ """
+ if type(what) == type(u''):
+ r = what
+ else:
+ r = what.__str__()
+ # make sure __str__() didnt return a unicode
+ if type(r) <> type(u''):
+ r = unicode(r,encoding,'replace')
+ return r
+
+
+def str(what):
+ """quick and dirty catchall for all the str() usage.
+
+ The code in this module should really be changed to call ustr()
+ instead of str() unless there is a good reason,
+ but remember all data on the wire are suposed to be unicode,
+ so this piece saves sloppy code ;)
+
+ str() usage generally tend to break things for everybody that
+ doesnt speek english - and we are quite a few on this planet...
+
+ If this is just to much to swallow, feel free to comment this out,
+ but please at least make sure that at least Client.send() uses ustr()
+ in that case
+ """
+ return ustr(what)
+
+
+
class Connection(xmlstream.Client):
"""Forms the base for both Client and Component Classes"""
def __init__(self, host, port, namespace,
@@ -480,7 +517,7 @@
def send(self, what):
"""Sends a jabber protocol element (Node) to the server"""
- xmlstream.Client.write(self,str(what))
+ xmlstream.Client.write(self,ustr(what))
def sendInitPresence(self):
|