From ebf69ce28455d6e1a329686b821a78bceb9a9b56 Mon Sep 17 00:00:00 2001 From: Glyph Date: Sat, 10 Sep 2016 05:37:42 -0700 Subject: [PATCH] remove unnecessary and ugly `exec_` compat hack --- 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 94ab75a86..792eda853 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 764fe552f..93756c7a5 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. @@ -418,7 +418,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,