Merge branch 'stable'

This commit is contained in:
Takeshi KOMIYA 2016-07-26 14:26:11 +09:00
commit 99c9f60373
7 changed files with 83 additions and 5 deletions

View File

@ -29,7 +29,8 @@ install:
- pip install -U pip setuptools
- pip install docutils==$DOCUTILS
- pip install -r test-reqs.txt
before_script: flake8
before_script:
- if [[ $TRAVIS_PYTHON_VERSION != '2.6' ]]; then flake8; fi
script:
- if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then make style-check test-async; fi
- if [[ $TRAVIS_PYTHON_VERSION != '3.5' ]]; then make test; fi

View File

@ -109,6 +109,8 @@ Bugs fixed
* Change extension from .html to .xhtml.
* 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)
=====================================

View File

@ -36,7 +36,7 @@ from sphinx.domains import ObjType
from sphinx.domains.std import GenericObject, Target, StandardDomain
from sphinx.environment import BuildEnvironment
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.tags import Tags
from sphinx.util.osutil import ENOENT

View File

@ -74,7 +74,6 @@ PACKAGE_DOC_TEMPLATE = u'''\
%(files)s
</manifest>
<spine toc="ncx" page-progression-direction="%(page_progression_direction)s">
<itemref idref="nav" />
%(spine)s
</spine>
<guide>

View File

@ -110,12 +110,18 @@ def safe_getattr(obj, name, *defargs):
except Exception:
# sometimes accessing a property raises an exception (e.g.
# 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]
except Exception:
pass
# this is a catch-all for all the weird things that some modules do
# with attribute access
if defargs:
return defargs[0]
raise AttributeError(name)

View File

@ -80,7 +80,7 @@ else:
# error handler
sys_encoding = __import__('locale').getpreferredencoding()
# 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):
"""Mixin class to handle defining the proper __str__/__unicode__

View 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')