File tree Expand file tree Collapse file tree 2 files changed +2
-38
lines changed Expand file tree Collapse file tree 2 files changed +2
-38
lines changed Original file line number Diff line number Diff line change 7
7
8
8
from codeop import compile_command , PyCF_DONT_IMPLY_DEDENT
9
9
import io
10
- import weakref
11
10
12
11
if is_jython :
13
12
import sys
@@ -295,22 +294,6 @@ def test_filename(self):
295
294
self .assertNotEqual (compile_command ("a = 1\n " , "abc" ).co_filename ,
296
295
compile ("a = 1\n " , "def" , 'single' ).co_filename )
297
296
298
- def test_invalid_doesnt_keep_user_object_alive (self ):
299
- '''succeed iff str is the start of an invalid piece of code'''
300
- class A : pass
301
- obj_wr = None
302
-
303
- def x ():
304
- nonlocal obj_wr
305
- obj = A ()
306
- obj_wr = weakref .ref (obj )
307
- try :
308
- compile_command ("invalid syntax =" )
309
- except SyntaxError :
310
- pass
311
- x ()
312
- assert obj_wr () is None
313
-
314
297
315
298
if __name__ == "__main__" :
316
299
unittest .main ()
Original file line number Diff line number Diff line change 15
15
import platform
16
16
import array
17
17
import contextlib
18
- import weakref
18
+ from weakref import proxy
19
19
import signal
20
20
import math
21
21
import pickle
@@ -850,7 +850,7 @@ def test_csocket_repr(self):
850
850
851
851
def test_weakref (self ):
852
852
with socket .socket (socket .AF_INET , socket .SOCK_STREAM ) as s :
853
- p = weakref . proxy (s )
853
+ p = proxy (s )
854
854
self .assertEqual (p .fileno (), s .fileno ())
855
855
s = None
856
856
try :
@@ -1882,25 +1882,6 @@ def test_socket_fileno_requires_valid_fd(self):
1882
1882
fileno = support .make_bad_fd ())
1883
1883
self .assertIn (cm .exception .errno , (errno .EBADF , WSAENOTSOCK ))
1884
1884
1885
- def testCreateConnectionDoesntCreateCycles (self ):
1886
- # `socket.create_connection` saves the exception in a
1887
- # variable to then re-raise, which caused a cycle
1888
- # and kept objects in upper frames alive unnecesarily.
1889
- port = support .find_unused_port ()
1890
- class A : pass
1891
- obj_wr = None
1892
-
1893
- def x ():
1894
- nonlocal obj_wr
1895
- obj = A ()
1896
- obj_wr = weakref .ref (obj )
1897
- try :
1898
- socket .create_connection ((HOST , port ))
1899
- except OSError :
1900
- pass
1901
- x ()
1902
- assert obj_wr () is None
1903
-
1904
1885
def test_socket_fileno_requires_socket_fd (self ):
1905
1886
with tempfile .NamedTemporaryFile () as afile :
1906
1887
with self .assertRaises (OSError ):
You can’t perform that action at this time.
0 commit comments