Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv644/spambayes

Modified Files:
        Dibbler.py 
Log Message:
rstrip(chars) isn't available pre 2.2.2, and we say we support 2.2, so add a 
function to
 do the work if rstrip(chars) isn't available.

This addresses the concern at http://entrian.com/sbwiki/Python22Compatibility

Index: Dibbler.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/Dibbler.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** Dibbler.py  6 Dec 2004 01:37:43 -0000       1.15
--- Dibbler.py  22 Dec 2004 03:32:19 -0000      1.16
***************
*** 179,182 ****
--- 179,191 ----
      True, False = 1, 0
  
+ try:
+     "".rstrip("abc")
+ except TypeError:
+     # rstrip(chars) requires Python 2.2.2 or higher.  Apart from that
+     # we probably work with Python 2.2 (and say we do), so provide the
+     # ability to do this for that case.
+     RSTRIP_CHARS_AVAILABLE = False
+ else:
+     RSTRIP_CHARS_AVAILABLE = True
  
  class BrighterAsyncChat(asynchat.async_chat):
***************
*** 594,598 ****
          minutes from now."""
          timeString = time.asctime(time.localtime(time.time() + 20*60))
!         return base64.encodestring(timeString).rstrip('\n=')
  
      def _isValidNonce(self, nonce):
--- 603,618 ----
          minutes from now."""
          timeString = time.asctime(time.localtime(time.time() + 20*60))
!         if RSTRIP_CHARS_AVAILABLE:
!             return base64.encodestring(timeString).rstrip('\n=')
!         else:
!             # Python pre 2.2.2, so can't do a rstrip(chars).  Do it
!             # manually instead.
!             def rstrip(s, chars):
!                 if not s:
!                     return s
!                 if s[-1] in chars:
!                     return rstrip(s[:-1])
!                 return s
!             return rstrip(base64.encodestring(timeString), '\n=')
  
      def _isValidNonce(self, nonce):

_______________________________________________
Spambayes-checkins mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/spambayes-checkins

Reply via email to