Commit Graph

93 Commits

Author SHA1 Message Date
Neal Norwitz 9b0ca79213 Patch #1519025 and bug #926423: If a KeyboardInterrupt occurs during
a socket operation on a socket with a timeout, the exception will be
caught correctly.  Previously, the exception was not caught.
2006-08-02 06:46:21 +00:00
Martin v. Löwis 7596e8342e Release all forwarded functions in .close. Fixes #1513223. 2006-07-01 15:33:37 +00:00
Neal Norwitz 9602cc2aa4 Prevent spurious leaks when running regrtest.py -R. There may be more
issues that crop up from time to time, but this change seems to have been
pretty stable (no spurious warnings) for about a week.

Other modules which use threads may require similar use of
threading_setup/threading_cleanup from test_support.
2006-06-18 19:35:01 +00:00
Neal Norwitz 909eb12c95 Fix the socket tests so they can be run concurrently. Backport candidate 2006-06-12 02:13:21 +00:00
Neal Norwitz 4a9ff1626a Get test to pass on S/390. Shout if you think this change is incorrect. 2006-06-11 21:38:38 +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
Armin Rigo a9017c39ce SF Patch #1062014: AF_UNIX sockets under Linux have a special
abstract namespace that is now fully supported.
2006-04-19 11:50:27 +00:00
Anthony Baxter cf0a2a8576 Deal with openbsd's different style of default /etc/hosts by forcing the fqdn
lookup to use the IP address returned by gethosbyname.
2006-04-03 08:10:33 +00:00
Martin v. Löwis 04855cc100 Fix typo. 2006-03-26 16:40:47 +00:00
Martin v. Löwis c667d052e5 Provide more debug output, to diagnose OpenBSD test failures. 2006-03-26 09:50:11 +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
Georg Brandl d2e3ba7a35 patch [ 756021 ] Allow socket.inet_aton("255.255.255.255") on Windows 2005-08-26 08:34:00 +00:00
Hye-Shik Chang 4e422817eb Add support for FreeBSD 7. 2005-07-17 02:36:59 +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
Brett Cannon 08febebf96 Add 'linux2' as one of the platforms that does not use the echo service as one
of the test possiblities for testGetServBy().
2004-11-20 21:10:07 +00:00
Hye-Shik Chang f64700a512 Add support for FreeBSD 6. 2004-08-18 15:13:41 +00:00
Skip Montanaro d4ff206906 Being bsd-based, darwin/macosx has the same limitation w.r.t. the "echo"
service.
2004-08-16 15:35:54 +00:00
Tim Peters 494aaee902 Whitespace normalization. 2004-08-09 18:54:11 +00:00
Dave Cole 331708b226 Patch #1003700: Add socketpair function to socket module. 2004-08-09 04:51:41 +00:00
Andrew MacIntyre 18bf43c4a4 FreeBSD's services file contains an additional echo service entry, with
a non-standard protocol and on a lower port than the tcp/udp entries,
which breaks the assumption that there will only be one service by a
given name on a given port when no protocol is specified.

Previous versions of this code have had other problems as a result of
different service definitions amongst common platforms.  As this platform
has an extra, unexpected, service entry, I've special cased the platform
rather than re-order the list of services checked to highlight the pitfall.
2004-07-12 12:10:30 +00:00
Barry Warsaw 7ff7d2cb0b testGetServBy(): Use services that should be available both on *nix and
Windows (XP at least ;).  Test in this order: echo, daytime, domain.
2004-07-06 16:48:25 +00:00
Barry Warsaw 11b91a0ea3 Added socket.getservbyport(), and make its second argument and that of
getservbyname() optional.  Update the tests and the docs.
2004-06-28 00:50:43 +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
Skip Montanaro 05eb40128e Fix indentation error in testGetServByName and rewrite loop to avoid clumsy
sentinel variable
2004-02-10 15:51:15 +00:00
Raymond Hettinger 11a35f545b SF patch #760257: add socket.timeout exception
(Contributed by Bob Halley)

Add unittests for the new socket.timeout exception.
2003-06-29 04:40:22 +00:00
Tim Peters c2659cff5d Whitespace normalization. 2003-05-12 20:19:37 +00:00
Walter Dörwald 21d3a32b99 Combine the functionality of test_support.run_unittest()
and test_support.run_classtests() into run_unittest()
and use it wherever possible.

Also don't use "from test.test_support import ...", but
"from test import test_support" in a few spots.

From SF patch #662807.
2003-05-01 17:45:56 +00:00
Guido van Rossum f4001eed3b Skip testing inet_ntop() an inet_pton() if they aren't defined.
This makes the test pass on Windows again (and on other platforms
that don't have these).
2003-04-25 15:11:23 +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
Guido van Rossum 9647b5240c Also skip testHostnameRes() if gethostbyaddr() raises an exception. 2002-12-26 17:04:45 +00:00
Guido van Rossum 71e02946ff Skip testHostnameRes() if gethostbyname() raises an exception. 2002-12-26 16:55:15 +00:00
Guido van Rossum c0a0e0810b Since it tests both ntohl and ntohs, the test should not be called
testNtoHL but testNtoH.
2002-09-16 01:30:03 +00:00
Guido van Rossum a2627afe37 Maybe this fixes test_socket on 64-bit Linux. 2002-09-14 00:58:46 +00:00
Jack Jansen 522e7694ed Skip UDP testing for MacPython (for now), it hangs. This may be due to
GUSI/Threading interaction, I'm not sure, but I don't have the time to fix this right now.
2002-09-06 21:57:50 +00:00
Guido van Rossum 558fc977c5 Don't use hex constants representing negative numbers. 2002-08-12 22:01:24 +00:00
Guido van Rossum e531e296fa testSendAll(): loop until all data is read; this was necessary at
least on OS/2 (see note on SF patch 555085 by A I MacIntyre) but
looks like the test *could* fail on any other platform too -- there's
no guarantee that recv() reads all data.
2002-08-08 20:28:34 +00:00
Tim Peters 469cdad822 Whitespace normalization. 2002-08-08 20:19:19 +00:00
Guido van Rossum 8c94383fa8 Replace docstrings on test functions witrh comments -- then unittest
prints function and module names, which is more informative now that
we repeat some tests in slightly modified subclasses.

Add a test for read() until EOF.

Add test suites for line-buffered (bufsize==1) and a small custom
buffer size (bufsize==2).

Restructure testUnbufferedRead() somewhat to avoid a potentially
infinite loop.
2002-08-08 01:00:28 +00:00
Guido van Rossum 10e3f411b0 Tighten the unbuffered readline test to distinguish between the two lines. 2002-08-07 19:02:49 +00:00
Guido van Rossum 29bf9157ec Oops. I accidentally commented out some tests. 2002-08-07 16:03:06 +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
Skip Montanaro f4433303a8 testGetServByName shouldn't check for getservbyname - the socket module
should always have it.
2002-08-02 15:52:30 +00:00
Skip Montanaro d3c884d4ea modify testGetServByName so it tries a few different protocols. In this day
and age of rampant computer breakins I imagine there are plenty of systems
with telnet disabled.  Successful check of at least one getservbyname() call
is required for success
2002-08-02 02:19:46 +00:00
Guido van Rossum b995eb79a0 Enable test_socket again, if only to prevent mistakes like Jeremy
thinking that he was running his new test by running "make test".
Also, I can't get this to fail any more.  Your turn. :-)
2002-07-31 16:08:40 +00:00
Jeremy Hylton cbd5b89571 Repair testNtoH for large long arguments.
If the long is large enough, the return value will be a negative int.
In this case, calling the function a second time won't return the
original value passed in.
2002-07-31 15:57:39 +00:00
Jeremy Hylton c075e197d6 Extended socket.htonl and ntohl to accept longs.
Fixes SF bug #568322.

The code should raise an OverflowError if the long is > 32 bits, even
on platforms where sizeof(long) > 4.
2002-07-25 16:01:12 +00:00
Jeremy Hylton b8a690d42a Remove test that was none too picky about whether attributes exist. 2002-07-25 15:37:23 +00:00