From 06e18a7c2473e6d1e8be3dee5c9232ab934e1ef2 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 11 Sep 2016 17:23:49 -0700 Subject: Issue #26511: Reference the id() function in the 'is' and 'is not' docs --- Doc/reference/expressions.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index eafd70a..08938b2 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -1315,8 +1315,9 @@ Identity comparisons -------------------- The operators :keyword:`is` and :keyword:`is not` test for object identity: ``x -is y`` is true if and only if *x* and *y* are the same object. ``x is not y`` -yields the inverse truth value. [#]_ +is y`` is true if and only if *x* and *y* are the same object. Object identity +is determined using the :meth:`id` function. ``x is not y`` yields the inverse +truth value. [#]_ .. _booleans: -- cgit v0.12 From a05a6ef1ca781e2f98fb4332284aca649f24f75d Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Sun, 11 Sep 2016 21:11:02 -0400 Subject: asyncio: Add set_protocol / get_protocol methods to Transports --- Lib/asyncio/base_subprocess.py | 6 ++++++ Lib/asyncio/proactor_events.py | 6 ++++++ Lib/asyncio/selector_events.py | 6 ++++++ Lib/asyncio/sslproto.py | 6 ++++++ Lib/asyncio/transports.py | 8 ++++++++ Lib/asyncio/unix_events.py | 12 ++++++++++++ Lib/test/test_asyncio/test_sslproto.py | 1 + 7 files changed, 45 insertions(+) diff --git a/Lib/asyncio/base_subprocess.py b/Lib/asyncio/base_subprocess.py index 8fc253c..bcc481d 100644 --- a/Lib/asyncio/base_subprocess.py +++ b/Lib/asyncio/base_subprocess.py @@ -87,6 +87,12 @@ class BaseSubprocessTransport(transports.SubprocessTransport): def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs): raise NotImplementedError + def set_protocol(self, protocol): + self._protocol = protocol + + def get_protocol(self): + return self._protocol + def is_closing(self): return self._closed diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py index 3ac314c..97ab487 100644 --- a/Lib/asyncio/proactor_events.py +++ b/Lib/asyncio/proactor_events.py @@ -66,6 +66,12 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, def _set_extra(self, sock): self._extra['pipe'] = sock + def set_protocol(self, protocol): + self._protocol = protocol + + def get_protocol(self): + return self._protocol + def is_closing(self): return self._closing diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py index ed2b4d7..c57f509 100644 --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -560,6 +560,12 @@ class _SelectorTransport(transports._FlowControlMixin, def abort(self): self._force_close(None) + def set_protocol(self, protocol): + self._protocol = protocol + + def get_protocol(self): + return self._protocol + def is_closing(self): return self._closing diff --git a/Lib/asyncio/sslproto.py b/Lib/asyncio/sslproto.py index 33d5de2..afe85a1 100644 --- a/Lib/asyncio/sslproto.py +++ b/Lib/asyncio/sslproto.py @@ -305,6 +305,12 @@ class _SSLProtocolTransport(transports._FlowControlMixin, """Get optional transport information.""" return self._ssl_protocol._get_extra_info(name, default) + def set_protocol(self, protocol): + self._app_protocol = protocol + + def get_protocol(self): + return self._app_protocol + def is_closing(self): return self._closed diff --git a/Lib/asyncio/transports.py b/Lib/asyncio/transports.py index 9a6d919..0db0875 100644 --- a/Lib/asyncio/transports.py +++ b/Lib/asyncio/transports.py @@ -33,6 +33,14 @@ class BaseTransport: """ raise NotImplementedError + def set_protocol(self, protocol): + """Set a new protocol.""" + raise NotImplementedError + + def get_protocol(self): + """Return the current protocol.""" + raise NotImplementedError + class ReadTransport(BaseTransport): """Interface for read-only transports.""" diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py index 18519fc..f7f9eb2 100644 --- a/Lib/asyncio/unix_events.py +++ b/Lib/asyncio/unix_events.py @@ -374,6 +374,12 @@ class _UnixReadPipeTransport(transports.ReadTransport): def resume_reading(self): self._loop.add_reader(self._fileno, self._read_ready) + def set_protocol(self, protocol): + self._protocol = protocol + + def get_protocol(self): + return self._protocol + def is_closing(self): return self._closing @@ -570,6 +576,12 @@ class _UnixWritePipeTransport(transports._FlowControlMixin, self._loop.remove_reader(self._fileno) self._loop.call_soon(self._call_connection_lost, None) + def set_protocol(self, protocol): + self._protocol = protocol + + def get_protocol(self): + return self._protocol + def is_closing(self): return self._closing diff --git a/Lib/test/test_asyncio/test_sslproto.py b/Lib/test/test_asyncio/test_sslproto.py index 8d52335..7dfa6c2 100644 --- a/Lib/test/test_asyncio/test_sslproto.py +++ b/Lib/test/test_asyncio/test_sslproto.py @@ -25,6 +25,7 @@ class SslProtoHandshakeTests(test_utils.TestCase): sslcontext = test_utils.dummy_ssl_context() app_proto = asyncio.Protocol() proto = sslproto.SSLProtocol(self.loop, app_proto, sslcontext, waiter) + self.assertIs(proto._app_transport.get_protocol(), app_proto) self.addCleanup(proto._app_transport.close) return proto -- cgit v0.12 From 2609fa7311c7536b8e8412f213576568f0f61957 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Sun, 11 Sep 2016 21:25:01 -0400 Subject: Merge 3.5 (asyncio/NEWS) --- Misc/NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index 25bf7cc..8a28aad 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -363,6 +363,8 @@ Library - Issue #21201: Improves readability of multiprocessing error message. Thanks to Wojciech Walczak for patch. +- asyncio: Add set_protocol / get_protocol to Transports. + IDLE ---- -- cgit v0.12 From c5ee3caa807abeb14b586117ce36bc1c2a762390 Mon Sep 17 00:00:00 2001 From: Martin Panter Date: Mon, 12 Sep 2016 01:32:03 +0000 Subject: Issue #28066: Fix include search directory logic for out-of-tree builds --- Misc/NEWS | 3 +++ configure | 2 +- configure.ac | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index 73286b7..43f8f25 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -322,6 +322,9 @@ Windows Build ----- +- Issue #28066: Fix the logic that searches build directories for generated + include files when building outside the source tree. + - Issue #27566: Fix clean target in freeze makefile (patch by Lisa Roach) - Issue #27705: Update message in validate_ucrtbase.py diff --git a/configure b/configure index ab1c32a..19fcbd1 100755 --- a/configure +++ b/configure @@ -2820,7 +2820,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test "$abs_srcdir" != "$abs_builddir"; then +if test "$srcdir" != . -a "$srcdir" != "$(pwd)"; then # If we're building out-of-tree, we need to make sure the following # resources get picked up before their $srcdir counterparts. # Objects/ -> typeslots.inc diff --git a/configure.ac b/configure.ac index 36758d4..381bab0 100644 --- a/configure.ac +++ b/configure.ac @@ -10,7 +10,7 @@ AC_PREREQ(2.65) AC_INIT(python, PYTHON_VERSION, https://bugs.python.org/) AC_SUBST(BASECPPFLAGS) -if test "$abs_srcdir" != "$abs_builddir"; then +if test "$srcdir" != . -a "$srcdir" != "$(pwd)"; then # If we're building out-of-tree, we need to make sure the following # resources get picked up before their $srcdir counterparts. # Objects/ -> typeslots.inc -- cgit v0.12 From 44c19eccf9fd8258f8d939fe30b79b644b2c235a Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Sun, 11 Sep 2016 21:39:31 -0400 Subject: Issue #27456: asyncio: Set TCP_NODELAY by default. --- Lib/asyncio/selector_events.py | 16 ++++++++++++++++ Misc/NEWS | 2 ++ 2 files changed, 18 insertions(+) diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py index c57f509..c91ab04 100644 --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -39,6 +39,17 @@ def _test_selector_event(selector, fd, event): return bool(key.events & event) +if hasattr(socket, 'TCP_NODELAY'): + def _set_nodelay(sock): + if (sock.family in {socket.AF_INET, socket.AF_INET6} and + sock.type == socket.SOCK_STREAM and + sock.proto == socket.IPPROTO_TCP): + sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) +else: + def _set_nodelay(sock): + pass + + class BaseSelectorEventLoop(base_events.BaseEventLoop): """Selector event loop. @@ -640,6 +651,11 @@ class _SelectorSocketTransport(_SelectorTransport): self._eof = False self._paused = False + # Disable the Nagle algorithm -- small writes will be + # sent without waiting for the TCP ACK. This generally + # decreases the latency (in some cases significantly.) + _set_nodelay(self._sock) + self._loop.call_soon(self._protocol.connection_made, self) # only start reading when connection_made() has been called self._loop.call_soon(self._loop.add_reader, diff --git a/Misc/NEWS b/Misc/NEWS index d1c36f0..73286b7 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -254,6 +254,8 @@ Library - Issue #21201: Improves readability of multiprocessing error message. Thanks to Wojciech Walczak for patch. +- Issue #27456: asyncio: Set TCP_NODELAY by default. + IDLE ---- -- cgit v0.12 From 16c18a354b8ae3e6a2a68de5cdb2679c5c8011e5 Mon Sep 17 00:00:00 2001 From: Zachary Ware Date: Sun, 11 Sep 2016 21:18:07 -0500 Subject: Issue #28065: Update xz to 5.2.2 on Windows, and build it from source --- Misc/NEWS | 2 + PCbuild/_lzma.vcxproj | 12 +-- PCbuild/get_externals.bat | 2 +- PCbuild/liblzma.vcxproj | 216 ++++++++++++++++++++++++++++++++++++++++++++++ PCbuild/python.props | 2 +- 5 files changed, 227 insertions(+), 7 deletions(-) create mode 100644 PCbuild/liblzma.vcxproj diff --git a/Misc/NEWS b/Misc/NEWS index 5e2836a..1eb37ea 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -447,6 +447,8 @@ Tools/Demos Windows ------- +- Issue #28065: Update xz dependency to 5.2.2 and build it from source. + - Issue #25144: Ensures TargetDir is set before continuing with custom install. diff --git a/PCbuild/_lzma.vcxproj b/PCbuild/_lzma.vcxproj index 1f0696da..7ec2692 100644 --- a/PCbuild/_lzma.vcxproj +++ b/PCbuild/_lzma.vcxproj @@ -61,13 +61,11 @@ - $(lzmaDir)include;%(AdditionalIncludeDirectories) + $(lzmaDir)src/liblzma/api;%(AdditionalIncludeDirectories) WIN32;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;LZMA_API_STATIC;%(PreprocessorDefinitions) - $(lzmaDir)\bin_i486\liblzma.a;%(AdditionalDependencies) - $(lzmaDir)\bin_x86-64\liblzma.a;%(AdditionalDependencies) - false + $(OutDir)/liblzma$(PyDebugExt).lib @@ -81,8 +79,12 @@ {cf7ac3d1-e2df-41d2-bea6-1e2556cdea26} false + + {12728250-16eC-4dc6-94d7-e21dd88947f8} + false + - \ No newline at end of file + diff --git a/PCbuild/get_externals.bat b/PCbuild/get_externals.bat index a45e73d..91a2a6d 100644 --- a/PCbuild/get_externals.bat +++ b/PCbuild/get_externals.bat @@ -59,7 +59,7 @@ set libraries=%libraries% sqlite-3.14.1.0 if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tcl-core-8.6.6.0 if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tk-8.6.6.0 if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tix-8.4.3.6 -set libraries=%libraries% xz-5.0.5 +set libraries=%libraries% xz-5.2.2 for %%e in (%libraries%) do ( if exist %%e ( diff --git a/PCbuild/liblzma.vcxproj b/PCbuild/liblzma.vcxproj new file mode 100644 index 0000000..711f9bd --- /dev/null +++ b/PCbuild/liblzma.vcxproj @@ -0,0 +1,216 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + PGInstrument + Win32 + + + PGInstrument + x64 + + + PGUpdate + Win32 + + + PGUpdate + x64 + + + Debug + x64 + + + Release + x64 + + + + {12728250-16EC-4DC6-94D7-E21DD88947F8} + liblzma + true + + + + + + + StaticLibrary + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + + + + WIN32;HAVE_CONFIG_H;_DEBUG;_LIB;%(PreprocessorDefinitions) + Level3 + ProgramDatabase + Disabled + $(lzmaDir)windows;$(lzmaDir)src/liblzma/common;$(lzmaDir)src/common;$(lzmaDir)src/liblzma/api;$(lzmaDir)src/liblzma/check;$(lzmaDir)src/liblzma/delta;$(lzmaDir)src/liblzma/lz;$(lzmaDir)src/liblzma/lzma;$(lzmaDir)src/liblzma/rangecoder;$(lzmaDir)src/liblzma/simple + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PCbuild/python.props b/PCbuild/python.props index 5f5e756..0150098 100644 --- a/PCbuild/python.props +++ b/PCbuild/python.props @@ -45,7 +45,7 @@ $([System.IO.Path]::GetFullPath(`$(PySourcePath)externals\`)) $(ExternalsDir)sqlite-3.14.1.0\ $(ExternalsDir)bzip2-1.0.6\ - $(ExternalsDir)xz-5.0.5\ + $(ExternalsDir)xz-5.2.2\ $(ExternalsDir)openssl-1.0.2h\ $(opensslDir)include32 $(opensslDir)include64 -- cgit v0.12 From a3222b8424e932783e417411e428779d08d2b8a9 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Sun, 11 Sep 2016 19:43:51 -0700 Subject: Fixes test_getargs2 to get the buildbots working again. --- Lib/test/test_getargs2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py index 8a194aa..5750bfa 100644 --- a/Lib/test/test_getargs2.py +++ b/Lib/test/test_getargs2.py @@ -471,7 +471,7 @@ class Tuple_TestCase(unittest.TestCase): ret = get_args(*TupleSubclass([1, 2])) self.assertEqual(ret, (1, 2)) - self.assertIs(type(ret), tuple) + self.assertIsInstance(ret, tuple) ret = get_args() self.assertIn(ret, ((), None)) -- cgit v0.12 From 18f3a9b93ccd4caeda3c34d1ce850c2cc33f7722 Mon Sep 17 00:00:00 2001 From: Alexander Belopolsky Date: Sun, 11 Sep 2016 22:55:16 -0400 Subject: Closes #25283: Make tm_gmtoff and tm_zone available on all platforms. --- Doc/library/time.rst | 8 ++-- Misc/NEWS | 4 ++ Modules/timemodule.c | 114 ++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 89 insertions(+), 37 deletions(-) diff --git a/Doc/library/time.rst b/Doc/library/time.rst index 7c81ce7..ae17f6f 100644 --- a/Doc/library/time.rst +++ b/Doc/library/time.rst @@ -83,6 +83,10 @@ An explanation of some terminology and conventions is in order. and :attr:`tm_zone` attributes when platform supports corresponding ``struct tm`` members. + .. versionchanged:: 3.6 + The :class:`struct_time` attributes :attr:`tm_gmtoff` and :attr:`tm_zone` + are now available on all platforms. + * Use the following functions to convert between time representations: +-------------------------+-------------------------+-------------------------+ @@ -566,10 +570,6 @@ The module defines the following functions and data items: :class:`struct_time`, or having elements of the wrong type, a :exc:`TypeError` is raised. - .. versionchanged:: 3.3 - :attr:`tm_gmtoff` and :attr:`tm_zone` attributes are available on platforms - with C library supporting the corresponding fields in ``struct tm``. - .. function:: time() Return the time in seconds since the epoch as a floating point number. diff --git a/Misc/NEWS b/Misc/NEWS index 1eb37ea..35f1d65 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -143,6 +143,10 @@ Core and Builtins Library ------- +- Issue #25283: Attributes tm_gmtoff and tm_zone are now available on + all platforms in the return values of time.localtime() and + time.gmtime(). + - Issue #24454: Regular expression match object groups are now accessible using __getitem__. "mo[x]" is equivalent to "mo.group(x)". diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 9474644..ea7d906 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -250,10 +250,8 @@ static PyStructSequence_Field struct_time_type_fields[] = { {"tm_wday", "day of week, range [0, 6], Monday is 0"}, {"tm_yday", "day of year, range [1, 366]"}, {"tm_isdst", "1 if summer time is in effect, 0 if not, and -1 if unknown"}, -#ifdef HAVE_STRUCT_TM_TM_ZONE {"tm_zone", "abbreviation of timezone name"}, {"tm_gmtoff", "offset from UTC in seconds"}, -#endif /* HAVE_STRUCT_TM_TM_ZONE */ {0} }; @@ -275,7 +273,11 @@ static PyTypeObject StructTimeType; static PyObject * -tmtotuple(struct tm *p) +tmtotuple(struct tm *p +#ifndef HAVE_STRUCT_TM_TM_ZONE + , const char *zone, int gmtoff +#endif +) { PyObject *v = PyStructSequence_New(&StructTimeType); if (v == NULL) @@ -296,6 +298,10 @@ tmtotuple(struct tm *p) PyStructSequence_SET_ITEM(v, 9, PyUnicode_DecodeLocale(p->tm_zone, "surrogateescape")); SET(10, p->tm_gmtoff); +#else + PyStructSequence_SET_ITEM(v, 9, + PyUnicode_DecodeLocale(zone, "surrogateescape")); + SET(10, gmtoff); #endif /* HAVE_STRUCT_TM_TM_ZONE */ #undef SET if (PyErr_Occurred()) { @@ -348,9 +354,26 @@ time_gmtime(PyObject *self, PyObject *args) return PyErr_SetFromErrno(PyExc_OSError); } buf = *local; +#ifdef HAVE_STRUCT_TM_TM_ZONE return tmtotuple(&buf); +#else + return tmtotuple(&buf, "UTC", 0); +#endif } +#ifndef HAVE_TIMEGM +static time_t +timegm(struct tm *p) +{ + /* XXX: the following implementation will not work for tm_year < 1970. + but it is likely that platforms that don't have timegm do not support + negative timestamps anyways. */ + return p->tm_sec + p->tm_min*60 + p->tm_hour*3600 + p->tm_yday*86400 + + (p->tm_year-70)*31536000 + ((p->tm_year-69)/4)*86400 - + ((p->tm_year-1)/100)*86400 + ((p->tm_year+299)/400)*86400; +} +#endif + PyDoc_STRVAR(gmtime_doc, "gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,\n\ tm_sec, tm_wday, tm_yday, tm_isdst)\n\ @@ -391,7 +414,18 @@ time_localtime(PyObject *self, PyObject *args) return NULL; if (pylocaltime(&when, &buf) == -1) return NULL; +#ifdef HAVE_STRUCT_TM_TM_ZONE return tmtotuple(&buf); +#else + { + struct tm local = buf; + char zone[100]; + int gmtoff; + strftime(zone, sizeof(buf), "%Z", &buf); + gmtoff = timegm(&buf) - when; + return tmtotuple(&local, zone, gmtoff); + } +#endif } PyDoc_STRVAR(localtime_doc, @@ -1146,6 +1180,27 @@ PyDoc_STRVAR(get_clock_info_doc, Get information of the specified clock."); static void +get_zone(char *zone, int n, struct tm *p) +{ +#ifdef HAVE_STRUCT_TM_TM_ZONE + strncpy(zone, p->tm_zone ? p->tm_zone : " ", n); +#else + tzset(); + strftime(zone, n, "%Z", p); +#endif +} + +static int +get_gmtoff(time_t t, struct tm *p) +{ +#ifdef HAVE_STRUCT_TM_TM_ZONE + return p->tm_gmtoff; +#else + return timegm(p) - t; +#endif +} + +static void PyInit_timezone(PyObject *m) { /* This code moved from PyInit_time wholesale to allow calling it from time_tzset. In the future, some parts of it can be moved back @@ -1177,7 +1232,6 @@ PyInit_timezone(PyObject *m) { otz1 = PyUnicode_DecodeLocale(tzname[1], "surrogateescape"); PyModule_AddObject(m, "tzname", Py_BuildValue("(NN)", otz0, otz1)); #else /* !HAVE_TZNAME || __GLIBC__ || __CYGWIN__*/ -#ifdef HAVE_STRUCT_TM_TM_ZONE { #define YEAR ((time_t)((365 * 24 + 6) * 3600)) time_t t; @@ -1186,13 +1240,13 @@ PyInit_timezone(PyObject *m) { char janname[10], julyname[10]; t = (time((time_t *)0) / YEAR) * YEAR; p = localtime(&t); - janzone = -p->tm_gmtoff; - strncpy(janname, p->tm_zone ? p->tm_zone : " ", 9); + get_zone(janname, 9, p); + janzone = -get_gmtoff(t, p); janname[9] = '\0'; t += YEAR/2; p = localtime(&t); - julyzone = -p->tm_gmtoff; - strncpy(julyname, p->tm_zone ? p->tm_zone : " ", 9); + get_zone(julyname, 9, p); + julyzone = -get_gmtoff(t, p); julyname[9] = '\0'; if( janzone < julyzone ) { @@ -1214,8 +1268,6 @@ PyInit_timezone(PyObject *m) { janname, julyname)); } } -#else -#endif /* HAVE_STRUCT_TM_TM_ZONE */ #ifdef __CYGWIN__ tzset(); PyModule_AddIntConstant(m, "timezone", _timezone); @@ -1225,25 +1277,6 @@ PyInit_timezone(PyObject *m) { Py_BuildValue("(zz)", _tzname[0], _tzname[1])); #endif /* __CYGWIN__ */ #endif /* !HAVE_TZNAME || __GLIBC__ || __CYGWIN__*/ - -#if defined(HAVE_CLOCK_GETTIME) - PyModule_AddIntMacro(m, CLOCK_REALTIME); -#ifdef CLOCK_MONOTONIC - PyModule_AddIntMacro(m, CLOCK_MONOTONIC); -#endif -#ifdef CLOCK_MONOTONIC_RAW - PyModule_AddIntMacro(m, CLOCK_MONOTONIC_RAW); -#endif -#ifdef CLOCK_HIGHRES - PyModule_AddIntMacro(m, CLOCK_HIGHRES); -#endif -#ifdef CLOCK_PROCESS_CPUTIME_ID - PyModule_AddIntMacro(m, CLOCK_PROCESS_CPUTIME_ID); -#endif -#ifdef CLOCK_THREAD_CPUTIME_ID - PyModule_AddIntMacro(m, CLOCK_THREAD_CPUTIME_ID); -#endif -#endif /* HAVE_CLOCK_GETTIME */ } @@ -1350,17 +1383,32 @@ PyInit_time(void) /* Set, or reset, module variables like time.timezone */ PyInit_timezone(m); +#if defined(HAVE_CLOCK_GETTIME) + PyModule_AddIntMacro(m, CLOCK_REALTIME); +#ifdef CLOCK_MONOTONIC + PyModule_AddIntMacro(m, CLOCK_MONOTONIC); +#endif +#ifdef CLOCK_MONOTONIC_RAW + PyModule_AddIntMacro(m, CLOCK_MONOTONIC_RAW); +#endif +#ifdef CLOCK_HIGHRES + PyModule_AddIntMacro(m, CLOCK_HIGHRES); +#endif +#ifdef CLOCK_PROCESS_CPUTIME_ID + PyModule_AddIntMacro(m, CLOCK_PROCESS_CPUTIME_ID); +#endif +#ifdef CLOCK_THREAD_CPUTIME_ID + PyModule_AddIntMacro(m, CLOCK_THREAD_CPUTIME_ID); +#endif +#endif /* HAVE_CLOCK_GETTIME */ + if (!initialized) { if (PyStructSequence_InitType2(&StructTimeType, &struct_time_type_desc) < 0) return NULL; } Py_INCREF(&StructTimeType); -#ifdef HAVE_STRUCT_TM_TM_ZONE PyModule_AddIntConstant(m, "_STRUCT_TM_ITEMS", 11); -#else - PyModule_AddIntConstant(m, "_STRUCT_TM_ITEMS", 9); -#endif PyModule_AddObject(m, "struct_time", (PyObject*) &StructTimeType); initialized = 1; return m; -- cgit v0.12 From 654a7bdf572aa1732d31b12c1c814ead0321027b Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Sun, 11 Sep 2016 20:19:32 -0700 Subject: Adds missing assert suppression. --- Modules/posixmodule.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index ce64684..43e3c77 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5030,11 +5030,13 @@ os_spawnv_impl(PyObject *module, int mode, path_t *path, PyObject *argv) mode = _P_OVERLAY; Py_BEGIN_ALLOW_THREADS + _Py_BEGIN_SUPPRESS_IPH #ifdef HAVE_WSPAWNV spawnval = _wspawnv(mode, path->wide, argvlist); #else spawnval = _spawnv(mode, path->narrow, argvlist); #endif + _Py_END_SUPPRESS_IPH Py_END_ALLOW_THREADS free_string_array(argvlist, argc); @@ -5122,11 +5124,13 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv, mode = _P_OVERLAY; Py_BEGIN_ALLOW_THREADS + _Py_BEGIN_SUPPRESS_IPH #ifdef HAVE_WSPAWNV spawnval = _wspawnve(mode, path->wide, argvlist, envlist); #else spawnval = _spawnve(mode, path->narrow, argvlist, envlist); #endif + _Py_END_SUPPRESS_IPH Py_END_ALLOW_THREADS if (spawnval == -1) -- cgit v0.12 From e7da2f8380fbd92d5978e9fb8ce317ecfd17d12e Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Sun, 11 Sep 2016 20:19:35 -0700 Subject: Make PGO use usual build directory on Windows. --- PCbuild/pyproject.props | 1 - PCbuild/python.props | 1 - Tools/msi/buildrelease.bat | 9 +-------- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props index d1ac998..543b4ca 100644 --- a/PCbuild/pyproject.props +++ b/PCbuild/pyproject.props @@ -7,7 +7,6 @@ $(OutDir)\ $(MSBuildThisFileDirectory)obj\ $(Py_IntDir)\$(ArchName)_$(Configuration)\$(ProjectName)\ - $(Py_IntDir)\$(ArchName)_PGO\$(ProjectName)\ $(ProjectName) $(TargetName)$(PyDebugExt) false diff --git a/PCbuild/python.props b/PCbuild/python.props index 0150098..2b9b903 100644 --- a/PCbuild/python.props +++ b/PCbuild/python.props @@ -25,7 +25,6 @@ --> amd64 win32 - $(ArchName)-pgo $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\..\)) diff --git a/Tools/msi/buildrelease.bat b/Tools/msi/buildrelease.bat index 1af5ac1..710acac 100644 --- a/Tools/msi/buildrelease.bat +++ b/Tools/msi/buildrelease.bat @@ -111,16 +111,10 @@ if "%1" EQU "x86" ( set BUILD_PLAT=Win32 set OUTDIR_PLAT=win32 set OBJDIR_PLAT=x86 -) else if "%~2" NEQ "" ( - call "%PCBUILD%env.bat" amd64 - set PGO=%~2 - set BUILD=%PCBUILD%amd64-pgo\ - set BUILD_PLAT=x64 - set OUTDIR_PLAT=amd64 - set OBJDIR_PLAT=x64 ) else ( call "%PCBUILD%env.bat" amd64 set BUILD=%PCBUILD%amd64\ + set PGO=%~2 set BUILD_PLAT=x64 set OUTDIR_PLAT=amd64 set OBJDIR_PLAT=x64 @@ -177,7 +171,6 @@ if not "%SKIPBUILD%" EQU "1" ( ) set BUILDOPTS=/p:Platform=%1 /p:BuildForRelease=true /p:DownloadUrl=%DOWNLOAD_URL% /p:DownloadUrlBase=%DOWNLOAD_URL_BASE% /p:ReleaseUri=%RELEASE_URI% -if "%PGO%" NEQ "" set BUILDOPTS=%BUILDOPTS% /p:PGOBuildPath=%BUILD% msbuild "%D%bundle\releaselocal.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=true if errorlevel 1 exit /B msbuild "%D%bundle\releaseweb.wixproj" /t:Rebuild %BUILDOPTS% %CERTOPTS% /p:RebuildAll=false -- cgit v0.12 From 59da4b324f08247d389a4c89e1e84243f41c489f Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Mon, 12 Sep 2016 07:16:43 +0300 Subject: Issue #28037: Use sqlite3_get_autocommit() instead of setting Connection->inTransaction manually Patch adapted from https://github.com/ghaering/pysqlite/commit/9b79188edbc50faa24dc178afe24a10454f3fcad --- Misc/NEWS | 3 +++ Modules/_sqlite/connection.c | 31 +++++++++++++++++-------------- Modules/_sqlite/connection.h | 4 ---- Modules/_sqlite/cursor.c | 9 --------- 4 files changed, 20 insertions(+), 27 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index 35f1d65..1c253b6 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -143,6 +143,9 @@ Core and Builtins Library ------- +- Issue #28037: Use sqlite3_get_autocommit() instead of setting + Connection->inTransaction manually. + - Issue #25283: Attributes tm_gmtoff and tm_zone are now available on all platforms in the return values of time.localtime() and time.gmtime(). diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index aca66fe..d29fafe 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -165,7 +165,6 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject self->statement_cache->decref_factory = 0; Py_DECREF(self); - self->inTransaction = 0; self->detect_types = detect_types; self->timeout = timeout; (void)sqlite3_busy_timeout(self->db, (int)(timeout*1000)); @@ -385,9 +384,7 @@ PyObject* _pysqlite_connection_begin(pysqlite_Connection* self) } rc = pysqlite_step(statement, self); - if (rc == SQLITE_DONE) { - self->inTransaction = 1; - } else { + if (rc != SQLITE_DONE) { _pysqlite_seterror(self->db, statement); } @@ -418,7 +415,7 @@ PyObject* pysqlite_connection_commit(pysqlite_Connection* self, PyObject* args) return NULL; } - if (self->inTransaction) { + if (!sqlite3_get_autocommit(self->db)) { Py_BEGIN_ALLOW_THREADS rc = sqlite3_prepare(self->db, "COMMIT", -1, &statement, &tail); @@ -429,9 +426,7 @@ PyObject* pysqlite_connection_commit(pysqlite_Connection* self, PyObject* args) } rc = pysqlite_step(statement, self); - if (rc == SQLITE_DONE) { - self->inTransaction = 0; - } else { + if (rc != SQLITE_DONE) { _pysqlite_seterror(self->db, statement); } @@ -463,7 +458,7 @@ PyObject* pysqlite_connection_rollback(pysqlite_Connection* self, PyObject* args return NULL; } - if (self->inTransaction) { + if (!sqlite3_get_autocommit(self->db)) { pysqlite_do_all_statements(self, ACTION_RESET, 1); Py_BEGIN_ALLOW_THREADS @@ -475,9 +470,7 @@ PyObject* pysqlite_connection_rollback(pysqlite_Connection* self, PyObject* args } rc = pysqlite_step(statement, self); - if (rc == SQLITE_DONE) { - self->inTransaction = 0; - } else { + if (rc != SQLITE_DONE) { _pysqlite_seterror(self->db, statement); } @@ -1158,6 +1151,17 @@ static PyObject* pysqlite_connection_get_total_changes(pysqlite_Connection* self } } +static PyObject* pysqlite_connection_get_in_transaction(pysqlite_Connection* self, void* unused) +{ + if (!pysqlite_check_connection(self)) { + return NULL; + } + if (!sqlite3_get_autocommit(self->db)) { + Py_RETURN_TRUE; + } + Py_RETURN_FALSE; +} + static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, PyObject* isolation_level) { if (isolation_level == Py_None) { @@ -1168,7 +1172,6 @@ static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, Py Py_DECREF(res); self->begin_statement = NULL; - self->inTransaction = 0; } else { const char * const *candidate; PyObject *uppercase_level; @@ -1606,6 +1609,7 @@ PyDoc_STR("SQLite database connection object."); static PyGetSetDef connection_getset[] = { {"isolation_level", (getter)pysqlite_connection_get_isolation_level, (setter)pysqlite_connection_set_isolation_level}, {"total_changes", (getter)pysqlite_connection_get_total_changes, (setter)0}, + {"in_transaction", (getter)pysqlite_connection_get_in_transaction, (setter)0}, {NULL} }; @@ -1667,7 +1671,6 @@ static struct PyMemberDef connection_members[] = {"NotSupportedError", T_OBJECT, offsetof(pysqlite_Connection, NotSupportedError), READONLY}, {"row_factory", T_OBJECT, offsetof(pysqlite_Connection, row_factory)}, {"text_factory", T_OBJECT, offsetof(pysqlite_Connection, text_factory)}, - {"in_transaction", T_BOOL, offsetof(pysqlite_Connection, inTransaction), READONLY}, {NULL} }; diff --git a/Modules/_sqlite/connection.h b/Modules/_sqlite/connection.h index adbfb54..2860a0c 100644 --- a/Modules/_sqlite/connection.h +++ b/Modules/_sqlite/connection.h @@ -37,10 +37,6 @@ typedef struct PyObject_HEAD sqlite3* db; - /* 1 if we are currently within a transaction, i. e. if a BEGIN has been - * issued */ - char inTransaction; - /* the type detection mode. Only 0, PARSE_DECLTYPES, PARSE_COLNAMES or a * bitwise combination thereof makes sense */ int detect_types; diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 020f931..c7169f6 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -644,15 +644,6 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* } error: - /* just to be sure (implicit ROLLBACKs with ON CONFLICT ROLLBACK/OR - * ROLLBACK could have happened */ - #ifdef SQLITE_VERSION_NUMBER - #if SQLITE_VERSION_NUMBER >= 3002002 - if (self->connection && self->connection->db) - self->connection->inTransaction = !sqlite3_get_autocommit(self->connection->db); - #endif - #endif - Py_XDECREF(parameters); Py_XDECREF(parameters_iter); Py_XDECREF(parameters_list); -- cgit v0.12 From 8a2150aae6db4d664c96a038ef6abacd4bcbcdc9 Mon Sep 17 00:00:00 2001 From: Ned Deily Date: Mon, 12 Sep 2016 00:26:20 -0400 Subject: Issue #28095: Temporarily disable part of test_startup_imports on OS X. --- Lib/test/test_site.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index 0720230..9afa56e 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -470,7 +470,9 @@ class StartupImportTests(unittest.TestCase): 'heapq', 'itertools', 'keyword', 'operator', 'reprlib', 'types', 'weakref' }.difference(sys.builtin_module_names) - self.assertFalse(modules.intersection(collection_mods), stderr) + # http://bugs.python.org/issue28095 + if sys.platform != 'darwin': + self.assertFalse(modules.intersection(collection_mods), stderr) if __name__ == "__main__": -- cgit v0.12 From ed6224ee0ceb0118cbc7f04278d8f2fefddddddd Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Mon, 12 Sep 2016 07:47:04 +0300 Subject: Issue #28045: Fix comment in range_contains_long() Patch by wim glenn. --- Objects/rangeobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index 0e9eb20..288be4f 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -406,7 +406,7 @@ range_contains_long(rangeobject *r, PyObject *ob) tmp2 = PyNumber_Remainder(tmp1, r->step); if (tmp2 == NULL) goto end; - /* result = (int(ob) - start % step) == 0 */ + /* result = ((int(ob) - start) % step) == 0 */ result = PyObject_RichCompareBool(tmp2, zero, Py_EQ); end: Py_XDECREF(tmp1); -- cgit v0.12 From 34b74fffb32493b49b262ed9122d798d373477b7 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Mon, 12 Sep 2016 08:00:01 +0300 Subject: Add missing versionadded directives --- Doc/library/dis.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 0a64d46..3c6c0fd 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -614,6 +614,8 @@ iterations of the loop. or module body contains :term:`variable annotations ` statically. + .. versionadded:: 3.6 + .. opcode:: IMPORT_STAR Loads all symbols not starting with ``'_'`` directly from the module TOS to @@ -900,6 +902,8 @@ All of the following opcodes use their arguments. Stores TOS as ``locals()['__annotations__'][co_names[namei]] = TOS``. + .. versionadded:: 3.6 + .. opcode:: LOAD_CLOSURE (i) -- cgit v0.12 From 4103e4dfbce8b6d9579565ab64868a721b01d2a1 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 11 Sep 2016 22:02:28 -0700 Subject: Issue #28071: Add early-out for differencing from an empty set. --- Misc/NEWS | 2 ++ Objects/setobject.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index 1c253b6..083b33f 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -33,6 +33,8 @@ Core and Builtins - Issue #28046: Remove platform-specific directories from sys.path. +- Issue #28071: Add early-out for differencing from an empty set. + - Issue #25758: Prevents zipimport from unnecessarily encoding a filename (patch by Eryk Sun) diff --git a/Objects/setobject.c b/Objects/setobject.c index 6dd403f..5846045 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -1476,6 +1476,10 @@ PyDoc_STRVAR(isdisjoint_doc, static int set_difference_update_internal(PySetObject *so, PyObject *other) { + if (PySet_GET_SIZE(so) == 0) { + return 0; + } + if ((PyObject *)so == other) return set_clear_internal(so); @@ -1550,6 +1554,10 @@ set_difference(PySetObject *so, PyObject *other) Py_ssize_t pos = 0; int rv; + if (PySet_GET_SIZE(so) == 0) { + return set_copy(so); + } + if (!PyAnySet_Check(other) && !PyDict_CheckExact(other)) { return set_copy_and_difference(so, other); } -- cgit v0.12 From 88057171f057dad4d855155c975d3e7c85cd23e3 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 11 Sep 2016 22:45:53 -0700 Subject: Revert part of 3471a3515827 that caused a performance regression --- Modules/_collectionsmodule.c | 52 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 1675102..9ed6f14b 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -403,10 +403,28 @@ deque_extend(dequeobject *deque, PyObject *iterable) iternext = *Py_TYPE(it)->tp_iternext; while ((item = iternext(it)) != NULL) { - if (deque_append_internal(deque, item, maxlen) < 0) { - Py_DECREF(item); - Py_DECREF(it); - return NULL; + if (deque->rightindex == BLOCKLEN - 1) { + block *b = newblock(); + if (b == NULL) { + Py_DECREF(item); + Py_DECREF(it); + return NULL; + } + b->leftlink = deque->rightblock; + CHECK_END(deque->rightblock->rightlink); + deque->rightblock->rightlink = b; + deque->rightblock = b; + MARK_END(b->rightlink); + deque->rightindex = -1; + } + Py_SIZE(deque)++; + deque->rightindex++; + deque->rightblock->data[deque->rightindex] = item; + if (NEEDS_TRIM(deque, maxlen)) { + PyObject *olditem = deque_popleft(deque, NULL); + Py_DECREF(olditem); + } else { + deque->state++; } } return finalize_iterator(it); @@ -450,10 +468,28 @@ deque_extendleft(dequeobject *deque, PyObject *iterable) iternext = *Py_TYPE(it)->tp_iternext; while ((item = iternext(it)) != NULL) { - if (deque_appendleft_internal(deque, item, maxlen) < 0) { - Py_DECREF(item); - Py_DECREF(it); - return NULL; + if (deque->leftindex == 0) { + block *b = newblock(); + if (b == NULL) { + Py_DECREF(item); + Py_DECREF(it); + return NULL; + } + b->rightlink = deque->leftblock; + CHECK_END(deque->leftblock->leftlink); + deque->leftblock->leftlink = b; + deque->leftblock = b; + MARK_END(b->leftlink); + deque->leftindex = BLOCKLEN; + } + Py_SIZE(deque)++; + deque->leftindex--; + deque->leftblock->data[deque->leftindex] = item; + if (NEEDS_TRIM(deque, maxlen)) { + PyObject *olditem = deque_pop(deque, NULL); + Py_DECREF(olditem); + } else { + deque->state++; } } return finalize_iterator(it); -- cgit v0.12 From 4b73676c3d260b37b91dedbc0b286c4e779350e4 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Mon, 12 Sep 2016 01:50:03 -0400 Subject: Issue #15308: Add 'interrupt execution' (^C) to Shell menu. Patch by Roger Serwy, updated by Bayard Randel. --- Doc/library/idle.rst | 3 +++ Lib/idlelib/Bindings.py | 2 ++ Lib/idlelib/README.txt | 11 +++++---- Lib/idlelib/help.html | 62 ++++++++++++++++++++++++++++++++----------------- 4 files changed, 52 insertions(+), 26 deletions(-) diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst index ffe8426..a629bc5 100644 --- a/Doc/library/idle.rst +++ b/Doc/library/idle.rst @@ -226,6 +226,9 @@ View Last Restart Restart Shell Restart the shell to clean the environment. +Interrupt Execution + Stop a running program. + Debug menu (Shell window only) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/Lib/idlelib/Bindings.py b/Lib/idlelib/Bindings.py index ab25ff1..e19a279 100644 --- a/Lib/idlelib/Bindings.py +++ b/Lib/idlelib/Bindings.py @@ -69,6 +69,8 @@ menudefs = [ ('shell', [ ('_View Last Restart', '<>'), ('_Restart Shell', '<>'), + None, + ('_Interrupt Execution', '<>'), ]), ('debug', [ ('_Go to File/Line', '<>'), diff --git a/Lib/idlelib/README.txt b/Lib/idlelib/README.txt index 7bf74c0..bc169c8 100644 --- a/Lib/idlelib/README.txt +++ b/Lib/idlelib/README.txt @@ -161,14 +161,15 @@ Edit Show surrounding parens # ParenMatch (& Hyperparser) Shell # PyShell - View Last Restart # PyShell.? - Restart Shell # PyShell.? + View Last Restart # PyShell.PyShell.view_restart_mark + Restart Shell # PyShell.PyShell.restart_shell + Interrupt Execution # pyshell.PyShell.cancel_callback Debug (Shell only) Go to File/Line - Debugger # Debugger, RemoteDebugger - Stack Viewer # StackViewer - Auto-open Stack Viewer # StackViewer + Debugger # Debugger, RemoteDebugger, PyShell.toggle_debuger + Stack Viewer # StackViewer, PyShell.open_stack_viewer + Auto-open Stack Viewer # StackViewer Format (Editor only) Indent Region diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html index 7860bfb..ffc03c4 100644 --- a/Lib/idlelib/help.html +++ b/Lib/idlelib/help.html @@ -65,6 +65,21 @@ +
  • + + + + + | +
  • + @@ -240,6 +255,8 @@ line.
    Scroll the shell window to the last Shell restart.
    Restart Shell
    Restart the shell to clean the environment.
    +
    Interrupt Execution
    +
    Stop a running program.
    @@ -649,26 +666,14 @@ are currently:

    Next topic

    25.6. Other Graphical User Interface Packages

    -

    This Page

    - - - - +
    +

    This Page

    + +
    @@ -697,6 +702,21 @@ are currently:

    +
  • + + + + + | +
  • +