>>> from mechanize import History If nothing has been added, .close should work. >>> history = History() >>> history.close() Under some circumstances response can be None, in that case this method should not raise an exception. >>> history.add(None, None) >>> history.close()