HTTPretty icon indicating copy to clipboard operation
HTTPretty copied to clipboard

Infinite recursion with python 3.4.2

Open kouk opened this issue 9 years ago • 2 comments

Due to this python issue (20386) there is the possibility of an infinite recursion when calling socket.__repr__ in python 3.4.2. HTTPretty patches socket.SocketType, which it assumes is the actual class of the socket, like in Python 2.7. In Python 3.4.2 they inadvertently made it an Enum with all the different socket types. The problem is they use this Enum in the socket's __repr__ to output the socket's type, but since HTTPretty has substituted the fake socket class for the enum the result is a new socket object is created. And when it's __repr__ method is called the same things happen again and again and again. This isn't a bug in HTTPretty, and by the end of the month it will have been fixed with Python 3.4.3, but I thought I would mention it here because it wasted half my day and if someone else had written about it I would probably have spent it more productively.

kouk avatar Feb 20 '15 19:02 kouk

Just a heads up that there is a proposed solution for this in https://github.com/gabrielfalcao/HTTPretty/pull/193

spulec avatar Feb 20 '15 21:02 spulec

I was hit by this two days ago, it was a nightmare to debug : http://stackoverflow.com/questions/29590459/http-request-with-python-typeerror-an-integer-is-required-got-type-socket

agateblue avatar Apr 13 '15 10:04 agateblue