[Python-3000-checkins] r55727 - in python/branches/p3yk: Demo/imputil/knee.py Doc/api/utilities.tex Doc/ext/extending.tex Doc/lib/libfuncs.tex Doc/lib/libimp.tex Doc/lib/libsys.tex Doc/lib/libzipimport.tex Doc/tut/tut.tex Lib/idlelib/StackViewer.py Lib/ihooks.py Lib/imputil.py Lib/pydoc.py Lib/test/infinite_reload.py Lib/test/output/test_pkg Lib/test/regrtest.py Lib/test/test_builtin.py Lib/test/test_doctest.py Lib/test/test_import.py Lib/test/test_importhooks.py Lib/test/test_pkg.py Lib/test/test_traceback.py Lib/test/test_xmlrpc.py Misc/NEWS Misc/cheatsheet Python/bltinmodule.c

neal.norwitz python-3000-checkins at python.org
Fri Jun 1 07:19:55 CEST 2007


Author: neal.norwitz
Date: Fri Jun  1 07:19:44 2007
New Revision: 55727

Removed:
   python/branches/p3yk/Lib/test/infinite_reload.py
Modified:
   python/branches/p3yk/Demo/imputil/knee.py
   python/branches/p3yk/Doc/api/utilities.tex
   python/branches/p3yk/Doc/ext/extending.tex
   python/branches/p3yk/Doc/lib/libfuncs.tex
   python/branches/p3yk/Doc/lib/libimp.tex
   python/branches/p3yk/Doc/lib/libsys.tex
   python/branches/p3yk/Doc/lib/libzipimport.tex
   python/branches/p3yk/Doc/tut/tut.tex
   python/branches/p3yk/Lib/idlelib/StackViewer.py
   python/branches/p3yk/Lib/ihooks.py
   python/branches/p3yk/Lib/imputil.py
   python/branches/p3yk/Lib/pydoc.py
   python/branches/p3yk/Lib/test/output/test_pkg
   python/branches/p3yk/Lib/test/regrtest.py
   python/branches/p3yk/Lib/test/test_builtin.py
   python/branches/p3yk/Lib/test/test_doctest.py
   python/branches/p3yk/Lib/test/test_import.py
   python/branches/p3yk/Lib/test/test_importhooks.py
   python/branches/p3yk/Lib/test/test_pkg.py
   python/branches/p3yk/Lib/test/test_traceback.py
   python/branches/p3yk/Lib/test/test_xmlrpc.py
   python/branches/p3yk/Misc/NEWS
   python/branches/p3yk/Misc/cheatsheet
   python/branches/p3yk/Python/bltinmodule.c
Log:
Remove reload() builtin.

Modified: python/branches/p3yk/Demo/imputil/knee.py
==============================================================================
--- python/branches/p3yk/Demo/imputil/knee.py	(original)
+++ python/branches/p3yk/Demo/imputil/knee.py	Fri Jun  1 07:19:44 2007
@@ -106,8 +106,7 @@
     return m
 
 
-# Replacement for reload()
-def reload_hook(module):
+def reload(module):
     name = module.__name__
     if '.' not in name:
         return import_module(name, name, None)
@@ -119,8 +118,6 @@
 
 # Save the original hooks
 original_import = __builtin__.__import__
-original_reload = __builtin__.reload
 
 # Now install our hooks
 __builtin__.__import__ = import_hook
-__builtin__.reload = reload_hook

Modified: python/branches/p3yk/Doc/api/utilities.tex
==============================================================================
--- python/branches/p3yk/Doc/api/utilities.tex	(original)
+++ python/branches/p3yk/Doc/api/utilities.tex	Fri Jun  1 07:19:44 2007
@@ -140,10 +140,7 @@
 \end{cfuncdesc}
 
 \begin{cfuncdesc}{PyObject*}{PyImport_ReloadModule}{PyObject *m}
-  Reload a module.  This is best described by referring to the
-  built-in Python function \function{reload()}\bifuncindex{reload}, as
-  the standard \function{reload()} function calls this function
-  directly.  Return a new reference to the reloaded module, or \NULL{}
+  Reload a module.  Return a new reference to the reloaded module, or \NULL{}
   with an exception set on failure (the module still exists in this
   case).
 \end{cfuncdesc}

Modified: python/branches/p3yk/Doc/ext/extending.tex
==============================================================================
--- python/branches/p3yk/Doc/ext/extending.tex	(original)
+++ python/branches/p3yk/Doc/ext/extending.tex	Fri Jun  1 07:19:44 2007
@@ -400,11 +400,6 @@
 \cfunction{exec()}) can create problems for some extension modules.
 Extension module authors should exercise caution when initializing
 internal data structures.
-Note also that the \function{reload()} function can be used with
-extension modules, and will call the module initialization function
-(\cfunction{initspam()} in the example), but will not load the module
-again if it was loaded from a dynamically loadable object file
-(\file{.so} on \UNIX, \file{.dll} on Windows).}
 
 A more substantial example module is included in the Python source
 distribution as \file{Modules/xxmodule.c}.  This file may be used as a 

Modified: python/branches/p3yk/Doc/lib/libfuncs.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/libfuncs.tex	(original)
+++ python/branches/p3yk/Doc/lib/libfuncs.tex	Fri Jun  1 07:19:44 2007
@@ -890,82 +890,6 @@
 \end{verbatim}
 \end{funcdesc}
 
-\begin{funcdesc}{reload}{module}
-  Reload a previously imported \var{module}.  The
-  argument must be a module object, so it must have been successfully
-  imported before.  This is useful if you have edited the module
-  source file using an external editor and want to try out the new
-  version without leaving the Python interpreter.  The return value is
-  the module object (the same as the \var{module} argument).
-
-  When \code{reload(module)} is executed:
-
-\begin{itemize}
-
-    \item Python modules' code is recompiled and the module-level code
-    reexecuted, defining a new set of objects which are bound to names in
-    the module's dictionary.  The \code{init} function of extension
-    modules is not called a second time.
-
-    \item As with all other objects in Python the old objects are only
-    reclaimed after their reference counts drop to zero.
-
-    \item The names in the module namespace are updated to point to
-    any new or changed objects.
-
-    \item Other references to the old objects (such as names external
-    to the module) are not rebound to refer to the new objects and
-    must be updated in each namespace where they occur if that is
-    desired.
-
-\end{itemize}
-
-  There are a number of other caveats:
-
-  If a module is syntactically correct but its initialization fails,
-  the first \keyword{import} statement for it does not bind its name
-  locally, but does store a (partially initialized) module object in
-  \code{sys.modules}.  To reload the module you must first
-  \keyword{import} it again (this will bind the name to the partially
-  initialized module object) before you can \function{reload()} it.
-
-  When a module is reloaded, its dictionary (containing the module's
-  global variables) is retained.  Redefinitions of names will override
-  the old definitions, so this is generally not a problem.  If the new
-  version of a module does not define a name that was defined by the
-  old version, the old definition remains.  This feature can be used
-  to the module's advantage if it maintains a global table or cache of
-  objects --- with a \keyword{try} statement it can test for the
-  table's presence and skip its initialization if desired:
-
-\begin{verbatim}
-try:
-    cache
-except NameError:
-    cache = {}
-\end{verbatim}
-
-
-  It is legal though generally not very useful to reload built-in or
-  dynamically loaded modules, except for \refmodule{sys},
-  \refmodule[main]{__main__} and \refmodule[builtin]{__builtin__}.  In
-  many cases, however, extension modules are not designed to be
-  initialized more than once, and may fail in arbitrary ways when
-  reloaded.
-
-  If a module imports objects from another module using \keyword{from}
-  \ldots{} \keyword{import} \ldots{}, calling \function{reload()} for
-  the other module does not redefine the objects imported from it ---
-  one way around this is to re-execute the \keyword{from} statement,
-  another is to use \keyword{import} and qualified names
-  (\var{module}.\var{name}) instead.
-
-  If a module instantiates instances of a class, reloading the module
-  that defines the class does not affect the method definitions of the
-  instances --- they continue to use the old class definition.  The
-  same is true for derived classes.
-\end{funcdesc}
-
 \begin{funcdesc}{repr}{object}
   Return a string containing a printable representation of an object.
   This is the same value yielded by conversions (reverse quotes).

Modified: python/branches/p3yk/Doc/lib/libimp.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/libimp.tex	(original)
+++ python/branches/p3yk/Doc/lib/libimp.tex	Fri Jun  1 07:19:44 2007
@@ -69,8 +69,7 @@
 Load a module that was previously found by \function{find_module()} (or by
 an otherwise conducted search yielding compatible results).  This
 function does more than importing the module: if the module was
-already imported, it is equivalent to a
-\function{reload()}\bifuncindex{reload}!  The \var{name} argument
+already imported, it will reload the module! The \var{name} argument
 indicates the full module name (including the package name, if this is
 a submodule of a package).  The \var{file} argument is an open file,
 and \var{filename} is the corresponding file name; these can be
@@ -286,7 +285,7 @@
 \end{verbatim}
 
 A more complete example that implements hierarchical module names and
-includes a \function{reload()}\bifuncindex{reload} function can be
+includes a \function{reload()} function can be
 found in the module \module{knee}\refmodindex{knee}.  The
 \module{knee} module can be found in \file{Demo/imputil/} in the
 Python source distribution.

Modified: python/branches/p3yk/Doc/lib/libsys.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/libsys.tex	(original)
+++ python/branches/p3yk/Doc/lib/libsys.tex	Fri Jun  1 07:19:44 2007
@@ -346,10 +346,7 @@
 \begin{datadesc}{modules}
   This is a dictionary that maps module names to modules which have
   already been loaded.  This can be manipulated to force reloading of
-  modules and other tricks.  Note that removing a module from this
-  dictionary is \emph{not} the same as calling
-  \function{reload()}\bifuncindex{reload} on the corresponding module
-  object.
+  modules and other tricks.
 \end{datadesc}
 
 \begin{datadesc}{path}

Modified: python/branches/p3yk/Doc/lib/libzipimport.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/libzipimport.tex	(original)
+++ python/branches/p3yk/Doc/lib/libzipimport.tex	Fri Jun  1 07:19:44 2007
@@ -29,11 +29,6 @@
 if a ZIP archive doesn't contain \file{.pyc} files, importing may be rather
 slow.
 
-Using the built-in \function{reload()} function will
-fail if called on a module loaded from a ZIP archive; it is unlikely that
-\function{reload()} would be needed, since this would imply that the ZIP
-has been altered during runtime.
-
 The available attributes of this module are:
 
 \begin{excdesc}{ZipImportError}

Modified: python/branches/p3yk/Doc/tut/tut.tex
==============================================================================
--- python/branches/p3yk/Doc/tut/tut.tex	(original)
+++ python/branches/p3yk/Doc/tut/tut.tex	Fri Jun  1 07:19:44 2007
@@ -2703,7 +2703,7 @@
  'id', 'input', 'int', 'isinstance', 'issubclass', 'iter',
  'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min',
  'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range',
- 'reload', 'repr', 'reversed', 'round', 'set',
+ 'repr', 'reversed', 'round', 'set',
  'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super',
  'tuple', 'type', 'unichr', 'unicode', 'vars', 'zip']
 \end{verbatim}

Modified: python/branches/p3yk/Lib/idlelib/StackViewer.py
==============================================================================
--- python/branches/p3yk/Lib/idlelib/StackViewer.py	(original)
+++ python/branches/p3yk/Lib/idlelib/StackViewer.py	Fri Jun  1 07:19:44 2007
@@ -120,18 +120,3 @@
             item = make_objecttreeitem(key + " =", value, setfunction)
             sublist.append(item)
         return sublist
-
-
-def _test():
-    try:
-        import testcode
-        reload(testcode)
-    except:
-        sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info()
-    from Tkinter import Tk
-    root = Tk()
-    StackBrowser(None, top=root)
-    root.mainloop()
-
-if __name__ == "__main__":
-    _test()

Modified: python/branches/p3yk/Lib/ihooks.py
==============================================================================
--- python/branches/p3yk/Lib/ihooks.py	(original)
+++ python/branches/p3yk/Lib/ihooks.py	Fri Jun  1 07:19:44 2007
@@ -45,9 +45,7 @@
 If a module importer class supports dotted names, its import_module()
 must return a different value depending on whether it is called on
 behalf of a "from ... import ..." statement or not.  (This is caused
-by the way the __import__ hook is used by the Python interpreter.)  It
-would also do wise to install a different version of reload().
-
+by the way the __import__ hook is used by the Python interpreter.)
 """
 
 
@@ -379,17 +377,14 @@
 
     def install(self):
         self.save_import_module = __builtin__.__import__
-        self.save_reload = __builtin__.reload
         if not hasattr(__builtin__, 'unload'):
             __builtin__.unload = None
         self.save_unload = __builtin__.unload
         __builtin__.__import__ = self.import_module
-        __builtin__.reload = self.reload
         __builtin__.unload = self.unload
 
     def uninstall(self):
         __builtin__.__import__ = self.save_import_module
-        __builtin__.reload = self.save_reload
         __builtin__.unload = self.save_unload
         if not __builtin__.unload:
             del __builtin__.unload

Modified: python/branches/p3yk/Lib/imputil.py
==============================================================================
--- python/branches/p3yk/Lib/imputil.py	(original)
+++ python/branches/p3yk/Lib/imputil.py	Fri Jun  1 07:19:44 2007
@@ -40,9 +40,6 @@
         self.namespace = namespace
         namespace['__import__'] = self._import_hook
 
-        ### fix this
-        #namespace['reload'] = self._reload_hook
-
     def uninstall(self):
         "Restore the previous import mechanism."
         self.namespace['__import__'] = self.previous_importer
@@ -194,22 +191,6 @@
                 return module
         return None
 
-    def _reload_hook(self, module):
-        "Python calls this hook to reload a module."
-
-        # reloading of a module may or may not be possible (depending on the
-        # importer), but at least we can validate that it's ours to reload
-        importer = module.__dict__.get('__importer__')
-        if not importer:
-            ### oops. now what...
-            pass
-
-        # okay. it is using the imputil system, and we must delegate it, but
-        # we don't know what to do (yet)
-        ### we should blast the module dict and do another get_code(). need to
-        ### flesh this out and add proper docco...
-        raise SystemError, "reload not yet implemented"
-
 
 class Importer:
     "Base class for replacing standard import functions."
@@ -682,7 +663,6 @@
 #   flag to force absolute imports? (speeds _determine_import_context and
 #       checking for a relative module)
 #   insert names of archives into sys.path  (see quote below)
-#   note: reload does NOT blast module dict
 #   shift import mechanisms and policies around; provide for hooks, overrides
 #       (see quote below)
 #   add get_source stuff

Modified: python/branches/p3yk/Lib/pydoc.py
==============================================================================
--- python/branches/p3yk/Lib/pydoc.py	(original)
+++ python/branches/p3yk/Lib/pydoc.py	Fri Jun  1 07:19:44 2007
@@ -273,12 +273,11 @@
         # that inherits from another module that has changed).
         if forceload and path in sys.modules:
             if path not in sys.builtin_module_names:
-                # Avoid simply calling reload() because it leaves names in
-                # the currently loaded module lying around if they're not
-                # defined in the new source file.  Instead, remove the
-                # module from sys.modules and re-import.  Also remove any
-                # submodules because they won't appear in the newly loaded
-                # module's namespace if they're already in sys.modules.
+                # Remove the module from sys.modules and re-import to try
+                # and avoid problems with partially loaded modules.
+                # Also remove any submodules because they won't appear
+                # in the newly loaded module's namespace if they're already
+                # in sys.modules.
                 subs = [m for m in sys.modules if m.startswith(path + '.')]
                 for key in [path] + subs:
                     # Prevent garbage collection.

Deleted: /python/branches/p3yk/Lib/test/infinite_reload.py
==============================================================================
--- /python/branches/p3yk/Lib/test/infinite_reload.py	Fri Jun  1 07:19:44 2007
+++ (empty file)
@@ -1,7 +0,0 @@
-# For testing http://python.org/sf/742342, which reports that Python
-#  segfaults (infinite recursion in C) in the presence of infinite
-#  reload()ing. This module is imported by test_import.py:test_infinite_reload
-#  to make sure this doesn't happen any more.
-
-import infinite_reload
-reload(infinite_reload)

Modified: python/branches/p3yk/Lib/test/output/test_pkg
==============================================================================
--- python/branches/p3yk/Lib/test/output/test_pkg	(original)
+++ python/branches/p3yk/Lib/test/output/test_pkg	Fri Jun  1 07:19:44 2007
@@ -15,8 +15,6 @@
 t3 loading
 t3.sub.subsub loading
 t3 t3.sub t3.sub.subsub
-t3 loading
-t3.sub.subsub loading
 running test t4
 t4 loading
 t4.sub.subsub loading

Modified: python/branches/p3yk/Lib/test/regrtest.py
==============================================================================
--- python/branches/p3yk/Lib/test/regrtest.py	(original)
+++ python/branches/p3yk/Lib/test/regrtest.py	Fri Jun  1 07:19:44 2007
@@ -669,7 +669,8 @@
             indirect_test()
     else:
         def run_the_test():
-            reload(the_module)
+            del sys.modules[the_module.__name__]
+            exec('import ' + the_module.__name__)
 
     deltas = []
     nwarmup, ntracked, fname = huntrleaks

Modified: python/branches/p3yk/Lib/test/test_builtin.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_builtin.py	(original)
+++ python/branches/p3yk/Lib/test/test_builtin.py	Fri Jun  1 07:19:44 2007
@@ -1558,14 +1558,6 @@
             fp.close()
             unlink(TESTFN)
 
-    def test_reload(self):
-        import marshal
-        reload(marshal)
-        import string
-        reload(string)
-        ## import sys
-        ## self.assertRaises(ImportError, reload, sys)
-
     def test_repr(self):
         self.assertEqual(repr(''), '\'\'')
         self.assertEqual(repr(0), '0')

Modified: python/branches/p3yk/Lib/test/test_doctest.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_doctest.py	(original)
+++ python/branches/p3yk/Lib/test/test_doctest.py	Fri Jun  1 07:19:44 2007
@@ -2409,7 +2409,7 @@
 def test_coverage(coverdir):
     tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,],
                          trace=0, count=1)
-    tracer.run('reload(doctest); test_main()')
+    tracer.run('test_main()')
     r = tracer.results()
     print('Writing coverage results...')
     r.write_results(show_missing=True, summary=True,

Modified: python/branches/p3yk/Lib/test/test_import.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_import.py	(original)
+++ python/branches/p3yk/Lib/test/test_import.py	Fri Jun  1 07:19:44 2007
@@ -6,6 +6,7 @@
 import sys
 import py_compile
 import warnings
+from test.test_support import unlink
 
 
 def remove_files(name):
@@ -63,22 +64,9 @@
                 self.assertEquals(mod.b, b,
                     "module loaded (%s) but contents invalid" % mod)
             finally:
-                os.unlink(source)
-
-            try:
-                try:
-                    reload(mod)
-                except ImportError as err:
-                    self.fail("import from .pyc/.pyo failed: %s" % err)
-            finally:
-                try:
-                    os.unlink(pyc)
-                except OSError:
-                    pass
-                try:
-                    os.unlink(pyo)
-                except OSError:
-                    pass
+                unlink(source)
+                unlink(pyc)
+                unlink(pyo)
                 del sys.modules[TESTFN]
 
         sys.path.insert(0, os.curdir)
@@ -136,6 +124,8 @@
         # New in 2.4, we shouldn't be able to import that no matter how often
         # we try.
         sys.path.insert(0, os.curdir)
+        if TESTFN in sys.modules:
+            del sys.modules[TESTFN]
         try:
             for i in 1, 2, 3:
                 try:
@@ -149,60 +139,6 @@
             sys.path.pop(0)
             remove_files(TESTFN)
 
-    def test_failing_reload(self):
-        # A failing reload should leave the module object in sys.modules.
-        source = TESTFN + os.extsep + "py"
-        f = open(source, "w")
-        print("a = 1", file=f)
-        print("b = 2", file=f)
-        f.close()
-
-        sys.path.insert(0, os.curdir)
-        try:
-            mod = __import__(TESTFN)
-            self.assert_(TESTFN in sys.modules, "expected module in sys.modules")
-            self.assertEquals(mod.a, 1, "module has wrong attribute values")
-            self.assertEquals(mod.b, 2, "module has wrong attribute values")
-
-            # On WinXP, just replacing the .py file wasn't enough to
-            # convince reload() to reparse it.  Maybe the timestamp didn't
-            # move enough.  We force it to get reparsed by removing the
-            # compiled file too.
-            remove_files(TESTFN)
-
-            # Now damage the module.
-            f = open(source, "w")
-            print("a = 10", file=f)
-            print("b = 20//0", file=f)
-            f.close()
-
-            self.assertRaises(ZeroDivisionError, reload, mod)
-
-            # But we still expect the module to be in sys.modules.
-            mod = sys.modules.get(TESTFN)
-            self.failIf(mod is None, "expected module to still be in sys.modules")
-
-            # We should have replaced a w/ 10, but the old b value should
-            # stick.
-            self.assertEquals(mod.a, 10, "module has wrong attribute values")
-            self.assertEquals(mod.b, 2, "module has wrong attribute values")
-
-        finally:
-            sys.path.pop(0)
-            remove_files(TESTFN)
-            if TESTFN in sys.modules:
-                del sys.modules[TESTFN]
-
-    def test_infinite_reload(self):
-        # Bug #742342 reports that Python segfaults (infinite recursion in C)
-        #  when faced with self-recursive reload()ing.
-
-        sys.path.insert(0, os.path.dirname(__file__))
-        try:
-            import infinite_reload
-        finally:
-            sys.path.pop(0)
-
     def test_import_name_binding(self):
         # import x.y.z binds x in the current namespace
         import test as x

Modified: python/branches/p3yk/Lib/test/test_importhooks.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_importhooks.py	(original)
+++ python/branches/p3yk/Lib/test/test_importhooks.py	Fri Jun  1 07:19:44 2007
@@ -190,10 +190,6 @@
         import reloadmodule
         self.failIf(hasattr(reloadmodule,'reloaded'))
 
-        TestImporter.modules['reloadmodule'] = (False, reload_co)
-        reload(reloadmodule)
-        self.failUnless(hasattr(reloadmodule,'reloaded'))
-
         import hooktestpackage.newrel
         self.assertEqual(hooktestpackage.newrel.get_name(),
                          "hooktestpackage.newrel")

Modified: python/branches/p3yk/Lib/test/test_pkg.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_pkg.py	(original)
+++ python/branches/p3yk/Lib/test/test_pkg.py	Fri Jun  1 07:19:44 2007
@@ -120,9 +120,6 @@
 """
 import t3.sub.subsub
 print(t3.__name__, t3.sub.__name__, t3.sub.subsub.__name__)
-reload(t3)
-reload(t3.sub)
-reload(t3.sub.subsub)
 """),
 
     ("t4", [

Modified: python/branches/p3yk/Lib/test/test_traceback.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_traceback.py	(original)
+++ python/branches/p3yk/Lib/test/test_traceback.py	Fri Jun  1 07:19:44 2007
@@ -52,51 +52,6 @@
         self.assert_("^" in err[2])
         self.assert_(err[1].find(")") == err[2].find("^"))
 
-    def test_bug737473(self):
-        import sys, os, tempfile, time
-
-        savedpath = sys.path[:]
-        testdir = tempfile.mkdtemp()
-        try:
-            sys.path.insert(0, testdir)
-            testfile = os.path.join(testdir, 'test_bug737473.py')
-            print("""
-def test():
-    raise ValueError""", file=open(testfile, 'w'))
-
-            if 'test_bug737473' in sys.modules:
-                del sys.modules['test_bug737473']
-            import test_bug737473
-
-            try:
-                test_bug737473.test()
-            except ValueError:
-                # this loads source code to linecache
-                traceback.extract_tb(sys.exc_info()[2])
-
-            # If this test runs too quickly, test_bug737473.py's mtime
-            # attribute will remain unchanged even if the file is rewritten.
-            # Consequently, the file would not reload.  So, added a sleep()
-            # delay to assure that a new, distinct timestamp is written.
-            # Since WinME with FAT32 has multisecond resolution, more than
-            # three seconds are needed for this test to pass reliably :-(
-            time.sleep(4)
-
-            print("""
-def test():
-    raise NotImplementedError""", file=open(testfile, 'w'))
-            reload(test_bug737473)
-            try:
-                test_bug737473.test()
-            except NotImplementedError:
-                src = traceback.extract_tb(sys.exc_info()[2])[-1][-1]
-                self.failUnlessEqual(src, 'raise NotImplementedError')
-        finally:
-            sys.path[:] = savedpath
-            for f in os.listdir(testdir):
-                os.unlink(os.path.join(testdir, f))
-            os.rmdir(testdir)
-
     def test_members(self):
         # Covers Python/structmember.c::listmembers()
         try:

Modified: python/branches/p3yk/Lib/test/test_xmlrpc.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_xmlrpc.py	(original)
+++ python/branches/p3yk/Lib/test/test_xmlrpc.py	Fri Jun  1 07:19:44 2007
@@ -17,7 +17,7 @@
           'ashortlong': 2,
           'anotherlist': ['.zyx.41'],
           'abase64': xmlrpclib.Binary("my dog has fleas"),
-          'boolean': xmlrpclib.False,
+          'boolean': False,
           'unicode': u'\u4000\u6000\u8000',
           u'ukey\u4000': 'regular value',
           'datetime1': xmlrpclib.DateTime('20050210T11:41:23'),
@@ -133,10 +133,11 @@
                   """
 
         # sys.setdefaultencoding() normally doesn't exist after site.py is
-        # loaded.  reload(sys) is the way to get it back.
+        # loaded.  Re-initializing sys again is the way to get it back. :-(
         old_encoding = sys.getdefaultencoding()
         setdefaultencoding_existed = hasattr(sys, "setdefaultencoding")
-        reload(sys) # ugh!
+        import imp
+        imp.init_builtin('sys')
         sys.setdefaultencoding("iso-8859-1")
         try:
             (s, d), m = xmlrpclib.loads(utf8)

Modified: python/branches/p3yk/Misc/NEWS
==============================================================================
--- python/branches/p3yk/Misc/NEWS	(original)
+++ python/branches/p3yk/Misc/NEWS	Fri Jun  1 07:19:44 2007
@@ -139,7 +139,7 @@
   backticks (ie, `x`), <>
 
 - Removed these Python builtins:
-  apply(), callable(), coerce(), file(), reduce()
+  apply(), callable(), coerce(), file(), reduce(), reload()
 
 - Removed these Python methods:
   {}.has_key

Modified: python/branches/p3yk/Misc/cheatsheet
==============================================================================
--- python/branches/p3yk/Misc/cheatsheet	(original)
+++ python/branches/p3yk/Misc/cheatsheet	Fri Jun  1 07:19:44 2007
@@ -927,7 +927,6 @@
 abs(x)              Return the absolute value of number x.
 bool(x)             Returns True when the argument x is true and False otherwise.
 buffer(obj)         Creates a buffer reference to an object.
-callable(x)         Returns True if x callable, else False.
 chr(i)              Returns one-character string whose ASCII code isinteger i
 classmethod(f)      Converts a function f, into a method with the class as the
                     first argument.  Useful for creating alternative constructors.
@@ -935,14 +934,14 @@
 compile(string,     from which the code was read, or eg. '<string>'if not read
 filename, kind)     from file.kind can be 'eval' if string is a single stmt, or
                     'single' which prints the output of expression statements
-                    thatevaluate to something else than None, or be 'exec'.
+                    that evaluate to something else than None, or be 'exec'.
 complex(real[,      Builds a complex object (can also be done using J or j
 image])             suffix,e.g. 1+3J)
 delattr(obj, name)  deletes attribute named name of object obj <=> del obj.name
                     If no args, returns the list of names in current
 dict([items])       Create a new dictionary from the specified item list.
-dir([object])       localsymbol table. With a module, class or class
-                    instanceobject as arg, returns list of names in its attr.
+dir([object])       local symbol table. With a module, class or class
+                    instance object as arg, returns list of names in its attr.
                     dict.
 divmod(a,b)         Returns tuple of (a/b, a%b)
 enumerate(seq)      Return a iterator giving:  (0, seq[0]), (1, seq[1]), ...
@@ -957,7 +956,7 @@
 float(x)            Converts a number or a string to floating point.
 getattr(object,     [<default> arg added in 1.5.2]Gets attribute called name
 name[, default]))   from object,e.g. getattr(x, 'f') <=> x.f). If not found,
-                    raisesAttributeError or returns default if specified.
+                    raises AttributeError or returns default if specified.
 globals()           Returns a dictionary containing current global variables.
 hasattr(object,     Returns true if object has attr called name.
 name)
@@ -967,9 +966,7 @@
 id(object)          Returns a unique 'identity' integer for an object.
 int(x[, base])      base paramenter specifies base from which to convert string
                     values.
-intern(aString)     Enters aString in the table of "interned strings"
-                    andreturns the string. Interned strings are 'immortals'.
-isinstance(obj,     returns true if obj is an instance of class. Ifissubclass
+isinstance(obj,     Returns true if obj is an instance of class. Ifissubclass
 class)              (A,B) then isinstance(x,A) => isinstance(x,B)
 issubclass(class1,  returns true if class1 is derived from class2
 class2)
@@ -1002,26 +999,24 @@
   [, buffering]])
 pow(x, y [, z])     Returns x to power y [modulo z]. See also ** operator.
 property()          Created a property with access controlled by functions.
-range(start [,end   Returns list of ints from >= start and < end.With 1 arg,
-[, step]])          list from 0..arg-1With 2 args, list from start..end-1With 3
-                    args, list from start up to end by step
-reload(module)      after fixing it. If module was syntacticallycorrect but had
-                    an error in initialization, mustimport it one more time
-                    before calling reload().
-                    Returns a string containing a printable and if possible
-repr(object)        evaluable representation of an object. 
+range(start [,end   Returns list of ints from >= start and < end. With 1 arg,
+[, step]])          list from 0..arg-1. With 2 args, list from start..end-1.
+                    With 3 args, list from start up to end by step
+                    after fixing it.
+repr(object)        Returns a string containing a printable and if possible
+                    evaluable representation of an object. 
                     Class redefinable (__repr__). See also str().
 round(x, n=0)       Returns the floating point value x rounded to n digitsafter
                     the decimal point.
-setattr(object,     This is the counterpart of getattr().setattr(o, 'foobar',
-name, value)        3) <=> o.foobar = 3Creates attribute if it doesn't exist!
+setattr(object,     This is the counterpart of getattr(). setattr(o, 'foobar',
+name, value)        3) <=> o.foobar = 3. Creates attribute if it doesn't exist!
 slice([start,] stop Returns a slice object representing a range, with R/
-[, step])           Oattributes: start, stop, step.
-                    Returns a string containing a nicely
+[, step])           O attributes: start, stop, step.
 staticmethod()      Convert a function to method with no self or class
                     argument.  Useful for methods associated with a class that
                     do not need access to an object's internal state.
-str(object)         printablerepresentation of an object. Class overridable
+str(object)         Returns a string containing a nicely
+                    printable representation of an object. Class overridable
                     (__str__).See also repr().
 super(type)         Create an unbound super object.  Used to call cooperative
                     superclass methods.
@@ -1043,12 +1038,8 @@
 vars([object])      instance object as argumentreturns a dictionary
                     corresponding to the object'ssymbol table. Useful with "%"
                     formatting operator.
-xrange(start [, end Like range(), but doesn't actually store entire listall at
-[, step]])          once. Good to use in "for" loops when there is abig range
-                    and little memory.
-zip(seq1[, seq2,    Returns a list of tuples where each tuple contains the nth
-...])               element of each of the argument sequences.
-
+zip(seq1[, seq2,    Returns an iterator of tuples where each tuple contains
+...])               the nth element of each of the argument sequences.
 
 
 

Modified: python/branches/p3yk/Python/bltinmodule.c
==============================================================================
--- python/branches/p3yk/Python/bltinmodule.c	(original)
+++ python/branches/p3yk/Python/bltinmodule.c	Fri Jun  1 07:19:44 2007
@@ -1683,17 +1683,6 @@
 On Unix, GNU readline is used if enabled.  The prompt string, if given,\n\
 is printed without a trailing newline before reading.");
 
-static PyObject *
-builtin_reload(PyObject *self, PyObject *v)
-{
-	return PyImport_ReloadModule(v);
-}
-
-PyDoc_STRVAR(reload_doc,
-"reload(module) -> module\n\
-\n\
-Reload the module.  The module must have been successfully imported before.");
-
 
 static PyObject *
 builtin_repr(PyObject *self, PyObject *v)
@@ -1991,7 +1980,6 @@
  	{"ord",		builtin_ord,        METH_O, ord_doc},
  	{"pow",		builtin_pow,        METH_VARARGS, pow_doc},
  	{"print",	(PyCFunction)builtin_print,      METH_VARARGS | METH_KEYWORDS, print_doc},
- 	{"reload",	builtin_reload,     METH_O, reload_doc},
  	{"repr",	builtin_repr,       METH_O, repr_doc},
  	{"round",	(PyCFunction)builtin_round,      METH_VARARGS | METH_KEYWORDS, round_doc},
  	{"setattr",	builtin_setattr,    METH_VARARGS, setattr_doc},


More information about the Python-3000-checkins mailing list