Python Mechanize With Ntlm Getting Attributeerror: Httpresponse Instance Has No Attribute '__iter__'
I am trying to access a site that's secured with NTLM authentication using python-ntlm and mechanize but I am getting this error. File 'build/bdist.macosx-10.6-universal/egg/mechan
Solution 1:
I patched mechanize to work around this:
--- _response.py.old 2013-02-06 11:14:33.208385467 +0100
+++ _response.py 2013-02-06 11:21:41.884081708 +0100
@@ -350,8 +350,13 @@
self.fileno = self.fp.fileno
else:
self.fileno = lambda: None
- self.__iter__ = self.fp.__iter__
- self.next = self.fp.next
+
+ if hasattr(self.fp, "__iter__"):
+ self.__iter__ = self.fp.__iter__
+ self.next = self.fp.next
+ else:
+ self.__iter__ = lambda self: self
+ self.next = lambda self: self.fp.readline()
def __repr__(self):
return '<%s at %s whose fp = %r>' % (
Post a Comment for "Python Mechanize With Ntlm Getting Attributeerror: Httpresponse Instance Has No Attribute '__iter__'"