Commits

Anonymous committed c8a6f9b

Fixed irccat.py and irccat2.py scripts

The example scripts irccat.py and irrcat2.py use sys.stdin.readline() to
get their input. However, sys.stdin.readline() also captures the carriage
return chracter when the Enter key is pressed when using the script
interactively with a command line. It also does this when feeding stdin
with a pipe from cat, or using a redirect from a file. Both scripts then
choke on these CR characters, and abort with a ValueError exception.

Changing sys.stdin.readline() to sys.stdin.readline().strip() fixes
this.

  • Participants
  • Parent commits 5bb4072

Comments (0)

Files changed (2)

scripts/irccat.py

         connection.join(target)
     else:
         while 1:
-            line = sys.stdin.readline()
+            line = sys.stdin.readline().strip()
             if not line:
                 break
             connection.privmsg(target, line)
 
 def on_join(connection, event):
     while 1:
-        line = sys.stdin.readline()
+        line = sys.stdin.readline().strip()
         if not line:
             break
         connection.privmsg(target, line)

scripts/irccat2.py

 
     def send_it(self):
         while 1:
-            line = sys.stdin.readline()
+            line = sys.stdin.readline().strip()
             if not line:
                 break
             self.connection.privmsg(self.target, line)