Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2a8911c

Browse files
committed
asyncio: Sync with upstream (compat module)
1 parent 996083d commit 2a8911c

7 files changed

Lines changed: 14 additions & 16 deletions

File tree

Lib/asyncio/base_events.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import sys
2929
import warnings
3030

31+
from . import compat
3132
from . import coroutines
3233
from . import events
3334
from . import futures
@@ -378,7 +379,7 @@ def is_closed(self):
378379
# On Python 3.3 and older, objects with a destructor part of a reference
379380
# cycle are never destroyed. It's not more the case on Python 3.4 thanks
380381
# to the PEP 442.
381-
if sys.version_info >= (3, 4):
382+
if compat.PY34:
382383
def __del__(self):
383384
if not self.is_closed():
384385
warnings.warn("unclosed event loop %r" % self, ResourceWarning)

Lib/asyncio/base_subprocess.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import collections
22
import subprocess
3-
import sys
43
import warnings
54

5+
from . import compat
66
from . import futures
77
from . import protocols
88
from . import transports
@@ -116,7 +116,7 @@ def close(self):
116116
# On Python 3.3 and older, objects with a destructor part of a reference
117117
# cycle are never destroyed. It's not more the case on Python 3.4 thanks
118118
# to the PEP 442.
119-
if sys.version_info >= (3, 4):
119+
if compat.PY34:
120120
def __del__(self):
121121
if not self._closed:
122122
warnings.warn("unclosed transport %r" % self, ResourceWarning)

Lib/asyncio/proactor_events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
__all__ = ['BaseProactorEventLoop']
88

99
import socket
10-
import sys
1110
import warnings
1211

1312
from . import base_events
13+
from . import compat
1414
from . import constants
1515
from . import futures
1616
from . import sslproto
@@ -79,7 +79,7 @@ def close(self):
7979
# On Python 3.3 and older, objects with a destructor part of a reference
8080
# cycle are never destroyed. It's not more the case on Python 3.4 thanks
8181
# to the PEP 442.
82-
if sys.version_info >= (3, 4):
82+
if compat.PY34:
8383
def __del__(self):
8484
if self._sock is not None:
8585
warnings.warn("unclosed transport %r" % self, ResourceWarning)

Lib/asyncio/selector_events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
import errno
1111
import functools
1212
import socket
13-
import sys
1413
import warnings
1514
try:
1615
import ssl
1716
except ImportError: # pragma: no cover
1817
ssl = None
1918

2019
from . import base_events
20+
from . import compat
2121
from . import constants
2222
from . import events
2323
from . import futures
@@ -568,7 +568,7 @@ def close(self):
568568
# On Python 3.3 and older, objects with a destructor part of a reference
569569
# cycle are never destroyed. It's not more the case on Python 3.4 thanks
570570
# to the PEP 442.
571-
if sys.version_info >= (3, 4):
571+
if compat.PY34:
572572
def __del__(self):
573573
if self._sock is not None:
574574
warnings.warn("unclosed transport %r" % self, ResourceWarning)

Lib/asyncio/sslproto.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import collections
2-
import sys
32
import warnings
43
try:
54
import ssl
65
except ImportError: # pragma: no cover
76
ssl = None
87

8+
from . import compat
99
from . import protocols
1010
from . import transports
1111
from .log import logger
@@ -317,7 +317,7 @@ def close(self):
317317
# On Python 3.3 and older, objects with a destructor part of a reference
318318
# cycle are never destroyed. It's not more the case on Python 3.4 thanks
319319
# to the PEP 442.
320-
if sys.version_info >= (3, 4):
320+
if compat.PY34:
321321
def __del__(self):
322322
if not self._closed:
323323
warnings.warn("unclosed transport %r" % self, ResourceWarning)

Lib/asyncio/unix_events.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from . import base_events
1515
from . import base_subprocess
16+
from . import compat
1617
from . import constants
1718
from . import coroutines
1819
from . import events
@@ -370,7 +371,7 @@ def close(self):
370371
# On Python 3.3 and older, objects with a destructor part of a reference
371372
# cycle are never destroyed. It's not more the case on Python 3.4 thanks
372373
# to the PEP 442.
373-
if sys.version_info >= (3, 4):
374+
if compat.PY34:
374375
def __del__(self):
375376
if self._pipe is not None:
376377
warnings.warn("unclosed transport %r" % self, ResourceWarning)
@@ -555,7 +556,7 @@ def close(self):
555556
# On Python 3.3 and older, objects with a destructor part of a reference
556557
# cycle are never destroyed. It's not more the case on Python 3.4 thanks
557558
# to the PEP 442.
558-
if sys.version_info >= (3, 4):
559+
if compat.PY34:
559560
def __del__(self):
560561
if self._pipe is not None:
561562
warnings.warn("unclosed transport %r" % self, ResourceWarning)

Lib/test/test_asyncio/test_subprocess.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,7 @@ def kill_running():
417417
def test_popen_error(self):
418418
# Issue #24763: check that the subprocess transport is closed
419419
# when BaseSubprocessTransport fails
420-
if sys.platform == 'win32':
421-
target = 'asyncio.windows_utils.Popen'
422-
else:
423-
target = 'subprocess.Popen'
424-
with mock.patch(target) as popen:
420+
with mock.patch('subprocess.Popen') as popen:
425421
exc = ZeroDivisionError
426422
popen.side_effect = exc
427423

0 commit comments

Comments
 (0)