[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

Patch of x88.strl for newer Pythons


The behavior of str(longnum) seems to have changed between Python 1.5
(for which Pyxi was written) and Python 2.1.  The result is that, with
newer Pythons, the least significant digit is clipped from each
component of the string representation of an Address.  Pyxi fails
attempting to open the first document, since it requests the document
at '.....', which is of course nonesense.

This patch fixes the problem for newer Pythons, while trying to be
backward compatible.  I have not tested this with Python 1.5, though,
so be warned.


Aaron Bingham
--- x88.py.old	Thu Apr 10 15:18:00 2003
+++ x88.py	Thu Apr 10 15:19:54 2003
@@ -82,7 +82,10 @@
 # ----------------------------------------------------------------- Tumbler
 def strl(longnum):
     """Convert a long integer to a string without the trailing L."""
-    return str(longnum)[:-1]
+    strval = str(longnum)
+    if strval[-1] not in string.digits:
+        return strval[:-1]
+    return strval
 class Tumbler:
     """A numbering system that permits addressing within documents