The reload function is in the imp module
authorJeremy Stanley <fungi@yuggoth.org>
Wed, 30 Jan 2013 00:28:34 +0000 (00:28 +0000)
committerJeremy Stanley <fungi@yuggoth.org>
Wed, 30 Jan 2013 00:28:34 +0000 (00:28 +0000)
* bin/mudpy
* lib/mudpy/__init__.py: For Py3K compatibility, only invoke the reload
function from the imp module rather than the global built-in namespace.

bin/mudpy
lib/mudpy/__init__.py

index b1071e3..e946462 100755 (executable)
--- a/bin/mudpy
+++ b/bin/mudpy
@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 """Skeletal executable for the mudpy engine."""
 
 # -*- coding: utf-8 -*-
 """Skeletal executable for the mudpy engine."""
 
-# Copyright (c) 2004-2011 Jeremy Stanley <fungi@yuggoth.org>. Permission
+# Copyright (c) 2004-2013 Jeremy Stanley <fungi@yuggoth.org>. Permission
 # to use, copy, modify, and distribute this software is granted under
 # terms provided in the LICENSE file distributed with this software.
 
 # to use, copy, modify, and distribute this software is granted under
 # terms provided in the LICENSE file distributed with this software.
 
@@ -10,6 +10,7 @@
 import os.path
 import sys
 sys.path.append( os.path.realpath("lib") )
 import os.path
 import sys
 sys.path.append( os.path.realpath("lib") )
+import imp
 import mudpy
 
 # start it up
 import mudpy
 
 # start it up
@@ -21,7 +22,7 @@ while not mudpy.misc.universe.terminate_flag or mudpy.misc.universe.userlist:
 
     # the world was flagged for a reload of all code/data
     if mudpy.misc.universe.reload_flag:
 
     # the world was flagged for a reload of all code/data
     if mudpy.misc.universe.reload_flag:
-        reload(mudpy)
+        imp.reload(mudpy)
         mudpy.misc.reload_data()
         mudpy.misc.universe.reload_flag = False
 
         mudpy.misc.reload_data()
         mudpy.misc.universe.reload_flag = False
 
index 8e077f7..4224b2f 100644 (file)
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 """Core modules package for the mudpy engine."""
 
 # -*- coding: utf-8 -*-
 """Core modules package for the mudpy engine."""
 
-# Copyright (c) 2004-2012 Jeremy Stanley <fungi@yuggoth.org>. Permission
+# Copyright (c) 2004-2013 Jeremy Stanley <fungi@yuggoth.org>. Permission
 # to use, copy, modify, and distribute this software is granted under
 # terms provided in the LICENSE file distributed with this software.
 
 # to use, copy, modify, and distribute this software is granted under
 # terms provided in the LICENSE file distributed with this software.
 
@@ -9,6 +9,8 @@
 def load():
     """Import/reload some modules (be careful, as this can result in loops)."""
 
 def load():
     """Import/reload some modules (be careful, as this can result in loops)."""
 
+    import imp
+
     # pick up the modules list from this package
     global modules
 
     # pick up the modules list from this package
     global modules
 
@@ -18,7 +20,7 @@ def load():
         # attempt to reload the module, assuming it was probably imported
         # earlier
         try:
         # attempt to reload the module, assuming it was probably imported
         # earlier
         try:
-            exec("reload(%s)" % module)
+            exec("imp.reload(%s)" % module)
 
         # must not have been, so import it now
         except NameError:
 
         # must not have been, so import it now
         except NameError: