mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
merge in Ben's bundle with more py3k compatibility
This commit is contained in:
commit
beb141c1c7
@ -137,7 +137,7 @@ class Config(object):
|
||||
if name not in self.values:
|
||||
raise AttributeError('No such config value: %s' % name)
|
||||
default = self.values[name][0]
|
||||
if callable(default):
|
||||
if hasattr(default, '__call__'):
|
||||
return default(self)
|
||||
return default
|
||||
|
||||
|
@ -541,7 +541,7 @@ class BuildEnvironment:
|
||||
doctree = pub.document
|
||||
except UnicodeError, err:
|
||||
from sphinx.application import SphinxError
|
||||
raise SphinxError(err.message)
|
||||
raise SphinxError(str(err))
|
||||
self.filter_messages(doctree)
|
||||
self.process_dependencies(docname, doctree)
|
||||
self.process_images(docname, doctree)
|
||||
|
@ -166,7 +166,7 @@ def between(marker, what=None, keepempty=False):
|
||||
def isdescriptor(x):
|
||||
"""Check if the object is some kind of descriptor."""
|
||||
for item in '__get__', '__set__', '__delete__':
|
||||
if callable(getattr(x, item, None)):
|
||||
if hasattr(getattr(x, item, None), '__call__'):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -284,7 +284,7 @@ def generate_tokens(readline):
|
||||
|
||||
if contstr: # continued string
|
||||
if not line:
|
||||
raise TokenError, ("EOF in multi-line string", strstart)
|
||||
raise TokenError("EOF in multi-line string", strstart)
|
||||
endmatch = endprog.match(line)
|
||||
if endmatch:
|
||||
pos = end = endmatch.end(0)
|
||||
@ -340,7 +340,7 @@ def generate_tokens(readline):
|
||||
|
||||
else: # continued statement
|
||||
if not line:
|
||||
raise TokenError, ("EOF in multi-line statement", (lnum, 0))
|
||||
raise TokenError("EOF in multi-line statement", (lnum, 0))
|
||||
continued = 0
|
||||
|
||||
while pos < max:
|
||||
|
@ -27,7 +27,7 @@ def make_admonition(node_class, name, arguments, options, content, lineno,
|
||||
textnodes, messages = state.inline_text(title_text, lineno)
|
||||
admonition_node += nodes.title(title_text, '', *textnodes)
|
||||
admonition_node += messages
|
||||
if options.has_key('class'):
|
||||
if 'class' in options:
|
||||
classes = options['class']
|
||||
else:
|
||||
classes = ['admonition-' + nodes.make_id(title_text)]
|
||||
|
@ -129,7 +129,7 @@ def test_html(app):
|
||||
for path, check in paths.iteritems():
|
||||
nodes = list(etree.findall(path))
|
||||
assert nodes != []
|
||||
if callable(check):
|
||||
if hasattr(check, '__call__'):
|
||||
check(nodes)
|
||||
elif not check:
|
||||
# only check for node presence
|
||||
|
Loading…
Reference in New Issue
Block a user