From 3067d6d71087c56a63c05ad869b8a7e94e0d55e1 Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Mon, 14 Jul 2014 18:09:11 +0800 Subject: [PATCH] PY3: fix has_key and use six.moves.configparser --- scrapy/tests/test_utils_datatypes.py | 1 - scrapy/utils/conf.py | 2 +- scrapy/xlib/pydispatch/dispatcher.py | 6 +++--- scrapy/xlib/pydispatch/robustapply.py | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/scrapy/tests/test_utils_datatypes.py b/scrapy/tests/test_utils_datatypes.py index c8233f8fa57..b31d2179c8e 100644 --- a/scrapy/tests/test_utils_datatypes.py +++ b/scrapy/tests/test_utils_datatypes.py @@ -75,7 +75,6 @@ def test_contains(self): d = CaselessDict() d['a'] = 1 assert 'a' in d - assert d.has_key('a') def test_pop(self): d = CaselessDict() diff --git a/scrapy/utils/conf.py b/scrapy/utils/conf.py index 66799b573b4..8d2d01a3c45 100644 --- a/scrapy/utils/conf.py +++ b/scrapy/utils/conf.py @@ -1,6 +1,6 @@ import sys import os -from ConfigParser import SafeConfigParser +from six.moves.configparser import SafeConfigParser from operator import itemgetter def build_component_list(base, custom): diff --git a/scrapy/xlib/pydispatch/dispatcher.py b/scrapy/xlib/pydispatch/dispatcher.py index 284c4c95efa..08adff9218c 100644 --- a/scrapy/xlib/pydispatch/dispatcher.py +++ b/scrapy/xlib/pydispatch/dispatcher.py @@ -134,7 +134,7 @@ def connect(receiver, signal=Any, sender=Any, weak=True): if weak: receiver = saferef.safeRef(receiver, onDelete=_removeReceiver) senderkey = id(sender) - if connections.has_key(senderkey): + if senderkey in connections: signals = connections[senderkey] else: connections[senderkey] = signals = {} @@ -154,7 +154,7 @@ def remove(object, senderkey=senderkey): receiverID = id(receiver) # get current set, remove any current references to # this receiver in the set, including back-references - if signals.has_key(signal): + if signal in signals: receivers = signals[signal] _removeOldBackRefs(senderkey, signal, receiver, receivers) else: @@ -290,7 +290,7 @@ def getAllReceivers( sender = Any, signal = Any ): for receiver in set: if receiver: # filter out dead instance-method weakrefs try: - if not receivers.has_key( receiver ): + if receiver not in receivers: receivers[receiver] = 1 yield receiver except TypeError: diff --git a/scrapy/xlib/pydispatch/robustapply.py b/scrapy/xlib/pydispatch/robustapply.py index cfd41425c36..5deda3c4289 100644 --- a/scrapy/xlib/pydispatch/robustapply.py +++ b/scrapy/xlib/pydispatch/robustapply.py @@ -37,7 +37,7 @@ def robustApply(receiver, *arguments, **named): receiver, codeObject, startIndex = function(receiver) acceptable = codeObject.co_varnames[startIndex+len(arguments):codeObject.co_argcount] for name in codeObject.co_varnames[startIndex:startIndex+len(arguments)]: - if named.has_key(name): + if name in named: raise TypeError( """Argument %r specified both positionally and as a keyword for calling %r"""% ( name, receiver,