Commit dce391cb authored by Jeremy Hylton's avatar Jeremy Hylton

Remove __del__ methods to avoid creating uncollectable cyclic trash.

Keep close() methods for backwards compatibility.

Does any call close() explicitly?
parent 6485a87b
...@@ -170,12 +170,6 @@ class HTTPError(URLError, addinfourl): ...@@ -170,12 +170,6 @@ class HTTPError(URLError, addinfourl):
def __str__(self): def __str__(self):
return 'HTTP Error %s: %s' % (self.code, self.msg) return 'HTTP Error %s: %s' % (self.code, self.msg)
def __del__(self):
# XXX is this safe? what if user catches exception, then
# extracts fp and discards exception?
if self.fp:
self.fp.close()
class GopherError(URLError): class GopherError(URLError):
pass pass
...@@ -307,13 +301,9 @@ class OpenerDirector: ...@@ -307,13 +301,9 @@ class OpenerDirector:
bisect.insort(self.handlers, handler) bisect.insort(self.handlers, handler)
handler.add_parent(self) handler.add_parent(self)
def __del__(self):
self.close()
def close(self): def close(self):
for handler in self.handlers: # Only exists for backwards compatibility.
handler.close() pass
self.handlers = []
def _call_chain(self, chain, kind, meth_name, *args): def _call_chain(self, chain, kind, meth_name, *args):
# XXX raise an exception if no one else should try to handle # XXX raise an exception if no one else should try to handle
...@@ -436,7 +426,8 @@ class BaseHandler: ...@@ -436,7 +426,8 @@ class BaseHandler:
self.parent = parent self.parent = parent
def close(self): def close(self):
self.parent = None # Only exists for backwards compatibility
pass
def __lt__(self, other): def __lt__(self, other):
if not hasattr(other, "handler_order"): if not hasattr(other, "handler_order"):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment