Closes issue 17660. You no longer need to explicitly pass create=True when patching builtin names.

This commit is contained in:
Michael Foord 2014-04-14 16:25:20 -04:00
parent fba913f77a
commit fddcfa27fa
3 changed files with 52 additions and 4 deletions

View file

@ -27,9 +27,13 @@ __version__ = '1.0'
import inspect
import pprint
import sys
import builtins
from types import ModuleType
from functools import wraps, partial
_builtins = {name for name in dir(builtins) if not name.startswith('_')}
BaseExceptions = (BaseException,)
if 'java' in sys.platform:
# jython
@ -1166,6 +1170,9 @@ class _patch(object):
else:
local = True
if name in _builtins and isinstance(target, ModuleType):
self.create = True
if not self.create and original is DEFAULT:
raise AttributeError(
"%s does not have the attribute %r" % (target, name)