Eliminate exec() in Universe.new()
authorJeremy Stanley <fungi@yuggoth.org>
Tue, 24 Dec 2019 22:23:32 +0000 (22:23 +0000)
committerJeremy Stanley <fungi@yuggoth.org>
Sat, 28 Dec 2019 20:40:11 +0000 (20:40 +0000)
Replace questionable exec call in the new() method of the Universe
class with cleaner getattr/setattr equivalents.

mudpy/misc.py

index eea2f00..fca279a 100644 (file)
@@ -406,7 +406,7 @@ class Universe:
         """Create a new, empty Universe (the Big Bang)."""
         new_universe = Universe()
         for attribute in vars(self).keys():
-            exec("new_universe." + attribute + " = self." + attribute)
+            setattr(new_universe, attribute, getattr(self, attribute))
         new_universe.reload_flag = False
         del self
         return new_universe