Dealing with deprecated next()

This commit is contained in:
Miroslav Stampar
2019-01-22 02:47:06 +01:00
parent 2c270ed250
commit 1adc66b763
13 changed files with 32 additions and 32 deletions

View File

@@ -370,7 +370,7 @@ class PageElement(object):
g = generator()
while True:
try:
i = g.next()
i = next(g)
except StopIteration:
break
if i:
@@ -470,7 +470,7 @@ class NavigableString(unicode, PageElement):
if attr == 'string':
return self
else:
raise AttributeError, "'%s' object has no attribute '%s'" % (self.__class__.__name__, attr)
raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, attr))
def __unicode__(self):
return str(self).decode(DEFAULT_OUTPUT_ENCODING)
@@ -668,7 +668,7 @@ class Tag(PageElement):
return self.find(tag[:-3])
elif tag.find('__') != 0:
return self.find(tag)
raise AttributeError, "'%s' object has no attribute '%s'" % (self.__class__, tag)
raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__, tag))
def __eq__(self, other):
"""Returns true iff this tag has the same name, the same attributes,
@@ -974,8 +974,8 @@ class SoupStrainer:
if self._matches(markup, self.text):
found = markup
else:
raise Exception, "I don't know how to match against a %s" \
% markup.__class__
raise Exception("I don't know how to match against a %s" \
% markup.__class__)
return found
def _matches(self, markup, matchAgainst):