mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
Add weakref support to sockets and re pattern objects.
This commit is contained in:
parent
cb87bc8e7e
commit
027bb633b6
7 changed files with 69 additions and 5 deletions
|
@ -9,6 +9,7 @@ import time
|
|||
import thread, threading
|
||||
import Queue
|
||||
import sys
|
||||
from weakref import proxy
|
||||
|
||||
PORT = 50007
|
||||
HOST = 'localhost'
|
||||
|
@ -191,6 +192,19 @@ class SocketConnectedTest(ThreadedTCPSocketTest):
|
|||
|
||||
class GeneralModuleTests(unittest.TestCase):
|
||||
|
||||
def test_weakref(self):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
p = proxy(s)
|
||||
self.assertEqual(p.fileno(), s.fileno())
|
||||
s.close()
|
||||
s = None
|
||||
try:
|
||||
p.fileno()
|
||||
except ReferenceError:
|
||||
pass
|
||||
else:
|
||||
self.fail('Socket proxy still exists')
|
||||
|
||||
def testSocketError(self):
|
||||
# Testing socket module exceptions
|
||||
def raise_error(*args, **kwargs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue