Browse Source

Replace id(...) calls with _get_idstr(...) calls to avoid future warnings

when id() returns a "negative" number.
main
Rich Salz 20 years ago
parent
commit
14b44b7e8e
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      Utility.py

+ 12
- 1
Utility.py View File

@@ -23,6 +23,17 @@ from TimeoutSocket import TimeoutSocket, TimeoutError
from urlparse import urlparse from urlparse import urlparse
from httplib import HTTPConnection, HTTPSConnection from httplib import HTTPConnection, HTTPSConnection
from exceptions import Exception from exceptions import Exception
try:
from ZSI import _get_idstr
except:
def _get_idstr(pyobj):
'''Python 2.3.x generates a FutureWarning for negative IDs, so
we use a different prefix character to ensure uniqueness, and
call abs() to avoid the warning.'''
x = id(pyobj)
if x < 0:
return 'x%x' % abs(x)
return 'o%x' % x


import xml.dom.minidom import xml.dom.minidom
from xml.dom import Node from xml.dom import Node
@@ -90,7 +101,7 @@ class DOMException(Exception):
class Base: class Base:
"""Base class for instance level Logging""" """Base class for instance level Logging"""
def __init__(self, module=__name__): def __init__(self, module=__name__):
self.logger = logging.getLogger('%s-%s(%x)' %(module, self.__class__, id(self)))
self.logger = logging.getLogger('%s-%s(%x)' %(module, self.__class__, get_idstr(self)))




class HTTPResponse: class HTTPResponse:


Loading…
Cancel
Save