Message342710
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
| Author | xtreak |
|---|---|
| Recipients | serhiy.storchaka, vstinner, xtreak |
| Date | 2019-05-17.11:36:30 |
| SpamBayes Score | -1.0 |
| Marked as misclassified | Yes |
| Message-id | <1558092990.73.0.202285685735.issue36918@roundup.psfhosted.org> |
| In-reply-to |
| Content | |
|---|---|
My analysis was that close was called on fakesocket which is internally closed when it's counter resets to zero and the destructor was trying to flush on a closed object during destructor call. Comment from https://bugs.python.org/issue18748#msg341106 The ValueError warnings in test_urllib noted in msg340059 feels like an issue with the test where FakeSocket calls close by itself once it's internal io_refs counter is 0 and during destructor again close is called on an already closed object causing the ValueError. * The test uses fakehttp() creating FakeSocket starting with io_refs as 1 [1] * During the test in urlopen, sock.makefile() (io_refs += 1) is called increasing the io_refs to be 2. * HTTPConnection.close calls sock.close (fakesocket.close) [3] calling io_refs -= 1 and to fakesocket.io_ref to be 1. * This test uses raises status 302 with http_error_302 which calls self.redirect_internal where self.close is again called causing fp.io_refs == 0 and subsequently calling io.BytesIO.close(self) to close the object. [4] * During the end of the test destructor is called on the above closed fakesocket object and trying to flush on a closed object causes the ValueError warnings . Maybe a check could be added during flush to make sure the object is not closed by testing for self.closed but I am not sure if closed attribute is guaranteed to be present. Removing the manual call to close in fakesocket could help since the destructor should be taking care of it and I could see no test failures or warnings removing the close as io_refs gets to 0. [1] https://github.com/python/cpython/blob/be6dbfb43b89989ccc83fbc4c5234f50f44c47ad/Lib/test/test_urllib.py#L61 [2] https://github.com/python/cpython/blob/be6dbfb43b89989ccc83fbc4c5234f50f44c47ad/Lib/test/test_urllib.py#L67 [3] https://github.com/python/cpython/blob/be6dbfb43b89989ccc83fbc4c5234f50f44c47ad/Lib/http/client.py#L919 [4] https://github.com/python/cpython/blob/be6dbfb43b89989ccc83fbc4c5234f50f44c47ad/Lib/urllib/request.py#L2145 |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2019-05-17 11:36:30 | xtreak | set | recipients: + xtreak, vstinner, serhiy.storchaka |
| 2019-05-17 11:36:30 | xtreak | set | messageid: <1558092990.73.0.202285685735.issue36918@roundup.psfhosted.org> |
| 2019-05-17 11:36:30 | xtreak | link | issue36918 messages |
| 2019-05-17 11:36:30 | xtreak | create | |