Commit Graph

56 Commits

Author SHA1 Message Date
Martin v. Löwis 0af338859b Bug #978833: Revert r50844, as it broke _socketobject.dup.
Will backport.
2007-03-23 13:27:15 +00:00
Georg Brandl dd7b0525e9 Patch #1627441: close sockets properly in urllib2. 2007-01-21 10:35:10 +00:00
Martin v. Löwis 9298eff5f9 Bug #978833: Really close underlying socket in _socketobject.close.
Fix httplib.HTTPConnection.getresponse to not close the
socket if it is still needed for the response.
2006-07-26 12:12:56 +00:00
Martin v. Löwis 7596e8342e Release all forwarded functions in .close. Fixes #1513223. 2006-07-01 15:33:37 +00:00
Martin Blais af2ae72cb2 Fixes in struct and socket from merge reviews.
- Following Guido's comments, renamed

  * pack_to -> pack_into
  * recv_buf -> recv_into
  * recvfrom_buf -> recvfrom_into

- Made fixes to _struct.c according to Neal Norwitz comments on the checkins
  list.

- Converted some ints into the appropriate -- I hope -- ssize_t and size_t.
2006-06-04 13:49:49 +00:00
Martin Blais 2856e5f390 Support for buffer protocol for socket and struct.
* Added socket.recv_buf() and socket.recvfrom_buf() methods, that use the buffer
  protocol (send and sendto already did).

* Added struct.pack_to(), that is the corresponding buffer compatible method to
  unpack_from().

* Fixed minor typos in arraymodule.
2006-05-26 12:03:27 +00:00
Georg Brandl a50794b620 Patch #1466993: remove wrong comment in socket.py 2006-04-09 14:28:13 +00:00
Tim Peters 0ae07bdb59 Whitespace normalization. 2006-03-22 03:23:21 +00:00
Georg Brandl bb03ac0dae Correct API design mistake from rev. 43126: make socket attributes readonly properties. 2006-03-21 18:17:25 +00:00
Georg Brandl bc45a3f821 RFE #567972: Socket objects' family, type and proto properties are
now exposed via new get...() methods.
2006-03-17 19:17:34 +00:00
Brett Cannon 01668a1ab9 Fix test for socket.getfqdn() to also include the name returned by
socket.gethostname() in the check for a valid return.

Also clarified docs (official and docstring) that the value from gethostname()
is returned if gethostbyaddr() doesn't do the job.
2005-03-11 00:04:17 +00:00
Dave Cole 331708b226 Patch #1003700: Add socketpair function to socket module. 2004-08-09 04:51:41 +00:00
Raymond Hettinger 027bb633b6 Add weakref support to sockets and re pattern objects. 2004-05-31 03:09:25 +00:00
Tim Peters 116d83ce71 SF bug 924242: socket._fileobject._getclosed() returns wrong value
The .closed property always returned the wrong result.

Bugfix candidate!
2004-03-28 02:20:45 +00:00
Martin v. Löwis 1867f24416 Always unwrap _socketobj in socket.ssl. Revert httplib.py 1.25.
Fixes #754447.
2003-06-14 13:30:53 +00:00
Guido van Rossum 65f8cedd4a I saw errors from _fileobject.__del__ about missing self._sock. This
can happen if __init__ doesn't complete.  Fix it by adding a
try/except to __del__.
2003-05-29 14:36:57 +00:00
Martin v. Löwis a94568a753 Patch #734231: Update RiscOS support. In particular, correct
riscospath.extsep, and use os.extsep throughout.
2003-05-10 07:36:56 +00:00
Fred Drake 70d566be10 Extract the errno value to use from the errno module if possible. 2003-04-29 19:50:25 +00:00
Skip Montanaro c689918c94 Regain throughput lost with the _socketobject wrapper. The
throughput-sensitive methods are grabbed from the underlying _socket.socket
object.  Closes SF patch 729293.
2003-04-29 19:27:26 +00:00
Guido van Rossum 47dfa4a89a Patch by Jp Calderone:
- The socket module now provides the functions inet_pton and inet_ntop
  for converting between string and packed representation of IP addresses.
  See SF patch #658327.

This still needs a bit of work in the doc area, because it is not
available on all platforms (especially not on Windows).
2003-04-25 05:48:32 +00:00
Skip Montanaro 89feabc7f5 The socket module now always uses the _socketobject wrapper class, even on
platforms which have dup(2).  The makefile() method is built directly on top
of the socket without duplicating the file descriptor, allowing timeouts to
work properly.  Includes a new test case (urllibnet) which requires the
network resource.

Closes bug 707074.
2003-03-30 04:54:24 +00:00
Guido van Rossum dbfb12148d On Windows, make sure SocketType is the same as socket. (SF bug
598097)
2002-08-22 17:31:16 +00:00
Tim Peters d7e8a0dd37 Delete junk attributes left behind by _socketobject class construction. 2002-08-08 20:07:03 +00:00
Guido van Rossum 715f970969 The _socketobject class has no need for a __del__ method: all it did was
to delete the reference to self._sock, and the regular destructor will
do that just fine.  This made some hacks in close() unnecessary.

The _fileobject class still has a __del__ method, because it must flush.
2002-08-08 18:11:36 +00:00
Guido van Rossum 48b7969af8 OK, one more hack: speed up the case of readline() in unbuffered mode.
This is important IMO because httplib reads the headers this way.
2002-08-08 17:34:19 +00:00
Guido van Rossum fb3deec2fc Another refactoring of read() and readline(), this time based on the
observation that _rbuf could never have more than one string in it.
So make _rbuf a string.  The code branches for size<0 and size>=0
are completely separate now, both in read() and in readline().

I checked for tabs this time. :-)
2002-08-08 17:16:09 +00:00
Guido van Rossum de7cadec54 Extend __all__ with the exports list of the _ssl module. 2002-08-08 15:25:28 +00:00
Guido van Rossum 7c3b6347e5 Oops, stupid tabs. Sorry again. 2002-08-08 15:22:12 +00:00
Guido van Rossum c18993f84a Another refactoring. Changed 'socket' from being a factory function
to being a new-style class, to be more similar to the socket class
in the _socket module; it is now the same as the _socketobject class.
Added __slots__.  Added docstrings, copied from the real socket class
where possible.

The _fileobject class is now also a new-style class with __slots__
(though without docstrings).  The mode, name, softspace, bufsize and
closed attributes are properly supported (closed as a property; name
as a class attributes; the softspace, mode and bufsize as slots).
2002-08-08 15:16:20 +00:00
Guido van Rossum 443fec3dd9 Major restructuring of _fileobject. Hopefully several things now work
correctly (the test at least succeed, but they don't test everything yet).

Also fix a performance problem in read(-1): in unbuffered mode, this would
read 1 byte at a time.  Since we're reading until EOF, that doesn't make
sense.  Use the default buffer size if _rbufsize is <= 1.
2002-08-08 01:02:16 +00:00
Guido van Rossum 9ed5ae7331 Replace tabs with spaces. (Sorry!) 2002-08-07 19:03:35 +00:00
Guido van Rossum e9f6614ea3 "Unbuffered" mode of class _fileobject wasn't actually unbuffered,
and this broke a Zope "pipelining" test which read multiple responses
from the same connection (this attaches a new file object to the
socket for each response).  Added a test for this too.

(I want to do some code cleanup too, but I thought I'd first fix
the problem with as little code as possible, and add a unit test
for this case.  So that's what this checkin is about.)
2002-08-07 15:46:19 +00:00
Tim Peters 6be147541a Restore a full arglist to the socket wrapper, so it supports keyword
arguments correctly too.
2002-07-31 17:48:02 +00:00
Tim Peters 8c3fb874ae For platforms (like Windows) that wrap _socket.socket:
+ Don't change the arglist requirements.
+ Give the wrapper the same docstring as _socket.socket (it didn't
  have any docstring).
2002-07-31 17:32:11 +00:00
Guido van Rossum 9d0c8cee66 Add default timeout functionality. This adds setdefaulttimeout() and
getdefaulttimeout() functions to the socket and _socket modules, and
appropriate tests.
2002-07-18 17:08:35 +00:00
Neal Norwitz 2b34290055 Cleanup a little 2002-06-13 22:18:39 +00:00
Guido van Rossum 67f7a38849 SF patch 555085 (timeout socket implementation) by Michael Gilfix.
I've made considerable changes to Michael's code, specifically to use
the select() system call directly and to store the timeout as a C
double instead of a Python object; internally, -1.0 (or anything
negative) represents the None from the API.

I'm not 100% sure that all corner cases are covered correctly, so
please keep an eye on this.  Next I'm going to try it Windows before
Tim complains.

No way is this a bugfix candidate. :-)
2002-06-06 21:08:16 +00:00
Tim Peters 18e6778bcd Repair so that importing socket doesn't blow up on platforms that lack
SSL support.  test_socket.py passes again on Windows.

Added an XXX about adding _ssl exports to the __all__ list (it doesn't
appear to be doing anything about that now, but since I don't have SSL
on this box I can't really tell).
2002-02-17 04:25:24 +00:00
Martin v. Löwis e12454f44a The Grande 'sendall()' patch, copied from release21-maint. Fixes #516715.
Replaces calls to socket.send() (which isn't guaranteed to send all data)
with the new socket.sendall() method.
2002-02-16 23:06:19 +00:00
Marc-André Lemburg a5d2b4cb18 Break SSL support out of _socket module and place it into a new
helper module _ssl.

The support for the RAND_* APIs in _ssl is now only enabled
for OpenSSL 0.9.5 and up since they were added in that
release.

Note that socketmodule.* should really be renamed to _socket.* --
unfortunately, this seems to lose the CVS history of the file.

Please review and test... I was only able to test the header file
chaos in socketmodule.c/h on Linux. The test run through fine
and compiles don't give errors or warnings.

WARNING: This patch does *not* include changes to the various
non-Unix build process files.
2002-02-16 18:23:30 +00:00
Guido van Rossum 99d2fbb823 Move the helper class _closedsocket *into* the _socketobject class.
This way, when a socket object is deleted after the socket module has
already been zapped by module shutdown, we don't get annoying warnings
about exceptions in __del__ methods.
2001-12-18 22:22:25 +00:00
Guido van Rossum b2c763fed2 Add 'sendall' to list of socket methods. 2001-10-29 07:13:53 +00:00
Guido van Rossum e2ae77b8b8 SF patch #474590 -- RISC OS support 2001-10-24 20:42:55 +00:00
Guido van Rossum 112ea6bfa6 Inspired by Greg Stein's proposed simplification of the _closesocket
class, I came up with an even simpler solution: raise the error in
__getattr__().
2001-08-18 21:00:39 +00:00
Guido van Rossum e5e50591a4 When the socket is closed, don't just assign 0 to self._sock.
This breaks software that excepts a socket.error but not an
AttributeError.
2001-08-18 01:23:20 +00:00
Tim Peters a19a168ccc Whitespace normalization. 2001-03-29 04:36:09 +00:00
Guido van Rossum 3f69f21644 Add a wrapper function for ssl() on Windows. Inspired by SF patch
# 409287, ssl fix when using _socketobject, by Robin Dunn.

I took the opportunity to improve the way it deals with reload(socket)
for the socket function as well.
2001-03-22 22:12:17 +00:00
Skip Montanaro 64de1a4b08 add errorTab to __all__ on win*
closes bug #406642
2001-03-18 19:53:21 +00:00
Guido van Rossum d74fb6b12a RISCOS changes by dschwertberger. 2001-03-02 06:43:49 +00:00
Skip Montanaro 0de65807e6 bunch more __all__ lists
also modified check_all function to suppress all warnings since they aren't
relevant to what this test is doing (allows quiet checking of regsub, for
instance)
2001-02-15 22:15:14 +00:00