mirror of
https://github.com/python/cpython.git
synced 2025-11-24 12:20:42 +00:00
Merge Python 3.4.0rc1 release branch.
This commit is contained in:
commit
3f99504c08
22 changed files with 198 additions and 64 deletions
|
|
@ -96,6 +96,7 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
self._default_executor = None
|
||||
self._internal_fds = 0
|
||||
self._running = False
|
||||
self._clock_resolution = time.get_clock_info('monotonic').resolution
|
||||
|
||||
def _make_socket_transport(self, sock, protocol, waiter=None, *,
|
||||
extra=None, server=None):
|
||||
|
|
@ -643,10 +644,10 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
self._process_events(event_list)
|
||||
|
||||
# Handle 'later' callbacks that are ready.
|
||||
now = self.time()
|
||||
end_time = self.time() + self._clock_resolution
|
||||
while self._scheduled:
|
||||
handle = self._scheduled[0]
|
||||
if handle._when > now:
|
||||
if handle._when >= end_time:
|
||||
break
|
||||
handle = heapq.heappop(self._scheduled)
|
||||
self._ready.append(handle)
|
||||
|
|
|
|||
|
|
@ -191,6 +191,7 @@ class TestLoop(base_events.BaseEventLoop):
|
|||
self._gen = gen()
|
||||
next(self._gen)
|
||||
self._time = 0
|
||||
self._clock_resolution = 1e-9
|
||||
self._timers = []
|
||||
self._selector = TestSelector()
|
||||
|
||||
|
|
|
|||
|
|
@ -111,6 +111,8 @@ class _SimpleBinder:
|
|||
except tkinter.TclError as e:
|
||||
if e.args[0] == APPLICATION_GONE:
|
||||
pass
|
||||
else:
|
||||
raise
|
||||
|
||||
# An int in range(1 << len(_modifiers)) represents a combination of modifiers
|
||||
# (if the least significent bit is on, _modifiers[0] is on, and so on).
|
||||
|
|
@ -244,6 +246,8 @@ class _ComplexBinder:
|
|||
except tkinter.TclError as e:
|
||||
if e.args[0] == APPLICATION_GONE:
|
||||
break
|
||||
else:
|
||||
raise
|
||||
|
||||
# define the list of event types to be handled by MultiEvent. the order is
|
||||
# compatible with the definition of event type constants.
|
||||
|
|
@ -411,6 +415,8 @@ def MultiCallCreator(widget):
|
|||
except tkinter.TclError as e:
|
||||
if e.args[0] == APPLICATION_GONE:
|
||||
break
|
||||
else:
|
||||
raise
|
||||
|
||||
_multicall_dict[widget] = MultiCall
|
||||
return MultiCall
|
||||
|
|
|
|||
|
|
@ -875,4 +875,3 @@ What's New in IDLEfork 0.9 Alpha 1?
|
|||
--------------------------------------------------------------------
|
||||
Refer to HISTORY.txt for additional information on earlier releases.
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ SMTP_PORT = 25
|
|||
SMTP_SSL_PORT = 465
|
||||
CRLF = "\r\n"
|
||||
bCRLF = b"\r\n"
|
||||
_MAXLINE = 8192 # more than 8 times larger than RFC 821, 4.5.3
|
||||
|
||||
OLDSTYLE_AUTH = re.compile(r"auth=(.*)", re.I)
|
||||
|
||||
|
|
@ -365,7 +366,7 @@ class SMTP:
|
|||
self.file = self.sock.makefile('rb')
|
||||
while 1:
|
||||
try:
|
||||
line = self.file.readline()
|
||||
line = self.file.readline(_MAXLINE + 1)
|
||||
except OSError as e:
|
||||
self.close()
|
||||
raise SMTPServerDisconnected("Connection unexpectedly closed: "
|
||||
|
|
@ -375,6 +376,8 @@ class SMTP:
|
|||
raise SMTPServerDisconnected("Connection unexpectedly closed")
|
||||
if self.debuglevel > 0:
|
||||
print('reply:', repr(line), file=stderr)
|
||||
if len(line) > _MAXLINE:
|
||||
raise SMTPResponseException(500, "Line too long.")
|
||||
resp.append(line[4:].strip(b' \t\r\n'))
|
||||
code = line[:3]
|
||||
# Check that the error code is syntactically correct.
|
||||
|
|
|
|||
|
|
@ -738,6 +738,9 @@ _PLATFORM_DEFAULT_CLOSE_FDS = object()
|
|||
|
||||
|
||||
class Popen(object):
|
||||
|
||||
_child_created = False # Set here since __del__ checks it
|
||||
|
||||
def __init__(self, args, bufsize=-1, executable=None,
|
||||
stdin=None, stdout=None, stderr=None,
|
||||
preexec_fn=None, close_fds=_PLATFORM_DEFAULT_CLOSE_FDS,
|
||||
|
|
@ -748,7 +751,6 @@ class Popen(object):
|
|||
"""Create new Popen instance."""
|
||||
_cleanup()
|
||||
|
||||
self._child_created = False
|
||||
self._input = None
|
||||
self._communication_started = False
|
||||
if bufsize is None:
|
||||
|
|
@ -890,11 +892,8 @@ class Popen(object):
|
|||
# Wait for the process to terminate, to avoid zombies.
|
||||
self.wait()
|
||||
|
||||
def __del__(self, _maxsize=sys.maxsize, _active=_active):
|
||||
# If __init__ hasn't had a chance to execute (e.g. if it
|
||||
# was passed an undeclared keyword argument), we don't
|
||||
# have a _child_created attribute at all.
|
||||
if not getattr(self, '_child_created', False):
|
||||
def __del__(self, _maxsize=sys.maxsize):
|
||||
if not self._child_created:
|
||||
# We didn't get to successfully create a child process.
|
||||
return
|
||||
# In case the child hasn't been waited on, check if it's done.
|
||||
|
|
@ -1446,7 +1445,7 @@ class Popen(object):
|
|||
_WTERMSIG=os.WTERMSIG, _WIFEXITED=os.WIFEXITED,
|
||||
_WEXITSTATUS=os.WEXITSTATUS):
|
||||
# This method is called (indirectly) by __del__, so it cannot
|
||||
# refer to anything outside of its local scope."""
|
||||
# refer to anything outside of its local scope.
|
||||
if _WIFSIGNALED(sts):
|
||||
self.returncode = -_WTERMSIG(sts)
|
||||
elif _WIFEXITED(sts):
|
||||
|
|
|
|||
|
|
@ -21,8 +21,13 @@ class MockFile:
|
|||
"""
|
||||
def __init__(self, lines):
|
||||
self.lines = lines
|
||||
def readline(self):
|
||||
return self.lines.pop(0) + b'\r\n'
|
||||
def readline(self, limit=-1):
|
||||
result = self.lines.pop(0) + b'\r\n'
|
||||
if limit >= 0:
|
||||
# Re-insert the line, removing the \r\n we added.
|
||||
self.lines.insert(0, result[limit:-2])
|
||||
result = result[:limit]
|
||||
return result
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -1176,15 +1176,17 @@ class EventLoopTestsMixin:
|
|||
loop = self.loop
|
||||
yield from asyncio.sleep(1e-2, loop=loop)
|
||||
yield from asyncio.sleep(1e-4, loop=loop)
|
||||
yield from asyncio.sleep(1e-6, loop=loop)
|
||||
yield from asyncio.sleep(1e-8, loop=loop)
|
||||
yield from asyncio.sleep(1e-10, loop=loop)
|
||||
|
||||
self.loop.run_until_complete(wait())
|
||||
# The ideal number of call is 6, but on some platforms, the selector
|
||||
# The ideal number of call is 12, but on some platforms, the selector
|
||||
# may sleep at little bit less than timeout depending on the resolution
|
||||
# of the clock used by the kernel. Tolerate 2 useless calls on these
|
||||
# platforms.
|
||||
self.assertLessEqual(self.loop._run_once_counter, 8,
|
||||
{'time_info': time.get_clock_info('time'),
|
||||
'monotonic_info': time.get_clock_info('monotonic'),
|
||||
# of the clock used by the kernel. Tolerate a few useless calls on
|
||||
# these platforms.
|
||||
self.assertLessEqual(self.loop._run_once_counter, 20,
|
||||
{'clock_resolution': self.loop._clock_resolution,
|
||||
'selector': self.loop._selector.__class__.__name__})
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import unittest
|
|||
import warnings
|
||||
from operator import neg
|
||||
from test.support import TESTFN, unlink, run_unittest, check_warnings
|
||||
from test.script_helper import assert_python_ok
|
||||
try:
|
||||
import pty, signal
|
||||
except ImportError:
|
||||
|
|
@ -1592,6 +1593,34 @@ class TestSorted(unittest.TestCase):
|
|||
data = 'The quick Brown fox Jumped over The lazy Dog'.split()
|
||||
self.assertRaises(TypeError, sorted, data, None, lambda x,y: 0)
|
||||
|
||||
|
||||
class ShutdownTest(unittest.TestCase):
|
||||
|
||||
def test_cleanup(self):
|
||||
# Issue #19255: builtins are still available at shutdown
|
||||
code = """if 1:
|
||||
import builtins
|
||||
import sys
|
||||
|
||||
class C:
|
||||
def __del__(self):
|
||||
print("before")
|
||||
# Check that builtins still exist
|
||||
len(())
|
||||
print("after")
|
||||
|
||||
c = C()
|
||||
# Make this module survive until builtins and sys are cleaned
|
||||
builtins.here = sys.modules[__name__]
|
||||
sys.here = sys.modules[__name__]
|
||||
# Create a reference loop so that this module needs to go
|
||||
# through a GC phase.
|
||||
here = sys.modules[__name__]
|
||||
"""
|
||||
rc, out, err = assert_python_ok("-c", code)
|
||||
self.assertEqual(["before", "after"], out.decode().splitlines())
|
||||
|
||||
|
||||
def load_tests(loader, tests, pattern):
|
||||
from doctest import DocTestSuite
|
||||
tests.addTest(DocTestSuite(builtins))
|
||||
|
|
|
|||
|
|
@ -2691,7 +2691,8 @@ class CTextIOWrapperTest(TextIOWrapperTest):
|
|||
|
||||
class PyTextIOWrapperTest(TextIOWrapperTest):
|
||||
io = pyio
|
||||
shutdown_error = "LookupError: unknown encoding: ascii"
|
||||
#shutdown_error = "LookupError: unknown encoding: ascii"
|
||||
shutdown_error = "TypeError: 'NoneType' object is not iterable"
|
||||
|
||||
|
||||
class IncrementalNewlineDecoderTest(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -563,6 +563,33 @@ class BadHELOServerTests(unittest.TestCase):
|
|||
HOST, self.port, 'localhost', 3)
|
||||
|
||||
|
||||
@unittest.skipUnless(threading, 'Threading required for this test.')
|
||||
class TooLongLineTests(unittest.TestCase):
|
||||
respdata = b'250 OK' + (b'.' * smtplib._MAXLINE * 2) + b'\n'
|
||||
|
||||
def setUp(self):
|
||||
self.old_stdout = sys.stdout
|
||||
self.output = io.StringIO()
|
||||
sys.stdout = self.output
|
||||
|
||||
self.evt = threading.Event()
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.sock.settimeout(15)
|
||||
self.port = support.bind_port(self.sock)
|
||||
servargs = (self.evt, self.respdata, self.sock)
|
||||
threading.Thread(target=server, args=servargs).start()
|
||||
self.evt.wait()
|
||||
self.evt.clear()
|
||||
|
||||
def tearDown(self):
|
||||
self.evt.wait()
|
||||
sys.stdout = self.old_stdout
|
||||
|
||||
def testLineTooLong(self):
|
||||
self.assertRaises(smtplib.SMTPResponseException, smtplib.SMTP,
|
||||
HOST, self.port, 'localhost', 3)
|
||||
|
||||
|
||||
sim_users = {'Mr.A@somewhere.com':'John A',
|
||||
'Ms.B@xn--fo-fka.com':'Sally B',
|
||||
'Mrs.C@somewhereesle.com':'Ruth C',
|
||||
|
|
@ -888,7 +915,8 @@ class SMTPSimTests(unittest.TestCase):
|
|||
def test_main(verbose=None):
|
||||
support.run_unittest(GeneralTests, DebuggingServerTests,
|
||||
NonConnectingTests,
|
||||
BadHELOServerTests, SMTPSimTests)
|
||||
BadHELOServerTests, SMTPSimTests,
|
||||
TooLongLineTests)
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue