Commit 6a93c355 authored by Matthias Klose's avatar Matthias Klose

* Update 3.6 extensions and modules to 3.6.8.

  * Update 3.7 extensions and modules to 3.7.2.
parent 30441aeb
......@@ -166,7 +166,15 @@ def make_zipfile(base_name, base_dir, verbose=0, dry_run=0):
zip = zipfile.ZipFile(zip_filename, "w",
compression=zipfile.ZIP_STORED)
if base_dir != os.curdir:
path = os.path.normpath(os.path.join(base_dir, ''))
zip.write(path, path)
log.info("adding '%s'", path)
for dirpath, dirnames, filenames in os.walk(base_dir):
for name in dirnames:
path = os.path.normpath(os.path.join(dirpath, name, ''))
zip.write(path, path)
log.info("adding '%s'", path)
for name in filenames:
path = os.path.normpath(os.path.join(dirpath, name))
if os.path.isfile(path):
......
......@@ -32,7 +32,7 @@ class bdist_dumb(Command):
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('relative', None,
"build the archive using relative paths"
"build the archive using relative paths "
"(default: false)"),
('owner=', 'u',
"Owner name used when creating a tar file"
......
......@@ -98,14 +98,14 @@ class bdist_msi(Command):
('no-target-compile', 'c',
"do not compile .py to .pyc on the target system"),
('no-target-optimize', 'o',
"do not compile .py to .pyo (optimized)"
"do not compile .py to .pyo (optimized) "
"on the target system"),
('dist-dir=', 'd',
"directory to put final built distributions in"),
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('install-script=', None,
"basename of installation script to be run after"
"basename of installation script to be run after "
"installation or before deinstallation"),
('pre-install-script=', None,
"Fully qualified filename of a script to be run before "
......
......@@ -58,7 +58,7 @@ class bdist_rpm(Command):
"RPM \"vendor\" (eg. \"Joe Blow <joe@example.com>\") "
"[default: maintainer or author from setup script]"),
('packager=', None,
"RPM packager (eg. \"Jane Doe <jane@example.net>\")"
"RPM packager (eg. \"Jane Doe <jane@example.net>\") "
"[default: vendor]"),
('doc-files=', None,
"list of documentation files (space or comma-separated)"),
......
......@@ -29,7 +29,7 @@ class bdist_wininst(Command):
('no-target-compile', 'c',
"do not compile .py to .pyc on the target system"),
('no-target-optimize', 'o',
"do not compile .py to .pyo (optimized)"
"do not compile .py to .pyo (optimized) "
"on the target system"),
('dist-dir=', 'd',
"directory to put final built distributions in"),
......@@ -40,7 +40,7 @@ class bdist_wininst(Command):
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('install-script=', None,
"basename of installation script to be run after"
"basename of installation script to be run after "
"installation or before deinstallation"),
('pre-install-script=', None,
"Fully qualified filename of a script to be run before "
......@@ -357,7 +357,10 @@ class bdist_wininst(Command):
sfix = ''
filename = os.path.join(directory, "wininst-%s%s.exe" % (bv, sfix))
f = open(filename, "rb")
try:
f = open(filename, "rb")
except IOError as e:
raise DistutilsFileError(str(e) + ', %s not included in the Debian packages.' % filename)
try:
return f.read()
finally:
......
......@@ -230,7 +230,7 @@ class build_ext(Command):
# For building extensions with a shared Python library,
# Python's library directory must be appended to library_dirs
# See Issues: #1600860, #4366
if (sysconfig.get_config_var('Py_ENABLE_SHARED')):
if False and (sysconfig.get_config_var('Py_ENABLE_SHARED')):
if not sysconfig.python_build:
# building third party extensions
self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
......@@ -365,7 +365,7 @@ class build_ext(Command):
ext_name, build_info = ext
log.warn("old-style (ext_name, build_info) tuple found in "
"ext_modules for extension '%s'"
"ext_modules for extension '%s' "
"-- please convert to Extension instance", ext_name)
if not (isinstance(ext_name, str) and
......@@ -746,7 +746,7 @@ class build_ext(Command):
return ext.libraries
else:
from distutils import sysconfig
if sysconfig.get_config_var('Py_ENABLE_SHARED'):
if False and sysconfig.get_config_var('Py_ENABLE_SHARED'):
pythonlib = 'python{}.{}{}'.format(
sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff,
sysconfig.get_config_var('ABIFLAGS'))
......
......@@ -35,6 +35,20 @@ INSTALL_SCHEMES = {
'scripts': '$base/bin',
'data' : '$base',
},
'unix_local': {
'purelib': '$base/local/lib/python$py_version_short/dist-packages',
'platlib': '$platbase/local/lib/python$py_version_short/dist-packages',
'headers': '$base/local/include/python$py_version_short/$dist_name',
'scripts': '$base/local/bin',
'data' : '$base/local',
},
'deb_system': {
'purelib': '$base/lib/python3/dist-packages',
'platlib': '$platbase/lib/python3/dist-packages',
'headers': '$base/include/python$py_version_short/$dist_name',
'scripts': '$base/bin',
'data' : '$base',
},
'unix_home': {
'purelib': '$base/lib/python',
'platlib': '$base/lib/python',
......@@ -131,6 +145,9 @@ class install(Command):
('record=', None,
"filename in which to record list of installed files"),
('install-layout=', None,
"installation layout to choose (known values: deb, unix)"),
]
boolean_options = ['compile', 'force', 'skip-build']
......@@ -151,6 +168,7 @@ class install(Command):
self.exec_prefix = None
self.home = None
self.user = 0
self.prefix_option = None
# These select only the installation base; it's up to the user to
# specify the installation scheme (currently, that means supplying
......@@ -172,6 +190,10 @@ class install(Command):
self.install_userbase = USER_BASE
self.install_usersite = USER_SITE
# enable custom installation, known values: deb
self.install_layout = None
self.multiarch = None
self.compile = None
self.optimize = None
......@@ -413,6 +435,7 @@ class install(Command):
self.install_base = self.install_platbase = self.home
self.select_scheme("unix_home")
else:
self.prefix_option = self.prefix
if self.prefix is None:
if self.exec_prefix is not None:
raise DistutilsOptionError(
......@@ -427,7 +450,28 @@ class install(Command):
self.install_base = self.prefix
self.install_platbase = self.exec_prefix
self.select_scheme("unix_prefix")
if self.install_layout:
if self.install_layout.lower() in ['deb']:
import sysconfig
self.multiarch = sysconfig.get_config_var('MULTIARCH')
self.select_scheme("deb_system")
elif self.install_layout.lower() in ['unix']:
self.select_scheme("unix_prefix")
else:
raise DistutilsOptionError(
"unknown value for --install-layout")
elif ((self.prefix_option and
os.path.normpath(self.prefix) != '/usr/local')
or sys.base_prefix != sys.prefix
or 'PYTHONUSERBASE' in os.environ
or 'VIRTUAL_ENV' in os.environ
or 'real_prefix' in sys.__dict__):
self.select_scheme("unix_prefix")
else:
if os.path.normpath(self.prefix) == '/usr/local':
self.prefix = self.exec_prefix = '/usr'
self.install_base = self.install_platbase = '/usr'
self.select_scheme("unix_local")
def finalize_other(self):
"""Finalizes options for non-posix platforms"""
......
......@@ -14,18 +14,38 @@ class install_egg_info(Command):
description = "Install package's PKG-INFO metadata as an .egg-info file"
user_options = [
('install-dir=', 'd', "directory to install to"),
('install-layout', None, "custom installation layout"),
]
def initialize_options(self):
self.install_dir = None
self.install_layout = None
self.prefix_option = None
def finalize_options(self):
self.set_undefined_options('install_lib',('install_dir','install_dir'))
basename = "%s-%s-py%d.%d.egg-info" % (
to_filename(safe_name(self.distribution.get_name())),
to_filename(safe_version(self.distribution.get_version())),
*sys.version_info[:2]
)
self.set_undefined_options('install',('install_layout','install_layout'))
self.set_undefined_options('install',('prefix_option','prefix_option'))
if self.install_layout:
if not self.install_layout.lower() in ['deb', 'unix']:
raise DistutilsOptionError(
"unknown value for --install-layout")
no_pyver = (self.install_layout.lower() == 'deb')
elif self.prefix_option:
no_pyver = False
else:
no_pyver = True
if no_pyver:
basename = "%s-%s.egg-info" % (
to_filename(safe_name(self.distribution.get_name())),
to_filename(safe_version(self.distribution.get_version()))
)
else:
basename = "%s-%s-py%d.%d.egg-info" % (
to_filename(safe_name(self.distribution.get_name())),
to_filename(safe_version(self.distribution.get_version())),
*sys.version_info[:2]
)
self.target = os.path.join(self.install_dir, basename)
self.outputs = [self.target]
......
......@@ -56,6 +56,7 @@ class install_lib(Command):
self.compile = None
self.optimize = None
self.skip_build = None
self.multiarch = None # if we should rename the extensions
def finalize_options(self):
# Get all the information we need to install pure Python modules
......@@ -68,6 +69,7 @@ class install_lib(Command):
('compile', 'compile'),
('optimize', 'optimize'),
('skip_build', 'skip_build'),
('multiarch', 'multiarch'),
)
if self.compile is None:
......@@ -108,6 +110,8 @@ class install_lib(Command):
def install(self):
if os.path.isdir(self.build_dir):
import distutils.dir_util
distutils.dir_util._multiarch = self.multiarch
outfiles = self.copy_tree(self.build_dir, self.install_dir)
else:
self.warn("'%s' does not exist -- no Python modules to install" %
......
......@@ -96,6 +96,9 @@ def create_tree(base_dir, files, mode=0o777, verbose=1, dry_run=0):
for dir in sorted(need_dir):
mkpath(dir, mode, verbose=verbose, dry_run=dry_run)
import sysconfig
_multiarch = None
def copy_tree(src, dst, preserve_mode=1, preserve_times=1,
preserve_symlinks=0, update=0, verbose=1, dry_run=0):
"""Copy an entire directory tree 'src' to a new location 'dst'.
......@@ -131,6 +134,13 @@ def copy_tree(src, dst, preserve_mode=1, preserve_times=1,
raise DistutilsFileError(
"error listing files in '%s': %s" % (src, e.strerror))
ext_suffix = sysconfig.get_config_var ('EXT_SUFFIX')
_multiarch = sysconfig.get_config_var ('MULTIARCH')
if ext_suffix.endswith(_multiarch + ext_suffix[-3:]):
new_suffix = None
else:
new_suffix = "%s-%s%s" % (ext_suffix[:-3], _multiarch, ext_suffix[-3:])
if not dry_run:
mkpath(dst, verbose=verbose)
......@@ -139,6 +149,9 @@ def copy_tree(src, dst, preserve_mode=1, preserve_times=1,
for n in names:
src_name = os.path.join(src, n)
dst_name = os.path.join(dst, n)
if new_suffix and _multiarch and n.endswith(ext_suffix) and not n.endswith(new_suffix):
dst_name = os.path.join(dst, n.replace(ext_suffix, new_suffix))
log.info("renaming extension %s -> %s", n, n.replace(ext_suffix, new_suffix))
if n.startswith('.nfs'):
# skip NFS rename files
......
......@@ -13,6 +13,7 @@ import _imp
import os
import re
import sys
import fnmatch
from .errors import DistutilsPlatformError
......@@ -99,6 +100,9 @@ def get_python_inc(plat_specific=0, prefix=None):
incdir = os.path.join(get_config_var('srcdir'), 'Include')
return os.path.normpath(incdir)
python_dir = 'python' + get_python_version() + build_flags
if not python_build and plat_specific:
import sysconfig
return sysconfig.get_path('platinclude')
return os.path.join(prefix, "include", python_dir)
elif os.name == "nt":
return os.path.join(prefix, "include")
......@@ -122,6 +126,7 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
If 'prefix' is supplied, use it instead of sys.base_prefix or
sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
"""
is_default_prefix = not prefix or os.path.normpath(prefix) in ('/usr', '/usr/local')
if prefix is None:
if standard_lib:
prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
......@@ -133,6 +138,12 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
"lib", "python" + get_python_version())
if standard_lib:
return libpython
elif (is_default_prefix and
'PYTHONUSERBASE' not in os.environ and
'VIRTUAL_ENV' not in os.environ and
'real_prefix' not in sys.__dict__ and
sys.prefix == sys.base_prefix):
return os.path.join(prefix, "lib", "python3", "dist-packages")
else:
return os.path.join(libpython, "site-packages")
elif os.name == "nt":
......@@ -170,9 +181,11 @@ def customize_compiler(compiler):
_osx_support.customize_compiler(_config_vars)
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
(cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
(cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags,
configure_cppflags, configure_cflags, configure_ldflags) = \
get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS',
'CONFIGURE_CPPFLAGS', 'CONFIGURE_CFLAGS', 'CONFIGURE_LDFLAGS')
if 'CC' in os.environ:
newcc = os.environ['CC']
......@@ -185,6 +198,10 @@ def customize_compiler(compiler):
cc = newcc
if 'CXX' in os.environ:
cxx = os.environ['CXX']
if fnmatch.filter([cc, cxx], '*-4.[0-8]'):
configure_cflags = configure_cflags.replace('-fstack-protector-strong', '-fstack-protector')
ldshared = ldshared.replace('-fstack-protector-strong', '-fstack-protector')
cflags = cflags.replace('-fstack-protector-strong', '-fstack-protector')
if 'LDSHARED' in os.environ:
ldshared = os.environ['LDSHARED']
if 'CPP' in os.environ:
......@@ -193,13 +210,22 @@ def customize_compiler(compiler):
cpp = cc + " -E" # not always
if 'LDFLAGS' in os.environ:
ldshared = ldshared + ' ' + os.environ['LDFLAGS']
elif configure_ldflags:
ldshared = ldshared + ' ' + configure_ldflags
if 'CFLAGS' in os.environ:
cflags = opt + ' ' + os.environ['CFLAGS']
ldshared = ldshared + ' ' + os.environ['CFLAGS']
elif configure_cflags:
cflags = opt + ' ' + configure_cflags
ldshared = ldshared + ' ' + configure_cflags
if 'CPPFLAGS' in os.environ:
cpp = cpp + ' ' + os.environ['CPPFLAGS']
cflags = cflags + ' ' + os.environ['CPPFLAGS']
ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
elif configure_cppflags:
cpp = cpp + ' ' + configure_cppflags
cflags = cflags + ' ' + configure_cppflags
ldshared = ldshared + ' ' + configure_cppflags
if 'AR' in os.environ:
ar = os.environ['AR']
if 'ARFLAGS' in os.environ:
......
......@@ -122,12 +122,13 @@ class ArchiveUtilTestCase(support.TempdirManager,
try:
names = tar.getnames()
names.sort()
return tuple(names)
return names
finally:
tar.close()
_created_files = ('dist', 'dist/file1', 'dist/file2',
'dist/sub', 'dist/sub/file3', 'dist/sub2')
_zip_created_files = ['dist/', 'dist/file1', 'dist/file2',
'dist/sub/', 'dist/sub/file3', 'dist/sub2/']
_created_files = [p.rstrip('/') for p in _zip_created_files]
def _create_files(self):
# creating something to tar
......@@ -244,8 +245,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
tarball = base_name + '.zip'
self.assertTrue(os.path.exists(tarball))
with zipfile.ZipFile(tarball) as zf:
self.assertEqual(sorted(zf.namelist()),
['dist/file1', 'dist/file2', 'dist/sub/file3'])
self.assertEqual(sorted(zf.namelist()), self._zip_created_files)
@unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run')
def test_make_zipfile_no_zlib(self):
......@@ -271,8 +271,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
[((tarball, "w"), {'compression': zipfile.ZIP_STORED})])
self.assertTrue(os.path.exists(tarball))
with zipfile.ZipFile(tarball) as zf:
self.assertEqual(sorted(zf.namelist()),
['dist/file1', 'dist/file2', 'dist/sub/file3'])
self.assertEqual(sorted(zf.namelist()), self._zip_created_files)
def test_check_archive_formats(self):
self.assertEqual(check_archive_formats(['gztar', 'xxx', 'zip']),
......
......@@ -84,8 +84,8 @@ class BuildDumbTestCase(support.TempdirManager,
finally:
fp.close()
contents = sorted(os.path.basename(fn) for fn in contents)
wanted = ['foo-0.1-py%s.%s.egg-info' % sys.version_info[:2], 'foo.py']
contents = sorted(filter(None, map(os.path.basename, contents)))
wanted = ['foo-0.1.egg-info', 'foo.py']
if not sys.dont_write_bytecode:
wanted.append('foo.%s.pyc' % sys.implementation.cache_tag)
self.assertEqual(contents, sorted(wanted))
......
......@@ -102,6 +102,7 @@ class BuildExtTestCase(TempdirManager,
build_ext.USER_BASE = self.old_user_base
super(BuildExtTestCase, self).tearDown()
@unittest.skip('Skipping failing Solaris test')
def test_solaris_enable_shared(self):
dist = Distribution({'name': 'xx'})
cmd = self.build_ext(dist)
......
......@@ -193,7 +193,7 @@ class InstallTestCase(support.TempdirManager,
found = [os.path.basename(line) for line in content.splitlines()]
expected = ['hello.py', 'hello.%s.pyc' % sys.implementation.cache_tag,
'sayhi',
'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]]
'UNKNOWN-0.0.0.egg-info']
self.assertEqual(found, expected)
def test_record_extensions(self):
......@@ -226,7 +226,7 @@ class InstallTestCase(support.TempdirManager,
found = [os.path.basename(line) for line in content.splitlines()]
expected = [_make_ext_name('xx'),
'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]]
'UNKNOWN-0.0.0.egg-info']
self.assertEqual(found, expected)
def test_debug_mode(self):
......
......@@ -128,7 +128,9 @@ class SDistTestCase(BasePyPIRCCommandTestCase):
zip_file.close()
# making sure everything has been pruned correctly
self.assertEqual(len(content), 4)
expected = ['', 'PKG-INFO', 'README', 'setup.py',
'somecode/', 'somecode/__init__.py']
self.assertEqual(sorted(content), ['fake-1.0/' + x for x in expected])
@unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
@unittest.skipIf(find_executable('tar') is None,
......@@ -226,7 +228,13 @@ class SDistTestCase(BasePyPIRCCommandTestCase):
zip_file.close()
# making sure everything was added
self.assertEqual(len(content), 12)
expected = ['', 'PKG-INFO', 'README', 'buildout.cfg',
'data/', 'data/data.dt', 'inroot.txt',
'scripts/', 'scripts/script.py', 'setup.py',
'some/', 'some/file.txt', 'some/other_file.txt',
'somecode/', 'somecode/__init__.py', 'somecode/doc.dat',
'somecode/doc.txt']
self.assertEqual(sorted(content), ['fake-1.0/' + x for x in expected])
# checking the MANIFEST
f = open(join(self.tmp_dir, 'MANIFEST'))
......
......@@ -155,6 +155,17 @@ class UnixCCompiler(CCompiler):
runtime_library_dirs)
libraries, library_dirs, runtime_library_dirs = fixed_args
# filter out standard library paths, which are not explicitely needed
# for linking
system_libdirs = ['/lib', '/lib64', '/usr/lib', '/usr/lib64']
multiarch = sysconfig.get_config_var("MULTIARCH")
if multiarch:
system_libdirs.extend(['/lib/%s' % multiarch, '/usr/lib/%s' % multiarch])
library_dirs = [dir for dir in library_dirs
if not dir in system_libdirs]
runtime_library_dirs = [dir for dir in runtime_library_dirs
if not dir in system_libdirs]
lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,
libraries)
if not isinstance(output_dir, (str, type(None))):
......
......@@ -31,7 +31,8 @@ class FixExecfile(fixer_base.BaseFix):
# call.
execfile_paren = node.children[-1].children[-1].clone()
# Construct open().read().
open_args = ArgList([filename.clone()], rparen=execfile_paren)
open_args = ArgList([filename.clone(), Comma(), String('"rb"', ' ')],
rparen=execfile_paren)
open_call = Node(syms.power, [Name("open"), open_args])
read = [Node(syms.trailer, [Dot(), Name('read')]),
Node(syms.trailer, [LParen(), RParen()])]
......
......@@ -123,7 +123,10 @@ def load_grammar(gt="Grammar.txt", gp=None,
if force or not _newer(gp, gt):
logger.info("Generating grammar tables from %s", gt)
g = pgen.generate_grammar(gt)
if save:
# the pickle files mismatch, when built on different architectures.
# don't save these for now. An alternative solution might be to
# include the multiarch triplet into the file name
if False:
logger.info("Writing grammar tables to %s", gp)
try:
g.dump(gp)
......
......@@ -1201,36 +1201,36 @@ class Test_execfile(FixerTestCase):
def test_conversion(self):
b = """execfile("fn")"""
a = """exec(compile(open("fn").read(), "fn", 'exec'))"""
a = """exec(compile(open("fn", "rb").read(), "fn", 'exec'))"""
self.check(b, a)
b = """execfile("fn", glob)"""
a = """exec(compile(open("fn").read(), "fn", 'exec'), glob)"""
a = """exec(compile(open("fn", "rb").read(), "fn", 'exec'), glob)"""
self.check(b, a)
b = """execfile("fn", glob, loc)"""
a = """exec(compile(open("fn").read(), "fn", 'exec'), glob, loc)"""
a = """exec(compile(open("fn", "rb").read(), "fn", 'exec'), glob, loc)"""
self.check(b, a)
b = """execfile("fn", globals=glob)"""
a = """exec(compile(open("fn").read(), "fn", 'exec'), globals=glob)"""
a = """exec(compile(open("fn", "rb").read(), "fn", 'exec'), globals=glob)"""
self.check(b, a)
b = """execfile("fn", locals=loc)"""
a = """exec(compile(open("fn").read(), "fn", 'exec'), locals=loc)"""
a = """exec(compile(open("fn", "rb").read(), "fn", 'exec'), locals=loc)"""
self.check(b, a)
b = """execfile("fn", globals=glob, locals=loc)"""
a = """exec(compile(open("fn").read(), "fn", 'exec'), globals=glob, locals=loc)"""
a = """exec(compile(open("fn", "rb").read(), "fn", 'exec'), globals=glob, locals=loc)"""
self.check(b, a)
def test_spacing(self):
b = """execfile( "fn" )"""
a = """exec(compile(open( "fn" ).read(), "fn", 'exec'))"""
a = """exec(compile(open( "fn", "rb" ).read(), "fn", 'exec'))"""
self.check(b, a)
b = """execfile("fn", globals = glob)"""
a = """exec(compile(open("fn").read(), "fn", 'exec'), globals = glob)"""
a = """exec(compile(open("fn", "rb").read(), "fn", 'exec'), globals = glob)"""
self.check(b, a)
......
......@@ -3750,7 +3750,7 @@ class Spinbox(Widget, XView):
select to commands. If the selection isn't currently in
the spinbox, then a new selection is created to include
the characters between index and the most recent selection
anchor point, inclusive. Returns an empty string.
anchor point, inclusive.
"""
return self.selection("adjust", index)
......@@ -3758,7 +3758,7 @@ class Spinbox(Widget, XView):
"""Clear the selection
If the selection isn't in this widget then the
command has no effect. Returns an empty string.
command has no effect.
"""
return self.selection("clear")
......@@ -3766,9 +3766,9 @@ class Spinbox(Widget, XView):
"""Sets or gets the currently selected element.
If a spinbutton element is specified, it will be
displayed depressed
displayed depressed.
"""
return self.selection("element", element)
return self.tk.call(self._w, 'selection', 'element', element)
###########################################################################
......
......@@ -62,9 +62,9 @@ def requires_tcl(*version):
def deco(test):
@functools.wraps(test)
def newtest(self):
if get_tk_patchlevel() < (8, 6, 5):
if get_tk_patchlevel() < version:
self.skipTest('requires Tcl version >= ' +
'.'.join(map(str, get_tk_patchlevel())))
'.'.join(map(str, version)))
test(self)
return newtest
return deco
......
......@@ -474,6 +474,14 @@ class SpinboxTest(EntryTest, unittest.TestCase):
self.assertRaises(TypeError, widget.bbox)
self.assertRaises(TypeError, widget.bbox, 0, 1)
def test_selection_element(self):
widget = self.create()
self.assertEqual(widget.selection_element(), "none")
widget.selection_element("buttonup")
self.assertEqual(widget.selection_element(), "buttonup")
widget.selection_element("buttondown")
self.assertEqual(widget.selection_element(), "buttondown")
@add_standard_options(StandardOptionsTests)
class TextTest(AbstractWidgetTest, unittest.TestCase):
......
......@@ -864,7 +864,7 @@ PyTclObject_string(PyTclObject *self, void *ignored)
}
static PyObject *
PyTclObject_str(PyTclObject *self, void *ignored)
PyTclObject_str(PyTclObject *self)
{
if (self->string) {
Py_INCREF(self->string);
......@@ -877,7 +877,7 @@ PyTclObject_str(PyTclObject *self, void *ignored)
static PyObject *
PyTclObject_repr(PyTclObject *self)
{
PyObject *repr, *str = PyTclObject_str(self, NULL);
PyObject *repr, *str = PyTclObject_str(self);
if (str == NULL)
return NULL;
repr = PyUnicode_FromFormat("<%s object: %R>",
......@@ -1153,9 +1153,7 @@ AsObj(PyObject *value)
}
if (PyTclObject_Check(value)) {
Tcl_Obj *v = ((PyTclObject*)value)->value;
Tcl_IncrRefCount(v);
return v;
return ((PyTclObject*)value)->value;
}
{
......
......@@ -56,43 +56,43 @@ def _find_vc2015():
return best_version, best_dir
def _find_vc2017():
import _distutils_findvs
import threading
"""Returns "15, path" based on the result of invoking vswhere.exe
If no install is found, returns "None, None"
best_version = 0, # tuple for full version comparisons
best_dir = None
The version is returned to avoid unnecessarily changing the function
result. It may be ignored when the path is not None.
If vswhere.exe is not available, by definition, VS 2017 is not
installed.
"""
import json
root = os.environ.get("ProgramFiles(x86)") or os.environ.get("ProgramFiles")
if not root:
return None, None
# We need to call findall() on its own thread because it will
# initialize COM.
all_packages = []
def _getall():
all_packages.extend(_distutils_findvs.findall())