mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix inspect using the "__builtins__" CPython specific module.
This commit is contained in:
parent
2a2b59598c
commit
f3dba82564
@ -16,7 +16,7 @@ import sys
|
|||||||
inspect = __import__('inspect')
|
inspect = __import__('inspect')
|
||||||
|
|
||||||
from sphinx.util import force_decode
|
from sphinx.util import force_decode
|
||||||
from sphinx.util.pycompat import bytes
|
from sphinx.util.pycompat import bytes, builtins
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info >= (3, 0):
|
if sys.version_info >= (3, 0):
|
||||||
@ -151,6 +151,6 @@ def is_builtin_class_method(obj, attr_name):
|
|||||||
classes = [c for c in inspect.getmro(obj) if attr_name in c.__dict__]
|
classes = [c for c in inspect.getmro(obj) if attr_name in c.__dict__]
|
||||||
cls = classes[0] if classes else object
|
cls = classes[0] if classes else object
|
||||||
|
|
||||||
if not hasattr(__builtins__, cls.__name__):
|
if not hasattr(builtins, safe_getattr(cls, '__name__', '')):
|
||||||
return False
|
return False
|
||||||
return getattr(__builtins__, cls.__name__) is cls
|
return getattr(builtins, safe_getattr(cls, '__name__', '')) is cls
|
||||||
|
@ -48,6 +48,8 @@ if sys.version_info >= (3, 0):
|
|||||||
# try to match ParseError details with SyntaxError details
|
# try to match ParseError details with SyntaxError details
|
||||||
raise SyntaxError(err.msg, (filepath, lineno, offset, err.value))
|
raise SyntaxError(err.msg, (filepath, lineno, offset, err.value))
|
||||||
return unicode(tree)
|
return unicode(tree)
|
||||||
|
from itertools import zip_longest # Python 3 name
|
||||||
|
import builtins
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Python 2
|
# Python 2
|
||||||
@ -69,6 +71,9 @@ else:
|
|||||||
# error handler
|
# error handler
|
||||||
import locale
|
import locale
|
||||||
sys_encoding = locale.getpreferredencoding()
|
sys_encoding = locale.getpreferredencoding()
|
||||||
|
# use Python 3 name
|
||||||
|
from itertools import izip_longest as zip_longest
|
||||||
|
import __builtin__ as builtins
|
||||||
|
|
||||||
|
|
||||||
def execfile_(filepath, _globals):
|
def execfile_(filepath, _globals):
|
||||||
|
Loading…
Reference in New Issue
Block a user