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.

classification
Title: socket._fileobject._getclosed() returns wrong value
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: tim.peters Nosy List: gigamorph, tim.peters
Priority: normal Keywords:

Created on 2004-03-26 22:03 by gigamorph, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg20326 - (view) Author: June Kim (gigamorph) Date: 2004-03-26 22:03
In socket.py, _getclosed() is defined as follows:

  class _fileobject(object)
      # ...
      def _getclosed(self):
          return self._sock is not None

Which causes the following interaction:
  >>> import socket
  >>> s = socket.socket()
  >>> f = s.makefile()
  >>> f.closed
  True
  >>> f.close()
  >>> f.closed
  False

Shouldn't the values of f.closed the opposite of the above?



msg20327 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-03-28 02:05
Logged In: YES 
user_id=31435

Why did you change the status from Open to Deleted?  
Changed back to Open.
msg20328 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-03-28 02:33
Logged In: YES 
user_id=31435

I agree the .closed property always returned the wrong result.
Fixed, in

lib/socket.py; new revision: 1.43
lib/test/test_socket.py; new revision: 1.68
History
Date User Action Args
2022-04-11 14:56:03adminsetgithub: 40087
2004-03-26 22:03:11gigamorphcreate