]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
On RH10, the PIE additions to gcc mean that id() can sometimes be a very
authorAnthony Baxter <anthonybaxter@gmail.com>
Thu, 6 Nov 2003 13:57:49 +0000 (13:57 +0000)
committerAnthony Baxter <anthonybaxter@gmail.com>
Thu, 6 Nov 2003 13:57:49 +0000 (13:57 +0000)
large 32 bit int, which comes out as a negative int. Workaround this to
prevent warnings from the test suite and the std lib.

Lib/asyncore.py
Lib/tarfile.py
Lib/xml/dom/minidom.py

index 7fb84b47fa8e5de62ce9910ee54bd3267d2dec24..fe69359def53d4044b9cc616f57fcd5ad8e9c48e 100644 (file)
@@ -227,7 +227,10 @@ class dispatcher:
                 status.append('%s:%d' % self.addr)
             except TypeError:
                 status.append(repr(self.addr))
-        return '<%s at %#x>' % (' '.join(status), id(self))
+        # On some systems (RH10) id() can be a negative number. 
+        # work around this.
+        MAX = 2L*sys.maxint+1
+        return '<%s at %#x>' % (' '.join(status), id(self)&MAX)
 
     def add_channel(self, map=None):
         #self.log_info('adding channel %s' % self)
index 26f9c7f6acff459cdbc16604bb8a10627f5db136..45fe03c043bf32afaac750df97e94d50c60a60c7 100644 (file)
@@ -649,7 +649,11 @@ class TarInfo(object):
         self.offset_data = 0       # the file's data starts here
 
     def __repr__(self):
-        return "<%s %r at %#x>" % (self.__class__.__name__,self.name,id(self))
+        # On some systems (RH10) id() can be a negative number. 
+        # work around this.
+        MAX = 2L*sys.maxint+1
+        return "<%s %r at %#x>" % (self.__class__.__name__,self.name,
+                                   id(self)&MAX)
 
     def frombuf(cls, buf):
         """Construct a TarInfo object from a 512 byte string buffer.
index a5ebe5f7e3a189dd336db0a07199801fe2bb597a..45e9c068d7c7ac68b9ea8dd7d5b3bdd7adae67a3 100644 (file)
@@ -14,6 +14,7 @@ Todo:
  * SAX 2 namespaces
 """
 
+import sys
 import xml.dom
 
 from xml.dom import EMPTY_NAMESPACE, EMPTY_PREFIX, XMLNS_NAMESPACE, domreg
@@ -794,7 +795,10 @@ class Element(Node):
             self, namespaceURI, localName, NodeList())
 
     def __repr__(self):
-        return "<DOM Element: %s at %#x>" % (self.tagName, id(self))
+        # On some systems (RH10) id() can be a negative number. 
+        # work around this.
+        MAX = 2L*sys.maxint+1
+        return "<DOM Element: %s at %#x>" % (self.tagName, id(self)&MAX)
 
     def writexml(self, writer, indent="", addindent="", newl=""):
         # indent = current indentation