Commit 7e0e863e authored by Charles-François Natali's avatar Charles-François Natali

Merge.

parents bba4bca9 72330dcf
...@@ -229,7 +229,8 @@ def main(): ...@@ -229,7 +229,8 @@ def main():
success = False success = False
return success return success
else: else:
return compile_path(legacy=args.legacy) return compile_path(legacy=args.legacy, force=args.force,
quiet=args.quiet)
except KeyboardInterrupt: except KeyboardInterrupt:
print("\n[interrupted]") print("\n[interrupted]")
return False return False
......
...@@ -5,8 +5,6 @@ import os ...@@ -5,8 +5,6 @@ import os
import py_compile import py_compile
import shutil import shutil
import struct import struct
import subprocess
import sys
import tempfile import tempfile
import time import time
import unittest import unittest
...@@ -181,6 +179,29 @@ class CommandLineTests(unittest.TestCase): ...@@ -181,6 +179,29 @@ class CommandLineTests(unittest.TestCase):
self.assertNotCompiled(self.initfn) self.assertNotCompiled(self.initfn)
self.assertNotCompiled(self.barfn) self.assertNotCompiled(self.barfn)
def test_no_args_respects_force_flag(self):
bazfn = script_helper.make_script(self.directory, 'baz', '')
self.assertRunOK(PYTHONPATH=self.directory)
pycpath = importlib.util.cache_from_source(bazfn)
# Set atime/mtime backward to avoid file timestamp resolution issues
os.utime(pycpath, (time.time()-60,)*2)
mtime = os.stat(pycpath).st_mtime
# Without force, no recompilation
self.assertRunOK(PYTHONPATH=self.directory)
mtime2 = os.stat(pycpath).st_mtime
self.assertEqual(mtime, mtime2)
# Now force it.
self.assertRunOK('-f', PYTHONPATH=self.directory)
mtime2 = os.stat(pycpath).st_mtime
self.assertNotEqual(mtime, mtime2)
def test_no_args_respects_quiet_flag(self):
script_helper.make_script(self.directory, 'baz', '')
noisy = self.assertRunOK(PYTHONPATH=self.directory)
self.assertIn(b'Listing ', noisy)
quiet = self.assertRunOK('-q', PYTHONPATH=self.directory)
self.assertNotIn(b'Listing ', quiet)
# Ensure that the default behavior of compileall's CLI is to create # Ensure that the default behavior of compileall's CLI is to create
# PEP 3147 pyc/pyo files. # PEP 3147 pyc/pyo files.
for name, ext, switch in [ for name, ext, switch in [
......
...@@ -15,6 +15,9 @@ try: ...@@ -15,6 +15,9 @@ try:
import ssl import ssl
except ImportError: except ImportError:
ssl = None ssl = None
HAS_SNI = False
else:
from ssl import HAS_SNI
from unittest import TestCase, skipUnless from unittest import TestCase, skipUnless
from test import support from test import support
...@@ -924,6 +927,7 @@ class TestTLS_FTPClass(TestCase): ...@@ -924,6 +927,7 @@ class TestTLS_FTPClass(TestCase):
self.client.ccc() self.client.ccc()
self.assertRaises(ValueError, self.client.sock.unwrap) self.assertRaises(ValueError, self.client.sock.unwrap)
@skipUnless(HAS_SNI, 'No SNI support in ssl module')
def test_check_hostname(self): def test_check_hostname(self):
self.client.quit() self.client.quit()
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
......
...@@ -18,6 +18,9 @@ try: ...@@ -18,6 +18,9 @@ try:
import ssl import ssl
except ImportError: except ImportError:
ssl = None ssl = None
HAS_SNI = False
else:
from ssl import HAS_SNI
CERTFILE = None CERTFILE = None
CAFILE = None CAFILE = None
...@@ -349,6 +352,7 @@ class ThreadedNetworkedTestsSSL(BaseThreadedNetworkedTests): ...@@ -349,6 +352,7 @@ class ThreadedNetworkedTestsSSL(BaseThreadedNetworkedTests):
imap_class = IMAP4_SSL imap_class = IMAP4_SSL
@reap_threads @reap_threads
@unittest.skipUnless(HAS_SNI, 'No SNI support in ssl module')
def test_ssl_verified(self): def test_ssl_verified(self):
ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
ssl_context.verify_mode = ssl.CERT_REQUIRED ssl_context.verify_mode = ssl.CERT_REQUIRED
......
...@@ -21,10 +21,14 @@ PORT = 0 ...@@ -21,10 +21,14 @@ PORT = 0
SUPPORTS_SSL = False SUPPORTS_SSL = False
if hasattr(poplib, 'POP3_SSL'): if hasattr(poplib, 'POP3_SSL'):
import ssl import ssl
from ssl import HAS_SNI
SUPPORTS_SSL = True SUPPORTS_SSL = True
CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert3.pem") CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert3.pem")
CAFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "pycacert.pem") CAFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "pycacert.pem")
else:
HAS_SNI = False
requires_ssl = skipUnless(SUPPORTS_SSL, 'SSL not supported') requires_ssl = skipUnless(SUPPORTS_SSL, 'SSL not supported')
# the dummy data returned by server when LIST and RETR commands are issued # the dummy data returned by server when LIST and RETR commands are issued
...@@ -330,6 +334,7 @@ class TestPOP3Class(TestCase): ...@@ -330,6 +334,7 @@ class TestPOP3Class(TestCase):
self.assertEqual(resp, expected) self.assertEqual(resp, expected)
@requires_ssl @requires_ssl
@skipUnless(HAS_SNI, 'No SNI support in ssl module')
def test_stls_context(self): def test_stls_context(self):
expected = b'+OK Begin TLS negotiation' expected = b'+OK Begin TLS negotiation'
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
......
...@@ -1419,6 +1419,7 @@ class NetworkedTests(unittest.TestCase): ...@@ -1419,6 +1419,7 @@ class NetworkedTests(unittest.TestCase):
s.close() s.close()
self.assertEqual(len(ctx.get_ca_certs()), 1) self.assertEqual(len(ctx.get_ca_certs()), 1)
@needs_sni
def test_context_setget(self): def test_context_setget(self):
# Check that the context of a connected socket can be replaced. # Check that the context of a connected socket can be replaced.
with support.transient_internet("svn.python.org"): with support.transient_internet("svn.python.org"):
...@@ -1970,6 +1971,7 @@ else: ...@@ -1970,6 +1971,7 @@ else:
cert = s.getpeercert() cert = s.getpeercert()
self.assertTrue(cert, "Can't get peer certificate.") self.assertTrue(cert, "Can't get peer certificate.")
@needs_sni
def test_check_hostname(self): def test_check_hostname(self):
if support.verbose: if support.verbose:
sys.stdout.write("\n") sys.stdout.write("\n")
......
...@@ -44,6 +44,9 @@ Core and Builtins ...@@ -44,6 +44,9 @@ Core and Builtins
Library Library
------- -------
- Issue #19532: python -m compileall with no filename/directory arguments now
respects the -f and -q flags instead of ignoring them.
- Issue #19623: Fixed writing to unseekable files in the aifc module. - Issue #19623: Fixed writing to unseekable files in the aifc module.
- Issue #19946: multiprocessing.spawn now raises ImportError when the module to - Issue #19946: multiprocessing.spawn now raises ImportError when the module to
......
...@@ -4421,21 +4421,22 @@ mpd_qfma(mpd_t *result, const mpd_t *a, const mpd_t *b, const mpd_t *c, ...@@ -4421,21 +4421,22 @@ mpd_qfma(mpd_t *result, const mpd_t *a, const mpd_t *b, const mpd_t *c,
const mpd_context_t *ctx, uint32_t *status) const mpd_context_t *ctx, uint32_t *status)
{ {
uint32_t workstatus = 0; uint32_t workstatus = 0;
const mpd_t *cc = c; mpd_t *cc = NULL;
if (result == c) { if (result == c) {
if ((cc = mpd_qncopy(c)) == NULL) { if ((cc = mpd_qncopy(c)) == NULL) {
mpd_seterror(result, MPD_Malloc_error, status); mpd_seterror(result, MPD_Malloc_error, status);
return; return;
} }
c = cc;
} }
_mpd_qmul(result, a, b, ctx, &workstatus); _mpd_qmul(result, a, b, ctx, &workstatus);
if (!(workstatus&MPD_Invalid_operation)) { if (!(workstatus&MPD_Invalid_operation)) {
mpd_qadd(result, result, cc, ctx, &workstatus); mpd_qadd(result, result, c, ctx, &workstatus);
} }
if (cc != c) mpd_del((mpd_t *)cc); if (cc) mpd_del(cc);
*status |= workstatus; *status |= workstatus;
} }
......
...@@ -36,9 +36,6 @@ static PyObject _dummy_struct; ...@@ -36,9 +36,6 @@ static PyObject _dummy_struct;
#define dummy (&_dummy_struct) #define dummy (&_dummy_struct)
/* Exported for the gdb plugin's benefit. */
PyObject *_PySet_Dummy = dummy;
/* ======================================================================== */ /* ======================================================================== */
/* ======= Begin logic for probing the hash table ========================= */ /* ======= Begin logic for probing the hash table ========================= */
...@@ -2345,6 +2342,9 @@ _PySet_Update(PyObject *set, PyObject *iterable) ...@@ -2345,6 +2342,9 @@ _PySet_Update(PyObject *set, PyObject *iterable)
return set_update_internal((PySetObject *)set, iterable); return set_update_internal((PySetObject *)set, iterable);
} }
/* Exported for the gdb plugin's benefit. */
PyObject *_PySet_Dummy = dummy;
#ifdef Py_DEBUG #ifdef Py_DEBUG
/* Test code to be called with any three element set. /* Test code to be called with any three element set.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment