summaryrefslogtreecommitdiffstats
path: root/Lib/distutils
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2006-08-18 22:13:04 (GMT)
committerGuido van Rossum <guido@python.org>2006-08-18 22:13:04 (GMT)
commite2b70bcf7401477936fba99a8bf4a1f759ecc8a3 (patch)
tree4c9b65b7fd8c26a3d2f1b64ecd6b4c72a756b4b2 /Lib/distutils
parentd2dbecb4ae9177e2e87adcb047147c6bcbf28cc1 (diff)
downloadcpython-e2b70bcf7401477936fba99a8bf4a1f759ecc8a3.zip
cpython-e2b70bcf7401477936fba99a8bf4a1f759ecc8a3.tar.gz
cpython-e2b70bcf7401477936fba99a8bf4a1f759ecc8a3.tar.bz2
Get rid of dict.has_key(). Boy this has a lot of repercussions!
Not all code has been fixed yet; this is just a checkpoint... The C API still has PyDict_HasKey() and _HasKeyString(); not sure if I want to change those just yet.
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/archive_util.py2
-rw-r--r--Lib/distutils/ccompiler.py2
-rw-r--r--Lib/distutils/command/build_ext.py2
-rw-r--r--Lib/distutils/core.py6
-rw-r--r--Lib/distutils/dist.py8
-rw-r--r--Lib/distutils/fancy_getopt.py8
-rw-r--r--Lib/distutils/sysconfig.py22
-rw-r--r--Lib/distutils/text_file.py4
-rw-r--r--Lib/distutils/util.py6
9 files changed, 30 insertions, 30 deletions
diff --git a/Lib/distutils/archive_util.py b/Lib/distutils/archive_util.py
index b725a14..059d544 100644
--- a/Lib/distutils/archive_util.py
+++ b/Lib/distutils/archive_util.py
@@ -124,7 +124,7 @@ ARCHIVE_FORMATS = {
def check_archive_formats (formats):
for format in formats:
- if not ARCHIVE_FORMATS.has_key(format):
+ if format not in ARCHIVE_FORMATS:
return format
else:
return None
diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py
index 1349abe..0ed9a40 100644
--- a/Lib/distutils/ccompiler.py
+++ b/Lib/distutils/ccompiler.py
@@ -159,7 +159,7 @@ class CCompiler:
# basically the same things with Unix C compilers.
for key in args.keys():
- if not self.executables.has_key(key):
+ if key not in self.executables:
raise ValueError, \
"unknown executable '%s' for class %s" % \
(key, self.__class__.__name__)
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index 9626710..cd67544 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -341,7 +341,7 @@ class build_ext (Command):
# Medium-easy stuff: same syntax/semantics, different names.
ext.runtime_library_dirs = build_info.get('rpath')
- if build_info.has_key('def_file'):
+ if 'def_file' in build_info:
log.warn("'def_file' element of build info dict "
"no longer supported")
diff --git a/Lib/distutils/core.py b/Lib/distutils/core.py
index c9c6f03..85a28fe 100644
--- a/Lib/distutils/core.py
+++ b/Lib/distutils/core.py
@@ -101,9 +101,9 @@ def setup (**attrs):
else:
klass = Distribution
- if not attrs.has_key('script_name'):
+ if 'script_name' not in attrs:
attrs['script_name'] = os.path.basename(sys.argv[0])
- if not attrs.has_key('script_args'):
+ if 'script_args' not in attrs:
attrs['script_args'] = sys.argv[1:]
# Create the Distribution instance, using the remaining arguments
@@ -111,7 +111,7 @@ def setup (**attrs):
try:
_setup_distribution = dist = klass(attrs)
except DistutilsSetupError, msg:
- if attrs.has_key('name'):
+ if 'name' not in attrs:
raise SystemExit, "error in %s setup command: %s" % \
(attrs['name'], msg)
else:
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
index ff49886..d098cb9 100644
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -239,7 +239,7 @@ Common commands: (see '--help-commands' for more)
for (opt, val) in cmd_options.items():
opt_dict[opt] = ("setup script", val)
- if attrs.has_key('licence'):
+ if 'licence' in attrs:
attrs['license'] = attrs['licence']
del attrs['licence']
msg = "'licence' distribution option is deprecated; use 'license'"
@@ -343,7 +343,7 @@ Common commands: (see '--help-commands' for more)
user_filename = "pydistutils.cfg"
# And look for the user config file
- if os.environ.has_key('HOME'):
+ if 'HOME' in os.environ:
user_file = os.path.join(os.environ.get('HOME'), user_filename)
if os.path.isfile(user_file):
files.append(user_file)
@@ -388,7 +388,7 @@ Common commands: (see '--help-commands' for more)
# If there was a "global" section in the config file, use it
# to set Distribution options.
- if self.command_options.has_key('global'):
+ if 'global' in self.command_options:
for (opt, (src, val)) in self.command_options['global'].items():
alias = self.negative_opt.get(opt)
try:
@@ -907,7 +907,7 @@ Common commands: (see '--help-commands' for more)
try:
is_string = type(value) is StringType
- if neg_opt.has_key(option) and is_string:
+ if option in neg_opt and is_string:
setattr(command_obj, neg_opt[option], not strtobool(value))
elif option in bool_opts and is_string:
setattr(command_obj, option, strtobool(value))
diff --git a/Lib/distutils/fancy_getopt.py b/Lib/distutils/fancy_getopt.py
index 218ed73..31cf0c5 100644
--- a/Lib/distutils/fancy_getopt.py
+++ b/Lib/distutils/fancy_getopt.py
@@ -97,7 +97,7 @@ class FancyGetopt:
self._build_index()
def add_option (self, long_option, short_option=None, help_string=None):
- if self.option_index.has_key(long_option):
+ if long_option in self.option_index:
raise DistutilsGetoptError, \
"option conflict: already an option '%s'" % long_option
else:
@@ -109,7 +109,7 @@ class FancyGetopt:
def has_option (self, long_option):
"""Return true if the option table for this parser has an
option with long name 'long_option'."""
- return self.option_index.has_key(long_option)
+ return long_option in self.option_index
def get_attr_name (self, long_option):
"""Translate long option name 'long_option' to the form it
@@ -121,11 +121,11 @@ class FancyGetopt:
def _check_alias_dict (self, aliases, what):
assert type(aliases) is DictionaryType
for (alias, opt) in aliases.items():
- if not self.option_index.has_key(alias):
+ if alias not in self.option_index:
raise DistutilsGetoptError, \
("invalid %s '%s': "
"option '%s' not defined") % (what, alias, alias)
- if not self.option_index.has_key(opt):
+ if opt not in self.option_index:
raise DistutilsGetoptError, \
("invalid %s '%s': "
"aliased option '%s' not defined") % (what, alias, opt)
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index 76fe256..0ea4bb7 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -150,22 +150,22 @@ def customize_compiler(compiler):
get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
'CCSHARED', 'LDSHARED', 'SO')
- if os.environ.has_key('CC'):
+ if 'CC' in os.environ:
cc = os.environ['CC']
- if os.environ.has_key('CXX'):
+ if 'CXX' in os.environ:
cxx = os.environ['CXX']
- if os.environ.has_key('LDSHARED'):
+ if 'LDSHARED' in os.environ:
ldshared = os.environ['LDSHARED']
- if os.environ.has_key('CPP'):
+ if 'CPP' in os.environ:
cpp = os.environ['CPP']
else:
cpp = cc + " -E" # not always
- if os.environ.has_key('LDFLAGS'):
+ if 'LDFLAGS' in os.environ:
ldshared = ldshared + ' ' + os.environ['LDFLAGS']
- if os.environ.has_key('CFLAGS'):
+ if 'CFLAGS' in os.environ:
cflags = opt + ' ' + os.environ['CFLAGS']
ldshared = ldshared + ' ' + os.environ['CFLAGS']
- if os.environ.has_key('CPPFLAGS'):
+ if 'CPPFLAGS' in os.environ:
cpp = cpp + ' ' + os.environ['CPPFLAGS']
cflags = cflags + ' ' + os.environ['CPPFLAGS']
ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
@@ -277,12 +277,12 @@ def parse_makefile(fn, g=None):
if m:
n = m.group(1)
found = True
- if done.has_key(n):
+ if n in done:
item = str(done[n])
- elif notdone.has_key(n):
+ elif n in notdone:
# get it on a subsequent round
found = False
- elif os.environ.has_key(n):
+ elif n in os.environ:
# do it like make: fall back to environment
item = os.environ[n]
else:
@@ -366,7 +366,7 @@ def _init_posix():
# MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so
# it needs to be compatible.
# If it isn't set we set it to the configure-time value
- if sys.platform == 'darwin' and g.has_key('MACOSX_DEPLOYMENT_TARGET'):
+ if sys.platform == 'darwin' and 'MACOSX_DEPLOYMENT_TARGET' in g:
cfg_target = g['MACOSX_DEPLOYMENT_TARGET']
cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '')
if cur_target == '':
diff --git a/Lib/distutils/text_file.py b/Lib/distutils/text_file.py
index 67efd65..ff2878d 100644
--- a/Lib/distutils/text_file.py
+++ b/Lib/distutils/text_file.py
@@ -89,7 +89,7 @@ class TextFile:
# set values for all options -- either from client option hash
# or fallback to default_options
for opt in self.default_options.keys():
- if options.has_key (opt):
+ if opt in options:
setattr (self, opt, options[opt])
else:
@@ -97,7 +97,7 @@ class TextFile:
# sanity check client option hash
for opt in options.keys():
- if not self.default_options.has_key (opt):
+ if opt not in self.default_options:
raise KeyError, "invalid TextFile option '%s'" % opt
if file is None:
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 1265f4c..1bcda93 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -200,11 +200,11 @@ def check_environ ():
if _environ_checked:
return
- if os.name == 'posix' and not os.environ.has_key('HOME'):
+ if os.name == 'posix' and 'HOME' not in os.environ:
import pwd
os.environ['HOME'] = pwd.getpwuid(os.getuid())[5]
- if not os.environ.has_key('PLAT'):
+ if 'PLAT' not in os.environ:
os.environ['PLAT'] = get_platform()
_environ_checked = 1
@@ -222,7 +222,7 @@ def subst_vars (s, local_vars):
check_environ()
def _subst (match, local_vars=local_vars):
var_name = match.group(1)
- if local_vars.has_key(var_name):
+ if var_name in local_vars:
return str(local_vars[var_name])
else:
return os.environ[var_name]