mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch 'stable'
This commit is contained in:
commit
99c9f60373
@ -29,7 +29,8 @@ install:
|
|||||||
- pip install -U pip setuptools
|
- pip install -U pip setuptools
|
||||||
- pip install docutils==$DOCUTILS
|
- pip install docutils==$DOCUTILS
|
||||||
- pip install -r test-reqs.txt
|
- pip install -r test-reqs.txt
|
||||||
before_script: flake8
|
before_script:
|
||||||
|
- if [[ $TRAVIS_PYTHON_VERSION != '2.6' ]]; then flake8; fi
|
||||||
script:
|
script:
|
||||||
- if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then make style-check test-async; fi
|
- if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then make style-check test-async; fi
|
||||||
- if [[ $TRAVIS_PYTHON_VERSION != '3.5' ]]; then make test; fi
|
- if [[ $TRAVIS_PYTHON_VERSION != '3.5' ]]; then make test; fi
|
||||||
|
2
CHANGES
2
CHANGES
@ -109,6 +109,8 @@ Bugs fixed
|
|||||||
* Change extension from .html to .xhtml.
|
* Change extension from .html to .xhtml.
|
||||||
* Disable search page on epub results
|
* Disable search page on epub results
|
||||||
|
|
||||||
|
* #2778: Fix autodoc crashes if obj.__dict__ is a property method and raises exception
|
||||||
|
* Fix duplicated toc in epub3 output.
|
||||||
|
|
||||||
Release 1.4.5 (released Jul 13, 2016)
|
Release 1.4.5 (released Jul 13, 2016)
|
||||||
=====================================
|
=====================================
|
||||||
|
@ -36,7 +36,7 @@ from sphinx.domains import ObjType
|
|||||||
from sphinx.domains.std import GenericObject, Target, StandardDomain
|
from sphinx.domains.std import GenericObject, Target, StandardDomain
|
||||||
from sphinx.environment import BuildEnvironment
|
from sphinx.environment import BuildEnvironment
|
||||||
from sphinx.io import SphinxStandaloneReader
|
from sphinx.io import SphinxStandaloneReader
|
||||||
from sphinx.util import pycompat # noqa: imported for side-effects
|
from sphinx.util import pycompat # noqa: F401
|
||||||
from sphinx.util import import_object
|
from sphinx.util import import_object
|
||||||
from sphinx.util.tags import Tags
|
from sphinx.util.tags import Tags
|
||||||
from sphinx.util.osutil import ENOENT
|
from sphinx.util.osutil import ENOENT
|
||||||
|
@ -74,7 +74,6 @@ PACKAGE_DOC_TEMPLATE = u'''\
|
|||||||
%(files)s
|
%(files)s
|
||||||
</manifest>
|
</manifest>
|
||||||
<spine toc="ncx" page-progression-direction="%(page_progression_direction)s">
|
<spine toc="ncx" page-progression-direction="%(page_progression_direction)s">
|
||||||
<itemref idref="nav" />
|
|
||||||
%(spine)s
|
%(spine)s
|
||||||
</spine>
|
</spine>
|
||||||
<guide>
|
<guide>
|
||||||
|
@ -110,12 +110,18 @@ def safe_getattr(obj, name, *defargs):
|
|||||||
except Exception:
|
except Exception:
|
||||||
# sometimes accessing a property raises an exception (e.g.
|
# sometimes accessing a property raises an exception (e.g.
|
||||||
# NotImplementedError), so let's try to read the attribute directly
|
# NotImplementedError), so let's try to read the attribute directly
|
||||||
if name in obj.__dict__:
|
try:
|
||||||
|
# In case the object does weird things with attribute access
|
||||||
|
# such that accessing `obj.__dict__` may raise an exception
|
||||||
return obj.__dict__[name]
|
return obj.__dict__[name]
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
# this is a catch-all for all the weird things that some modules do
|
# this is a catch-all for all the weird things that some modules do
|
||||||
# with attribute access
|
# with attribute access
|
||||||
if defargs:
|
if defargs:
|
||||||
return defargs[0]
|
return defargs[0]
|
||||||
|
|
||||||
raise AttributeError(name)
|
raise AttributeError(name)
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ else:
|
|||||||
# error handler
|
# error handler
|
||||||
sys_encoding = __import__('locale').getpreferredencoding()
|
sys_encoding = __import__('locale').getpreferredencoding()
|
||||||
# use Python 3 name
|
# use Python 3 name
|
||||||
from cgi import escape as htmlescape # noqa: 2.6, 2.7
|
from cgi import escape as htmlescape # noqa: F401
|
||||||
|
|
||||||
class UnicodeMixin(object):
|
class UnicodeMixin(object):
|
||||||
"""Mixin class to handle defining the proper __str__/__unicode__
|
"""Mixin class to handle defining the proper __str__/__unicode__
|
||||||
|
70
tests/test_util_inspect.py
Normal file
70
tests/test_util_inspect.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
test_util_inspect
|
||||||
|
~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Tests util.inspect functions.
|
||||||
|
|
||||||
|
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
||||||
|
:license: BSD, see LICENSE for details.
|
||||||
|
"""
|
||||||
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from sphinx.util import inspect
|
||||||
|
|
||||||
|
|
||||||
|
class TestSafeGetAttr(TestCase):
|
||||||
|
def test_safe_getattr_with_default(self):
|
||||||
|
class Foo(object):
|
||||||
|
def __getattr__(self, item):
|
||||||
|
raise Exception
|
||||||
|
|
||||||
|
obj = Foo()
|
||||||
|
|
||||||
|
result = inspect.safe_getattr(obj, 'bar', 'baz')
|
||||||
|
|
||||||
|
assert result == 'baz'
|
||||||
|
|
||||||
|
def test_safe_getattr_with_exception(self):
|
||||||
|
class Foo(object):
|
||||||
|
def __getattr__(self, item):
|
||||||
|
raise Exception
|
||||||
|
|
||||||
|
obj = Foo()
|
||||||
|
|
||||||
|
try:
|
||||||
|
inspect.safe_getattr(obj, 'bar')
|
||||||
|
except AttributeError as exc:
|
||||||
|
self.assertEqual(exc.args[0], 'bar')
|
||||||
|
else:
|
||||||
|
self.fail('AttributeError not raised')
|
||||||
|
|
||||||
|
def test_safe_getattr_with_property_exception(self):
|
||||||
|
class Foo(object):
|
||||||
|
@property
|
||||||
|
def bar(self):
|
||||||
|
raise Exception
|
||||||
|
|
||||||
|
obj = Foo()
|
||||||
|
|
||||||
|
try:
|
||||||
|
inspect.safe_getattr(obj, 'bar')
|
||||||
|
except AttributeError as exc:
|
||||||
|
self.assertEqual(exc.args[0], 'bar')
|
||||||
|
else:
|
||||||
|
self.fail('AttributeError not raised')
|
||||||
|
|
||||||
|
def test_safe_getattr_with___dict___override(self):
|
||||||
|
class Foo(object):
|
||||||
|
@property
|
||||||
|
def __dict__(self):
|
||||||
|
raise Exception
|
||||||
|
|
||||||
|
obj = Foo()
|
||||||
|
|
||||||
|
try:
|
||||||
|
inspect.safe_getattr(obj, 'bar')
|
||||||
|
except AttributeError as exc:
|
||||||
|
self.assertEqual(exc.args[0], 'bar')
|
||||||
|
else:
|
||||||
|
self.fail('AttributeError not raised')
|
Loading…
Reference in New Issue
Block a user