https://github.com/python/cpython/commit/ab71f8b793f7b42853ccd2a127ae7720ad…
commit: ab71f8b793f7b42853ccd2a127ae7720adc5bcb4
branch: master
author: Victor Stinner <vstinner(a)redhat.com>
committer: GitHub <noreply(a)github.com>
date: 2019-03-01T00:08:03+01:00
summary:
bpo-29571: Fix test_re.test_locale_flag() (GH-12099)
Use locale.getpreferredencoding() rather than locale.getlocale() to
get the locale encoding. With some locales, locale.getlocale()
returns the wrong encoding.
For example, on Fedora 29, locale.getlocale() returns ISO-8859-1
encoding for the "en_IN" locale, whereas
locale.getpreferredencoding() reports the correct encoding: UTF-8.
files:
A Misc/NEWS.d/next/Tests/2019-02-28-18-33-29.bpo-29571.r6b9fr.rst
M Lib/test/test_re.py
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 797d85d0629c..0a77e6fe9edc 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -1552,8 +1552,7 @@ def test_ascii_and_unicode_flag(self):
self.assertRaises(re.error, re.compile, r'(?au)\w')
def test_locale_flag(self):
- import locale
- _, enc = locale.getlocale(locale.LC_CTYPE)
+ enc = locale.getpreferredencoding()
# Search non-ASCII letter
for i in range(128, 256):
try:
diff --git a/Misc/NEWS.d/next/Tests/2019-02-28-18-33-29.bpo-29571.r6b9fr.rst b/Misc/NEWS.d/next/Tests/2019-02-28-18-33-29.bpo-29571.r6b9fr.rst
new file mode 100644
index 000000000000..0f40c98514ce
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2019-02-28-18-33-29.bpo-29571.r6b9fr.rst
@@ -0,0 +1,3 @@
+Fix ``test_re.test_locale_flag()``: use ``locale.getpreferredencoding()``
+rather than ``locale.getlocale()`` to get the locale encoding. With some
+locales, ``locale.getlocale()`` returns the wrong encoding.
https://github.com/python/cpython/commit/7dc322f8a5deecb931e66dceb0cc0a8268…
commit: 7dc322f8a5deecb931e66dceb0cc0a826887c661
branch: 3.7
author: Cheryl Sabella <cheryl.sabella(a)gmail.com>
committer: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
date: 2019-02-28T10:11:35-08:00
summary:
[3.7] Add versionadded directives to ssl.minimum_version and ssl.maxi… (GH-12101)
…mum_version (GH-11894).
(cherry picked from commit ae2ea33d5da34a777e77d489b700ff45d753934f)
Co-authored-by: Zhiming Wang <i(a)zhimingwang.org>
files:
M Doc/library/ssl.rst
diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
index 0835e9ae04e6..fba9d5a63dd0 100644
--- a/Doc/library/ssl.rst
+++ b/Doc/library/ssl.rst
@@ -1328,12 +1328,12 @@ SSL sockets also have the following additional methods and attributes:
If any precondition isn't met (e.g. not TLS 1.3, PHA not enabled), an
:exc:`SSLError` is raised.
- .. versionadded:: 3.7.1
-
.. note::
Only available with OpenSSL 1.1.1 and TLS 1.3 enabled. Without TLS 1.3
support, the method raises :exc:`NotImplementedError`.
+ .. versionadded:: 3.7.1
+
.. method:: SSLSocket.version()
Return the actual SSL protocol version negotiated by the connection
@@ -1922,6 +1922,8 @@ to speed up repeated connections from the same clients.
This attribute is not available unless the ssl module is compiled
with OpenSSL 1.1.0g or newer.
+ .. versionadded:: 3.7
+
.. attribute:: SSLContext.minimum_version
Like :attr:`SSLContext.maximum_version` except it is the lowest
@@ -1932,6 +1934,8 @@ to speed up repeated connections from the same clients.
This attribute is not available unless the ssl module is compiled
with OpenSSL 1.1.0g or newer.
+ .. versionadded:: 3.7
+
.. attribute:: SSLContext.options
An integer representing the set of SSL options enabled on this context.
@@ -1965,12 +1969,12 @@ to speed up repeated connections from the same clients.
:meth:`SSLSocket.verify_client_post_handshake` is called and some I/O is
performed.
- .. versionadded:: 3.7.1
-
.. note::
Only available with OpenSSL 1.1.1 and TLS 1.3 enabled. Without TLS 1.3
support, the property value is None and can't be modified
+ .. versionadded:: 3.7.1
+
.. attribute:: SSLContext.protocol
The protocol version chosen when constructing the context. This attribute
@@ -1982,11 +1986,11 @@ to speed up repeated connections from the same clients.
subject common name in the absence of a subject alternative name
extension (default: true).
- .. versionadded:: 3.7
-
.. note::
Only writeable with OpenSSL 1.1.0 or higher.
+ .. versionadded:: 3.7
+
.. attribute:: SSLContext.verify_flags
The flags for certificate verification operations. You can set flags like
https://github.com/python/cpython/commit/ef17fdbc1c274dc84c2f611c40449ab848…
commit: ef17fdbc1c274dc84c2f611c40449ab84824607e
branch: master
author: Raymond Hettinger <rhettinger(a)users.noreply.github.com>
committer: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
date: 2019-02-28T09:16:25-08:00
summary:
bpo-36018: Add special value tests and make minor tweaks to the docs (GH-12096)
https://bugs.python.org/issue36018
files:
M Doc/library/statistics.rst
M Lib/statistics.py
M Lib/test/test_statistics.py
diff --git a/Doc/library/statistics.rst b/Doc/library/statistics.rst
index a0d4d3910220..8d961b7ca5b1 100644
--- a/Doc/library/statistics.rst
+++ b/Doc/library/statistics.rst
@@ -482,9 +482,9 @@ of applications in statistics, including simulations and hypothesis testing.
.. class:: NormalDist(mu=0.0, sigma=1.0)
Returns a new *NormalDist* object where *mu* represents the `arithmetic
- mean <https://en.wikipedia.org/wiki/Arithmetic_mean>`_ of data and *sigma*
+ mean <https://en.wikipedia.org/wiki/Arithmetic_mean>`_ and *sigma*
represents the `standard deviation
- <https://en.wikipedia.org/wiki/Standard_deviation>`_ of the data.
+ <https://en.wikipedia.org/wiki/Standard_deviation>`_.
If *sigma* is negative, raises :exc:`StatisticsError`.
@@ -579,7 +579,7 @@ of applications in statistics, including simulations and hypothesis testing.
:class:`NormalDist` Examples and Recipes
----------------------------------------
-A :class:`NormalDist` readily solves classic probability problems.
+:class:`NormalDist` readily solves classic probability problems.
For example, given `historical data for SAT exams
<https://blog.prepscholar.com/sat-standard-deviation>`_ showing that scores
diff --git a/Lib/statistics.py b/Lib/statistics.py
index bab585750d91..e917a5dddd8b 100644
--- a/Lib/statistics.py
+++ b/Lib/statistics.py
@@ -735,7 +735,7 @@ def pdf(self, x):
return exp((x - self.mu)**2.0 / (-2.0*variance)) / sqrt(tau * variance)
def cdf(self, x):
- 'Cumulative density function: P(X <= x)'
+ 'Cumulative distribution function: P(X <= x)'
if not self.sigma:
raise StatisticsError('cdf() not defined when sigma is zero')
return 0.5 * (1.0 + erf((x - self.mu) / (self.sigma * sqrt(2.0))))
diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py
index d35cdd8420a3..4adc5e4cbf4a 100644
--- a/Lib/test/test_statistics.py
+++ b/Lib/test/test_statistics.py
@@ -2113,6 +2113,10 @@ def test_pdf(self):
Y = NormalDist(100, 0)
with self.assertRaises(statistics.StatisticsError):
Y.pdf(90)
+ # Special values
+ self.assertEqual(X.pdf(float('-Inf')), 0.0)
+ self.assertEqual(X.pdf(float('Inf')), 0.0)
+ self.assertTrue(math.isnan(X.pdf(float('NaN'))))
def test_cdf(self):
NormalDist = statistics.NormalDist
@@ -2127,6 +2131,10 @@ def test_cdf(self):
Y = NormalDist(100, 0)
with self.assertRaises(statistics.StatisticsError):
Y.cdf(90)
+ # Special values
+ self.assertEqual(X.cdf(float('-Inf')), 0.0)
+ self.assertEqual(X.cdf(float('Inf')), 1.0)
+ self.assertTrue(math.isnan(X.cdf(float('NaN'))))
def test_properties(self):
X = statistics.NormalDist(100, 15)
https://github.com/python/cpython/commit/ae2ea33d5da34a777e77d489b700ff45d7…
commit: ae2ea33d5da34a777e77d489b700ff45d753934f
branch: master
author: Zhiming Wang <i(a)zhimingwang.org>
committer: Cheryl Sabella <cheryl.sabella(a)gmail.com>
date: 2019-02-28T12:15:04-05:00
summary:
Add versionadded directives to ssl.minimum_version and ssl.maximum_version (GH-11894)
files:
M Doc/library/ssl.rst
diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
index 4817bba7d4f2..6a441983f888 100644
--- a/Doc/library/ssl.rst
+++ b/Doc/library/ssl.rst
@@ -1328,12 +1328,12 @@ SSL sockets also have the following additional methods and attributes:
If any precondition isn't met (e.g. not TLS 1.3, PHA not enabled), an
:exc:`SSLError` is raised.
- .. versionadded:: 3.8
-
.. note::
Only available with OpenSSL 1.1.1 and TLS 1.3 enabled. Without TLS 1.3
support, the method raises :exc:`NotImplementedError`.
+ .. versionadded:: 3.8
+
.. method:: SSLSocket.version()
Return the actual SSL protocol version negotiated by the connection
@@ -1922,6 +1922,8 @@ to speed up repeated connections from the same clients.
This attribute is not available unless the ssl module is compiled
with OpenSSL 1.1.0g or newer.
+ .. versionadded:: 3.7
+
.. attribute:: SSLContext.minimum_version
Like :attr:`SSLContext.maximum_version` except it is the lowest
@@ -1932,6 +1934,8 @@ to speed up repeated connections from the same clients.
This attribute is not available unless the ssl module is compiled
with OpenSSL 1.1.0g or newer.
+ .. versionadded:: 3.7
+
.. attribute:: SSLContext.options
An integer representing the set of SSL options enabled on this context.
@@ -1965,12 +1969,12 @@ to speed up repeated connections from the same clients.
:meth:`SSLSocket.verify_client_post_handshake` is called and some I/O is
performed.
- .. versionadded:: 3.8
-
.. note::
Only available with OpenSSL 1.1.1 and TLS 1.3 enabled. Without TLS 1.3
support, the property value is None and can't be modified
+ .. versionadded:: 3.8
+
.. attribute:: SSLContext.protocol
The protocol version chosen when constructing the context. This attribute
@@ -1982,11 +1986,11 @@ to speed up repeated connections from the same clients.
subject common name in the absence of a subject alternative name
extension (default: true).
- .. versionadded:: 3.7
-
.. note::
Only writeable with OpenSSL 1.1.0 or higher.
+ .. versionadded:: 3.7
+
.. attribute:: SSLContext.verify_flags
The flags for certificate verification operations. You can set flags like
https://github.com/python/cpython/commit/4cbea518a0827d23a41a45b03a8af729c2…
commit: 4cbea518a0827d23a41a45b03a8af729c2f16605
branch: master
author: Victor Stinner <vstinner(a)redhat.com>
committer: GitHub <noreply(a)github.com>
date: 2019-02-28T17:48:38+01:00
summary:
bpo-36146: Refactor setup.py (GH-12093)
* Rename globals to upper case to better distinguish if a variable is
global or local:
* Rename cross_compiling to CROSS_COMPILING
* Rename host_platform to HOST_PLATFORM
* Rename disabled_module_list to DISABLED_MODULE_LIST
* Add MS_WINDOWS, CYGWIN and MACOS constants.
* Use booleans: replace "return 0" with "return False"
and replace "return 1" with "return True"
files:
M setup.py
diff --git a/setup.py b/setup.py
index b04208602f3b..2fef0ad468a4 100644
--- a/setup.py
+++ b/setup.py
@@ -16,7 +16,7 @@
from distutils.command.build_scripts import build_scripts
from distutils.spawn import find_executable
-cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ
+CROSS_COMPILING = "_PYTHON_HOST_PLATFORM" in os.environ
# Set common compiler and linker flags derived from the Makefile,
# reserved for building the interpreter and the stdlib modules.
@@ -42,15 +42,18 @@ def get_platform():
if sys.platform.startswith('osf1'):
return 'osf1'
return sys.platform
-host_platform = get_platform()
+HOST_PLATFORM = get_platform()
+MS_WINDOWS = (HOST_PLATFORM == 'win32')
+CYGWIN = (HOST_PLATFORM == 'cygwin')
+MACOS = (HOST_PLATFORM == 'darwin')
-VXWORKS = ('vxworks' in host_platform)
+VXWORKS = ('vxworks' in HOST_PLATFORM)
# Were we compiled --with-pydebug or with #define Py_DEBUG?
COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
# This global variable is used to hold the list of modules to be disabled.
-disabled_module_list = []
+DISABLED_MODULE_LIST = []
def add_dir_to_list(dirlist, dir):
"""Add the directory 'dir' to the list 'dirlist' (after any relative
@@ -124,7 +127,7 @@ def find_file(filename, std_dirs, paths):
'paths' is a list of additional locations to check; if the file is
found in one of them, the resulting list will contain the directory.
"""
- if host_platform == 'darwin':
+ if MACOS:
# Honor the MacOSX SDK setting when one was specified.
# An SDK is a directory with the same structure as a real
# system, but with only header files and libraries.
@@ -134,7 +137,7 @@ def find_file(filename, std_dirs, paths):
for dir in std_dirs:
f = os.path.join(dir, filename)
- if host_platform == 'darwin' and is_macosx_sdk_path(dir):
+ if MACOS and is_macosx_sdk_path(dir):
f = os.path.join(sysroot, dir[1:], filename)
if os.path.exists(f): return []
@@ -143,7 +146,7 @@ def find_file(filename, std_dirs, paths):
for dir in paths:
f = os.path.join(dir, filename)
- if host_platform == 'darwin' and is_macosx_sdk_path(dir):
+ if MACOS and is_macosx_sdk_path(dir):
f = os.path.join(sysroot, dir[1:], filename)
if os.path.exists(f):
@@ -157,7 +160,7 @@ def find_library_file(compiler, libname, std_dirs, paths):
if result is None:
return None
- if host_platform == 'darwin':
+ if MACOS:
sysroot = macosx_sdk_root()
# Check whether the found file is in one of the standard directories
@@ -166,7 +169,7 @@ def find_library_file(compiler, libname, std_dirs, paths):
# Ensure path doesn't end with path separator
p = p.rstrip(os.sep)
- if host_platform == 'darwin' and is_macosx_sdk_path(p):
+ if MACOS and is_macosx_sdk_path(p):
# Note that, as of Xcode 7, Apple SDKs may contain textual stub
# libraries with .tbd extensions rather than the normal .dylib
# shared libraries installed in /. The Apple compiler tool
@@ -195,7 +198,7 @@ def find_library_file(compiler, libname, std_dirs, paths):
# Ensure path doesn't end with path separator
p = p.rstrip(os.sep)
- if host_platform == 'darwin' and is_macosx_sdk_path(p):
+ if MACOS and is_macosx_sdk_path(p):
if os.path.join(sysroot, p[1:]) == dirname:
return [ p ]
@@ -236,7 +239,7 @@ def build_extensions(self):
# Remove modules that are present on the disabled list
extensions = [ext for ext in self.extensions
- if ext.name not in disabled_module_list]
+ if ext.name not in DISABLED_MODULE_LIST]
# move ctypes to the end, it depends on other modules
ext_map = dict((ext.name, i) for i, ext in enumerate(extensions))
if "_ctypes" in ext_map:
@@ -411,7 +414,7 @@ def check_extension_import(self, ext):
ext.name)
return
- if host_platform == 'darwin' and (
+ if MACOS and (
sys.maxsize > 2**32 and '-arch' in ext.extra_link_args):
# Don't bother doing an import check when an extension was
# build with an explicit '-arch' flag on OSX. That's currently
@@ -425,7 +428,7 @@ def check_extension_import(self, ext):
# Workaround for Cygwin: Cygwin currently has fork issues when many
# modules have been imported
- if host_platform == 'cygwin':
+ if CYGWIN:
self.announce('WARNING: skipping import check for Cygwin-based "%s"'
% ext.name)
return
@@ -439,7 +442,7 @@ def check_extension_import(self, ext):
sys.path_importer_cache.clear()
# Don't try to load extensions for cross builds
- if cross_compiling:
+ if CROSS_COMPILING:
return
loader = importlib.machinery.ExtensionFileLoader(ext.name, ext_filename)
@@ -492,7 +495,7 @@ def add_multiarch_paths(self):
if not find_executable('dpkg-architecture'):
return
opt = ''
- if cross_compiling:
+ if CROSS_COMPILING:
opt = '-t' + sysconfig.get_config_var('HOST_GNU_TYPE')
tmpfile = os.path.join(self.build_temp, 'multiarch')
if not os.path.exists(self.build_temp):
@@ -550,11 +553,11 @@ def detect_modules(self):
# Ensure that /usr/local is always used, but the local build
# directories (i.e. '.' and 'Include') must be first. See issue
# 10520.
- if not cross_compiling:
+ if not CROSS_COMPILING:
add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
# only change this for cross builds for 3.3, issues on Mageia
- if cross_compiling:
+ if CROSS_COMPILING:
self.add_cross_compiling_paths()
self.add_multiarch_paths()
@@ -577,7 +580,7 @@ def detect_modules(self):
for directory in reversed(options.dirs):
add_dir_to_list(dir_list, directory)
- if (not cross_compiling and
+ if (not CROSS_COMPILING and
os.path.normpath(sys.base_prefix) != '/usr' and
not sysconfig.get_config_var('PYTHONFRAMEWORK')):
# OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
@@ -594,7 +597,7 @@ def detect_modules(self):
# lib_dirs and inc_dirs are used to search for files;
# if a file is found in one of those directories, it can
# be assumed that no additional -I,-L directives are needed.
- if not cross_compiling:
+ if not CROSS_COMPILING:
lib_dirs = self.compiler.library_dirs + system_lib_dirs
inc_dirs = self.compiler.include_dirs + system_include_dirs
else:
@@ -616,14 +619,14 @@ def detect_modules(self):
srcdir = sysconfig.get_config_var('srcdir')
# OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb)
- if host_platform in ['osf1', 'unixware7', 'openunix8']:
+ if HOST_PLATFORM in ['osf1', 'unixware7', 'openunix8']:
lib_dirs += ['/usr/ccs/lib']
# HP-UX11iv3 keeps files in lib/hpux folders.
- if host_platform == 'hp-ux11':
+ if HOST_PLATFORM == 'hp-ux11':
lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32']
- if host_platform == 'darwin':
+ if MACOS:
# This should work on any unixy platform ;-)
# If the user has bothered specifying additional -I and -L flags
# in OPT and LDFLAGS we might as well use them here.
@@ -786,7 +789,7 @@ def detect_modules(self):
os.makedirs(self.build_temp)
# Determine if readline is already linked against curses or tinfo.
if do_readline:
- if cross_compiling:
+ if CROSS_COMPILING:
ret = os.system("%s -d %s | grep '(NEEDED)' > %s" \
% (sysconfig.get_config_var('READELF'),
do_readline, tmpfile))
@@ -819,7 +822,7 @@ def detect_modules(self):
elif self.compiler.find_library_file(lib_dirs, 'curses'):
curses_library = 'curses'
- if host_platform == 'darwin':
+ if MACOS:
os_release = int(os.uname()[2].split('.')[0])
dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
if (dep_target and
@@ -833,7 +836,7 @@ def detect_modules(self):
if find_file('readline/rlconf.h', inc_dirs, []) is None:
do_readline = False
if do_readline:
- if host_platform == 'darwin' and os_release < 9:
+ if MACOS and os_release < 9:
# In every directory on the search path search for a dynamic
# library and then a static library, instead of first looking
# for dynamic libraries on the entire path.
@@ -999,7 +1002,7 @@ def gen_db_minor_ver_nums(major):
db_inc_paths.append('/pkg/db-3.%d/include' % x)
db_inc_paths.append('/opt/db-3.%d/include' % x)
- if cross_compiling:
+ if CROSS_COMPILING:
db_inc_paths = []
# Add some common subdirectories for Sleepycat DB to the list,
@@ -1022,7 +1025,7 @@ def gen_db_minor_ver_nums(major):
db_ver_inc_map = {}
- if host_platform == 'darwin':
+ if MACOS:
sysroot = macosx_sdk_root()
class db_found(Exception): pass
@@ -1031,7 +1034,7 @@ class db_found(Exception): pass
# search path.
for d in inc_dirs + db_inc_paths:
f = os.path.join(d, "db.h")
- if host_platform == 'darwin' and is_macosx_sdk_path(d):
+ if MACOS and is_macosx_sdk_path(d):
f = os.path.join(sysroot, d[1:], "db.h")
if db_setup_debug: print("db: looking for db.h in", f)
@@ -1082,7 +1085,7 @@ class db_found(Exception): pass
db_incdir.replace("include", 'lib'),
]
- if host_platform != 'darwin':
+ if not MACOS:
db_dirs_to_check = list(filter(os.path.isdir, db_dirs_to_check))
else:
@@ -1147,7 +1150,7 @@ class db_found(Exception): pass
'/usr/local/include/sqlite',
'/usr/local/include/sqlite3',
]
- if cross_compiling:
+ if CROSS_COMPILING:
sqlite_inc_paths = []
MIN_SQLITE_VERSION_NUMBER = (3, 0, 8)
MIN_SQLITE_VERSION = ".".join([str(x)
@@ -1156,12 +1159,12 @@ class db_found(Exception): pass
# Scan the default include directories before the SQLite specific
# ones. This allows one to override the copy of sqlite on OSX,
# where /usr/include contains an old version of sqlite.
- if host_platform == 'darwin':
+ if MACOS:
sysroot = macosx_sdk_root()
for d_ in inc_dirs + sqlite_inc_paths:
d = d_
- if host_platform == 'darwin' and is_macosx_sdk_path(d):
+ if MACOS and is_macosx_sdk_path(d):
d = os.path.join(sysroot, d[1:])
f = os.path.join(d, "sqlite3.h")
@@ -1212,7 +1215,7 @@ class db_found(Exception): pass
'_sqlite/util.c', ]
sqlite_defines = []
- if host_platform != "win32":
+ if not MS_WINDOWS:
sqlite_defines.append(('MODULE_NAME', '"sqlite3"'))
else:
sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"'))
@@ -1222,7 +1225,7 @@ class db_found(Exception): pass
if '--enable-loadable-sqlite-extensions' not in sysconfig.get_config_var("CONFIG_ARGS"):
sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))
- if host_platform == 'darwin':
+ if MACOS:
# In every directory on the search path search for a dynamic
# library and then a static library, instead of first looking
# for dynamic libraries on the entire path.
@@ -1253,7 +1256,7 @@ class db_found(Exception): pass
dbm_setup_debug = False # verbose debug prints from this script?
dbm_order = ['gdbm']
# The standard Unix dbm module:
- if host_platform not in ['cygwin']:
+ if not CYGWIN:
config_args = [arg.strip("'")
for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
dbm_args = [arg for arg in config_args
@@ -1335,7 +1338,7 @@ class db_found(Exception): pass
missing.append('_gdbm')
# Unix-only modules
- if host_platform != 'win32':
+ if not MS_WINDOWS:
if not VXWORKS:
# Steen Lumholt's termios module
exts.append( Extension('termios', ['termios.c']) )
@@ -1357,12 +1360,12 @@ class db_found(Exception): pass
panel_library = 'panel'
if curses_library == 'ncursesw':
curses_defines.append(('HAVE_NCURSESW', '1'))
- if not cross_compiling:
+ if not CROSS_COMPILING:
curses_includes.append('/usr/include/ncursesw')
# Bug 1464056: If _curses.so links with ncursesw,
# _curses_panel.so must link with panelw.
panel_library = 'panelw'
- if host_platform == 'darwin':
+ if MACOS:
# On OS X, there is no separate /usr/lib/libncursesw nor
# libpanelw. If we are here, we found a locally-supplied
# version of libncursesw. There should also be a
@@ -1370,7 +1373,7 @@ class db_found(Exception): pass
# for OS X but we need _XOPEN_SOURCE_EXTENDED here for
# ncurses wide char support
curses_defines.append(('_XOPEN_SOURCE_EXTENDED', '1'))
- elif host_platform == 'darwin' and curses_library == 'ncurses':
+ elif MACOS and curses_library == 'ncurses':
# Building with the system-suppied combined libncurses/libpanel
curses_defines.append(('HAVE_NCURSESW', '1'))
curses_defines.append(('_XOPEN_SOURCE_EXTENDED', '1'))
@@ -1381,7 +1384,7 @@ class db_found(Exception): pass
include_dirs=curses_includes,
define_macros=curses_defines,
libraries = curses_libs) )
- elif curses_library == 'curses' and host_platform != 'darwin':
+ elif curses_library == 'curses' and not MACOS:
# OSX has an old Berkeley curses, not good enough for
# the _curses module.
if (self.compiler.find_library_file(lib_dirs, 'terminfo')):
@@ -1425,7 +1428,7 @@ class db_found(Exception): pass
zlib_h = zlib_inc[0] + '/zlib.h'
version = '"0.0.0"'
version_req = '"1.1.3"'
- if host_platform == 'darwin' and is_macosx_sdk_path(zlib_h):
+ if MACOS and is_macosx_sdk_path(zlib_h):
zlib_h = os.path.join(macosx_sdk_root(), zlib_h[1:])
with open(zlib_h) as fp:
while 1:
@@ -1437,7 +1440,7 @@ class db_found(Exception): pass
break
if version >= version_req:
if (self.compiler.find_library_file(lib_dirs, 'z')):
- if host_platform == "darwin":
+ if MACOS:
zlib_extra_link_args = ('-Wl,-search_paths_first',)
else:
zlib_extra_link_args = ()
@@ -1469,7 +1472,7 @@ class db_found(Exception): pass
# Gustavo Niemeyer's bz2 module.
if (self.compiler.find_library_file(lib_dirs, 'bz2')):
- if host_platform == "darwin":
+ if MACOS:
bz2_extra_link_args = ('-Wl,-search_paths_first',)
else:
bz2_extra_link_args = ()
@@ -1575,23 +1578,23 @@ class db_found(Exception): pass
self.detect_ctypes(inc_dirs, lib_dirs)
# Richard Oudkerk's multiprocessing module
- if host_platform == 'win32': # Windows
+ if MS_WINDOWS:
macros = dict()
libraries = ['ws2_32']
- elif host_platform == 'darwin': # Mac OSX
+ elif MACOS: # Mac OSX
macros = dict()
libraries = []
- elif host_platform == 'cygwin': # Cygwin
+ elif CYGWIN:
macros = dict()
libraries = []
- elif host_platform.startswith('openbsd'):
+ elif HOST_PLATFORM.startswith('openbsd'):
macros = dict()
libraries = []
- elif host_platform.startswith('netbsd'):
+ elif HOST_PLATFORM.startswith('netbsd'):
macros = dict()
libraries = []
@@ -1599,7 +1602,7 @@ class db_found(Exception): pass
macros = dict()
libraries = ['rt']
- if host_platform == 'win32':
+ if MS_WINDOWS:
multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c',
'_multiprocessing/semaphore.c',
]
@@ -1629,12 +1632,12 @@ class db_found(Exception): pass
# End multiprocessing
# Platform-specific libraries
- if host_platform.startswith(('linux', 'freebsd', 'gnukfreebsd')):
+ if HOST_PLATFORM.startswith(('linux', 'freebsd', 'gnukfreebsd')):
exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) )
else:
missing.append('ossaudiodev')
- if host_platform == 'darwin':
+ if MACOS:
exts.append(
Extension('_scproxy', ['_scproxy.c'],
extra_link_args=[
@@ -1697,7 +1700,7 @@ def detect_tkinter_explicitly(self):
tcltk_libs = os.environ.get('_TCLTK_LIBS')
if not (tcltk_includes and tcltk_libs):
# Resume default configuration search.
- return 0
+ return False
extra_compile_args = tcltk_includes.split()
extra_link_args = tcltk_libs.split()
@@ -1707,7 +1710,7 @@ def detect_tkinter_explicitly(self):
extra_link_args = extra_link_args,
)
self.extensions.append(ext)
- return 1
+ return True
def detect_tkinter_darwin(self, inc_dirs, lib_dirs):
# The _tkinter module, using frameworks. Since frameworks are quite
@@ -1742,7 +1745,7 @@ def detect_tkinter_darwin(self, inc_dirs, lib_dirs):
else:
# Tk and Tcl frameworks not found. Normal "unix" tkinter search
# will now resume.
- return 0
+ return False
# For 8.4a2, we must add -I options that point inside the Tcl and Tk
# frameworks. In later release we should hopefully be able to pass
@@ -1796,7 +1799,7 @@ def detect_tkinter_darwin(self, inc_dirs, lib_dirs):
extra_link_args = frameworks,
)
self.extensions.append(ext)
- return 1
+ return True
def detect_tkinter(self, inc_dirs, lib_dirs):
# The _tkinter module.
@@ -1811,7 +1814,7 @@ def detect_tkinter(self, inc_dirs, lib_dirs):
# Rather than complicate the code below, detecting and building
# AquaTk is a separate method. Only one Tkinter will be built on
# Darwin - either AquaTk, if it is found, or X11 based Tk.
- if (host_platform == 'darwin' and
+ if (MACOS and
self.detect_tkinter_darwin(inc_dirs, lib_dirs)):
return
@@ -1834,7 +1837,7 @@ def detect_tkinter(self, inc_dirs, lib_dirs):
# Check for the include files on Debian and {Free,Open}BSD, where
# they're put in /usr/include/{tcl,tk}X.Y
dotversion = version
- if '.' not in dotversion and "bsd" in host_platform.lower():
+ if '.' not in dotversion and "bsd" in HOST_PLATFORM.lower():
# OpenBSD and FreeBSD use Tcl/Tk library names like libtcl83.a,
# but the include subdirs are named like .../include/tcl8.3.
dotversion = dotversion[:-1] + '.' + dotversion[-1]
@@ -1860,7 +1863,7 @@ def detect_tkinter(self, inc_dirs, lib_dirs):
include_dirs.append(dir)
# Check for various platform-specific directories
- if host_platform == 'sunos5':
+ if HOST_PLATFORM == 'sunos5':
include_dirs.append('/usr/openwin/include')
added_lib_dirs.append('/usr/openwin/lib')
elif os.path.exists('/usr/X11R6/include'):
@@ -1876,7 +1879,7 @@ def detect_tkinter(self, inc_dirs, lib_dirs):
added_lib_dirs.append('/usr/X11/lib')
# If Cygwin, then verify that X is installed before proceeding
- if host_platform == 'cygwin':
+ if CYGWIN:
x11_inc = find_file('X11/Xlib.h', [], include_dirs)
if x11_inc is None:
return
@@ -1895,11 +1898,11 @@ def detect_tkinter(self, inc_dirs, lib_dirs):
libs.append('tk'+ version)
libs.append('tcl'+ version)
- if host_platform in ['aix3', 'aix4']:
+ if HOST_PLATFORM in ['aix3', 'aix4']:
libs.append('ld')
# Finally, link with the X11 libraries (not appropriate on cygwin)
- if host_platform != "cygwin":
+ if not CYGWIN:
libs.append('X11')
ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
@@ -1947,7 +1950,7 @@ def configure_ctypes_darwin(self, ext):
def configure_ctypes(self, ext):
if not self.use_system_libffi:
- if host_platform == 'darwin':
+ if MACOS:
return self.configure_ctypes_darwin(ext)
print('INFO: Could not locate ffi libs and/or headers')
return False
@@ -1965,7 +1968,7 @@ def detect_ctypes(self, inc_dirs, lib_dirs):
'_ctypes/cfield.c']
depends = ['_ctypes/ctypes.h']
- if host_platform == 'darwin':
+ if MACOS:
sources.append('_ctypes/malloc_closure.c')
sources.append('_ctypes/darwin/dlfcn_simple.c')
extra_compile_args.append('-DMACOSX')
@@ -1973,7 +1976,7 @@ def detect_ctypes(self, inc_dirs, lib_dirs):
# XXX Is this still needed?
## extra_link_args.extend(['-read_only_relocs', 'warning'])
- elif host_platform == 'sunos5':
+ elif HOST_PLATFORM == 'sunos5':
# XXX This shouldn't be necessary; it appears that some
# of the assembler code is non-PIC (i.e. it has relocations
# when it shouldn't. The proper fix would be to rewrite
@@ -1984,7 +1987,7 @@ def detect_ctypes(self, inc_dirs, lib_dirs):
# finding some -z option for the Sun compiler.
extra_link_args.append('-mimpure-text')
- elif host_platform.startswith('hp-ux'):
+ elif HOST_PLATFORM.startswith('hp-ux'):
extra_link_args.append('-fPIC')
ext = Extension('_ctypes',
@@ -2000,7 +2003,7 @@ def detect_ctypes(self, inc_dirs, lib_dirs):
libraries=['m'])
self.extensions.extend([ext, ext_test])
- if host_platform == 'darwin':
+ if MACOS:
if '--with-system-ffi' not in sysconfig.get_config_var("CONFIG_ARGS"):
return
# OS X 10.5 comes with libffi.dylib; the include files are
@@ -2101,7 +2104,7 @@ def _decimal_ext(self):
if machine:
# Override automatic configuration to facilitate testing.
define_macros = config[machine]
- elif host_platform == 'darwin':
+ elif MACOS:
# Universal here means: build with the same options Python
# was built with.
define_macros = config['universal']
@@ -2115,7 +2118,7 @@ def _decimal_ext(self):
elif sizeof_size_t == 4:
ppro = sysconfig.get_config_var('HAVE_GCC_ASM_FOR_X87')
if ppro and ('gcc' in cc or 'clang' in cc) and \
- not 'sunos' in host_platform:
+ not 'sunos' in HOST_PLATFORM:
# solaris: problems with register allocation.
# icc >= 11.0 works as well.
define_macros = config['ppro']
@@ -2208,7 +2211,7 @@ def split_var(name, sep):
return ssl_ext, hashlib_ext
def _detect_nis(self, inc_dirs, lib_dirs):
- if host_platform in {'win32', 'cygwin', 'qnx6'}:
+ if MS_WINDOWS or CYGWIN or HOST_PLATFORM == 'qnx6':
return None
libs = []
https://github.com/python/cpython/commit/fb352413c1fac65823f274feeb369cd5ab…
commit: fb352413c1fac65823f274feeb369cd5ab1af2e4
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
committer: Ned Deily <nad(a)python.org>
date: 2019-02-27T18:46:08-05:00
summary:
Document the surprising sideeffect PyErr_Print(). (GH-12081) (GH-12084)
(cherry picked from commit 4173772031747a9b249be4100b4aa9eda805ea23)
Co-authored-by: Gregory P. Smith <greg(a)krypto.org>
files:
M Doc/c-api/exceptions.rst
diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst
index 2bc1bd876a2f..817469af0a58 100644
--- a/Doc/c-api/exceptions.rst
+++ b/Doc/c-api/exceptions.rst
@@ -53,8 +53,12 @@ Printing and clearing
.. c:function:: void PyErr_PrintEx(int set_sys_last_vars)
Print a standard traceback to ``sys.stderr`` and clear the error indicator.
- Call this function only when the error indicator is set. (Otherwise it will
- cause a fatal error!)
+ **Unless** the error is a ``SystemExit``. In that case the no traceback
+ is printed and Python process will exit with the error code specified by
+ the ``SystemExit`` instance.
+
+ Call this function **only** when the error indicator is set. Otherwise it
+ will cause a fatal error!
If *set_sys_last_vars* is nonzero, the variables :data:`sys.last_type`,
:data:`sys.last_value` and :data:`sys.last_traceback` will be set to the
https://github.com/python/cpython/commit/a588343390356f5f7bb40e25371f0f2a09…
commit: a588343390356f5f7bb40e25371f0f2a092d6d72
branch: 2.7
author: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
committer: GitHub <noreply(a)github.com>
date: 2019-02-27T15:45:57-08:00
summary:
Document the surprising sideeffect PyErr_Print(). (GH-12081)
Did you know an API documented as printing the pending traceback would sometimes exit the process?
You do now.
(cherry picked from commit 4173772031747a9b249be4100b4aa9eda805ea23)
Co-authored-by: Gregory P. Smith <greg(a)krypto.org>
files:
M Doc/c-api/exceptions.rst
diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst
index db302d8ee0ca..281e4c8473fd 100644
--- a/Doc/c-api/exceptions.rst
+++ b/Doc/c-api/exceptions.rst
@@ -44,8 +44,12 @@ is a separate error indicator for each thread.
.. c:function:: void PyErr_PrintEx(int set_sys_last_vars)
Print a standard traceback to ``sys.stderr`` and clear the error indicator.
- Call this function only when the error indicator is set. (Otherwise it will
- cause a fatal error!)
+ **Unless** the error is a ``SystemExit``. In that case the no traceback
+ is printed and Python process will exit with the error code specified by
+ the ``SystemExit`` instance.
+
+ Call this function **only** when the error indicator is set. Otherwise it
+ will cause a fatal error!
If *set_sys_last_vars* is nonzero, the variables :data:`sys.last_type`,
:data:`sys.last_value` and :data:`sys.last_traceback` will be set to the
https://github.com/python/cpython/commit/661151b3417a30912024dc72854286f1db…
commit: 661151b3417a30912024dc72854286f1db4fe72b
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
committer: GitHub <noreply(a)github.com>
date: 2019-02-27T15:45:28-08:00
summary:
Document the surprising sideeffect PyErr_Print(). (GH-12081)
Did you know an API documented as printing the pending traceback would sometimes exit the process?
You do now.
(cherry picked from commit 4173772031747a9b249be4100b4aa9eda805ea23)
Co-authored-by: Gregory P. Smith <greg(a)krypto.org>
files:
M Doc/c-api/exceptions.rst
diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst
index dd1e026cb071..cd06096ef7bb 100644
--- a/Doc/c-api/exceptions.rst
+++ b/Doc/c-api/exceptions.rst
@@ -53,8 +53,12 @@ Printing and clearing
.. c:function:: void PyErr_PrintEx(int set_sys_last_vars)
Print a standard traceback to ``sys.stderr`` and clear the error indicator.
- Call this function only when the error indicator is set. (Otherwise it will
- cause a fatal error!)
+ **Unless** the error is a ``SystemExit``. In that case the no traceback
+ is printed and Python process will exit with the error code specified by
+ the ``SystemExit`` instance.
+
+ Call this function **only** when the error indicator is set. Otherwise it
+ will cause a fatal error!
If *set_sys_last_vars* is nonzero, the variables :data:`sys.last_type`,
:data:`sys.last_value` and :data:`sys.last_traceback` will be set to the
https://github.com/python/cpython/commit/79e72591b17bfff8bee17ae837bfa4685e…
commit: 79e72591b17bfff8bee17ae837bfa4685e1599dc
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
committer: GitHub <noreply(a)github.com>
date: 2019-02-27T15:27:36-08:00
summary:
Fix grammar error in timeit module docs (GH-12066)
skip issue
skip news
(cherry picked from commit 4064089fce57c6fb2d1df9f3fb51d3fd5557696b)
Co-authored-by: Shiv Dhar <shivdhar(a)gmail.com>
files:
M Doc/library/timeit.rst
diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst
index 197b8a76fc38..8ca37034f79b 100644
--- a/Doc/library/timeit.rst
+++ b/Doc/library/timeit.rst
@@ -129,7 +129,7 @@ The module defines three convenience functions and a public class:
By default, :meth:`.timeit` temporarily turns off :term:`garbage
collection` during the timing. The advantage of this approach is that
- it makes independent timings more comparable. This disadvantage is
+ it makes independent timings more comparable. The disadvantage is
that GC may be an important component of the performance of the
function being measured. If so, GC can be re-enabled as the first
statement in the *setup* string. For example::