Преглед на файлове

Encoding str from utf-8 before sending to socket

Jadjay преди 8 години
родител
ревизия
85a90e47db
променени са 1 файла, в които са добавени 7 реда и са изтрити 4 реда
  1. 7 4
      irclib.py

+ 7 - 4
irclib.py Целия файл

@@ -780,16 +780,19 @@ class ServerConnection(Connection):
780 780
         """Send raw string to the server.
781 781
 
782 782
         The string will be padded with appropriate CR LF.
783
+        From here everything need to be encoded in str from utf-8
783 784
         """
785
+        string=string.encode('utf-8')
786
+
784 787
         if self.socket is None:
785
-            raise ServerNotConnectedError, u'Not connected.'
788
+            raise ServerNotConnectedError, "Not connected."
786 789
         try:
787 790
             if self.ssl:
788
-                self.ssl.write(string + u'\r\n')
791
+                self.ssl.write(string + "\r\n")
789 792
             else:
790
-                self.socket.send(string + u'\r\n')
793
+                self.socket.send(string + "\r\n")
791 794
             if DEBUG:
792
-                print u'TO SERVER:', string
795
+                print "TO SERVER:", string
793 796
         except socket.error, x:
794 797
             # Ouch!
795 798
             self.disconnect(u'Connection reset by peer.')