From dcfbb7b955a85aec77a0f1a0b20d2bee8ac97653 Mon Sep 17 00:00:00 2001 From: Glyph Date: Sat, 10 Sep 2016 06:15:48 -0700 Subject: [PATCH] remove unnecessary and ugly `exec_` compat hack (#87) --- src/attr/_compat.py | 6 ------ src/attr/_make.py | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/attr/_compat.py b/src/attr/_compat.py index 94ab75a867233a..792eda853772f2 100644 --- a/src/attr/_compat.py +++ b/src/attr/_compat.py @@ -17,9 +17,6 @@ def isclass(klass): # TYPE is used in exceptions, repr(int) is different on Python 2 and 3. TYPE = "type" - def exec_(code, locals_, globals_): - exec("exec code in locals_, globals_") - def iteritems(d): return d.iteritems() @@ -31,9 +28,6 @@ def isclass(klass): TYPE = "class" - def exec_(code, locals_, globals_): - exec(code, locals_, globals_) - def iteritems(d): return d.items() diff --git a/src/attr/_make.py b/src/attr/_make.py index 1bcf4413b8c89e..513bfbfe8ac09a 100644 --- a/src/attr/_make.py +++ b/src/attr/_make.py @@ -4,7 +4,7 @@ import linecache from . import _config -from ._compat import exec_, iteritems, isclass, iterkeys +from ._compat import iteritems, isclass, iterkeys from .exceptions import FrozenInstanceError # This is used at least twice, so cache it here. @@ -420,7 +420,7 @@ def _add_init(cls, frozen): # Save the lookup overhead in __init__ if we need to circumvent # immutability. globs["_cached_setattr"] = _obj_setattr - exec_(bytecode, globs, locs) + eval(bytecode, globs, locs) init = locs["__init__"] # In order of debuggers like PDB being able to step through the code,