| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0e41148 commit e7ba495
116 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -106,8 +106,7 @@ def import_module(partname, fqname, parent): | |||
| 106 | 106 | return m | |
| 107 | 107 | ||
| 108 | 108 | ||
| 109 | - # Replacement for reload() | ||
| 110 | - def reload_hook(module): | ||
| 109 | + def reload(module): | ||
| 111 | 110 | name = module.__name__ | |
| 112 | 111 | if '.' not in name: | |
| 113 | 112 | return import_module(name, name, None) | |
@@ -119,8 +118,6 @@ def reload_hook(module): | |||
| 119 | 118 | ||
| 120 | 119 | # Save the original hooks | |
| 121 | 120 | original_import = __builtin__.__import__ | |
| 122 | - original_reload = __builtin__.reload | ||
| 123 | 121 | ||
| 124 | 122 | # Now install our hooks | |
| 125 | 123 | __builtin__.__import__ = import_hook | |
| 126 | - __builtin__.reload = reload_hook | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -262,7 +262,6 @@ def test(): | |||
| 262 | 262 | rl.unlock() | |
| 263 | 263 | finally: | |
| 264 | 264 | print [1] | |
| 265 | - sys.exc_traceback = None | ||
| 266 | 265 | print [2] | |
| 267 | 266 | if rl: | |
| 268 | 267 | rl.unlock() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -122,7 +122,7 @@ EMACS= emacs | |||
| 122 | 122 | ||
| 123 | 123 | # The end of this should reflect the major/minor version numbers of | |
| 124 | 124 | # the release: | |
| 125 | - WHATSNEW=whatsnew26 | ||
| 125 | + WHATSNEW=whatsnew30 | ||
| 126 | 126 | ||
| 127 | 127 | # what's what | |
| 128 | 128 | MANDVIFILES= paper-$(PAPER)/api.dvi paper-$(PAPER)/ext.dvi \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -171,7 +171,6 @@ LIBFILES= $(MANSTYLES) $(INDEXSTYLES) $(COMMONTEX) \ | |||
| 171 | 171 | lib/libgdbm.tex \ | |
| 172 | 172 | lib/libtermios.tex \ | |
| 173 | 173 | lib/libfcntl.tex \ | |
| 174 | - lib/libposixfile.tex \ | ||
| 175 | 174 | lib/libsyslog.tex \ | |
| 176 | 175 | lib/liblogging.tex \ | |
| 177 | 176 | lib/libpdb.tex \ | |
@@ -192,7 +191,6 @@ LIBFILES= $(MANSTYLES) $(INDEXSTYLES) $(COMMONTEX) \ | |||
| 192 | 191 | lib/libsgmllib.tex \ | |
| 193 | 192 | lib/librfc822.tex \ | |
| 194 | 193 | lib/libmimetools.tex \ | |
| 195 | - lib/libmimewriter.tex \ | ||
| 196 | 194 | lib/libbinascii.tex \ | |
| 197 | 195 | lib/libmm.tex \ | |
| 198 | 196 | lib/libaudioop.tex \ | |
@@ -235,7 +233,6 @@ LIBFILES= $(MANSTYLES) $(INDEXSTYLES) $(COMMONTEX) \ | |||
| 235 | 233 | lib/libzipfile.tex \ | |
| 236 | 234 | lib/libpprint.tex \ | |
| 237 | 235 | lib/libcode.tex \ | |
| 238 | - lib/libmimify.tex \ | ||
| 239 | 236 | lib/libre.tex \ | |
| 240 | 237 | lib/libuserdict.tex \ | |
| 241 | 238 | lib/libdis.tex \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -140,10 +140,7 @@ \section{Importing Modules \label{importing}} | |||
| 140 | 140 | \end{cfuncdesc} | |
| 141 | 141 | ||
| 142 | 142 | \begin{cfuncdesc}{PyObject*}{PyImport_ReloadModule}{PyObject *m} | |
| 143 | - Reload a module. This is best described by referring to the | ||
| 144 | - built-in Python function \function{reload()}\bifuncindex{reload}, as | ||
| 145 | - the standard \function{reload()} function calls this function | ||
| 146 | - directly. Return a new reference to the reloaded module, or \NULL{} | ||
| 143 | + Reload a module. Return a new reference to the reloaded module, or \NULL{} | ||
| 147 | 144 | with an exception set on failure (the module still exists in this | |
| 148 | 145 | case). | |
| 149 | 146 | \end{cfuncdesc} | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -399,12 +399,7 @@ \section{The Module's Method Table and Initialization Function | |||
| 399 | 399 | following a \cfunction{fork()} without an intervening | |
| 400 | 400 | \cfunction{exec()}) can create problems for some extension modules. | |
| 401 | 401 | Extension module authors should exercise caution when initializing | |
| 402 | - internal data structures. | ||
| 403 | - Note also that the \function{reload()} function can be used with | ||
| 404 | - extension modules, and will call the module initialization function | ||
| 405 | - (\cfunction{initspam()} in the example), but will not load the module | ||
| 406 | - again if it was loaded from a dynamically loadable object file | ||
| 407 | - (\file{.so} on \UNIX, \file{.dll} on Windows).} | ||
| 402 | + internal data structures.} | ||
| 408 | 403 | ||
| 409 | 404 | A more substantial example module is included in the Python source | |
| 410 | 405 | distribution as \file{Modules/xxmodule.c}. This file may be used as a | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -980,7 +980,7 @@ element. | |||
| 980 | 980 | that's a slice of the iterator. With a single ``stop`` argument, | |
| 981 | 981 | it will return the first ``stop`` | |
| 982 | 982 | elements. If you supply a starting index, you'll get ``stop-start`` | |
| 983 | - elements, and if you supply a value for ``step`, elements will be | ||
| 983 | + elements, and if you supply a value for ``step``, elements will be | ||
| 984 | 984 | skipped accordingly. Unlike Python's string and list slicing, you | |
| 985 | 985 | can't use negative values for ``start``, ``stop``, or ``step``. | |
| 986 | 986 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -146,8 +146,6 @@ \chapter*{Front Matter\label{front}} | |||
| 146 | 146 | \input{libmhlib} | |
| 147 | 147 | \input{libmimetools} | |
| 148 | 148 | \input{libmimetypes} | |
| 149 | - \input{libmimewriter} | ||
| 150 | - \input{libmimify} | ||
| 151 | 149 | \input{libmultifile} | |
| 152 | 150 | \input{librfc822} | |
| 153 | 151 | ||
@@ -265,7 +263,6 @@ \chapter*{Front Matter\label{front}} | |||
| 265 | 263 | \input{libpty} | |
| 266 | 264 | \input{libfcntl} | |
| 267 | 265 | \input{libpipes} | |
| 268 | - \input{libposixfile} | ||
| 269 | 266 | \input{libresource} | |
| 270 | 267 | \input{libnis} | |
| 271 | 268 | \input{libsyslog} | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -237,7 +237,7 @@ \section{\module{codecs} --- | |||
| 237 | 237 | \begin{funcdesc}{iterdecode}{iterable, encoding\optional{, errors}} | |
| 238 | 238 | Uses an incremental decoder to iteratively decode the input provided by | |
| 239 | 239 | \var{iterable}. This function is a generator. \var{errors} (as well as | |
| 240 | - any other keyword argument) is passed through to the incremental encoder. | ||
| 240 | + any other keyword argument) is passed through to the incremental decoder. | ||
| 241 | 241 | \versionadded{2.5} | |
| 242 | 242 | \end{funcdesc} | |
| 243 | 243 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -890,82 +890,6 @@ \section{Built-in Functions \label{built-in-funcs}} | |||
| 890 | 890 | \end{verbatim} | |
| 891 | 891 | \end{funcdesc} | |
| 892 | 892 | ||
| 893 | - \begin{funcdesc}{reload}{module} | ||
| 894 | - Reload a previously imported \var{module}. The | ||
| 895 | - argument must be a module object, so it must have been successfully | ||
| 896 | - imported before. This is useful if you have edited the module | ||
| 897 | - source file using an external editor and want to try out the new | ||
| 898 | - version without leaving the Python interpreter. The return value is | ||
| 899 | - the module object (the same as the \var{module} argument). | ||
| 900 | - | ||
| 901 | - When \code{reload(module)} is executed: | ||
| 902 | - | ||
| 903 | - \begin{itemize} | ||
| 904 | - | ||
| 905 | - \item Python modules' code is recompiled and the module-level code | ||
| 906 | - reexecuted, defining a new set of objects which are bound to names in | ||
| 907 | - the module's dictionary. The \code{init} function of extension | ||
| 908 | - modules is not called a second time. | ||
| 909 | - | ||
| 910 | - \item As with all other objects in Python the old objects are only | ||
| 911 | - reclaimed after their reference counts drop to zero. | ||
| 912 | - | ||
| 913 | - \item The names in the module namespace are updated to point to | ||
| 914 | - any new or changed objects. | ||
| 915 | - | ||
| 916 | - \item Other references to the old objects (such as names external | ||
| 917 | - to the module) are not rebound to refer to the new objects and | ||
| 918 | - must be updated in each namespace where they occur if that is | ||
| 919 | - desired. | ||
| 920 | - | ||
| 921 | - \end{itemize} | ||
| 922 | - | ||
| 923 | - There are a number of other caveats: | ||
| 924 | - | ||
| 925 | - If a module is syntactically correct but its initialization fails, | ||
| 926 | - the first \keyword{import} statement for it does not bind its name | ||
| 927 | - locally, but does store a (partially initialized) module object in | ||
| 928 | - \code{sys.modules}. To reload the module you must first | ||
| 929 | - \keyword{import} it again (this will bind the name to the partially | ||
| 930 | - initialized module object) before you can \function{reload()} it. | ||
| 931 | - | ||
| 932 | - When a module is reloaded, its dictionary (containing the module's | ||
| 933 | - global variables) is retained. Redefinitions of names will override | ||
| 934 | - the old definitions, so this is generally not a problem. If the new | ||
| 935 | - version of a module does not define a name that was defined by the | ||
| 936 | - old version, the old definition remains. This feature can be used | ||
| 937 | - to the module's advantage if it maintains a global table or cache of | ||
| 938 | - objects --- with a \keyword{try} statement it can test for the | ||
| 939 | - table's presence and skip its initialization if desired: | ||
| 940 | - | ||
| 941 | - \begin{verbatim} | ||
| 942 | - try: | ||
| 943 | - cache | ||
| 944 | - except NameError: | ||
| 945 | - cache = {} | ||
| 946 | - \end{verbatim} | ||
| 947 | - | ||
| 948 | - | ||
| 949 | - It is legal though generally not very useful to reload built-in or | ||
| 950 | - dynamically loaded modules, except for \refmodule{sys}, | ||
| 951 | - \refmodule[main]{__main__} and \refmodule[builtin]{__builtin__}. In | ||
| 952 | - many cases, however, extension modules are not designed to be | ||
| 953 | - initialized more than once, and may fail in arbitrary ways when | ||
| 954 | - reloaded. | ||
| 955 | - | ||
| 956 | - If a module imports objects from another module using \keyword{from} | ||
| 957 | - \ldots{} \keyword{import} \ldots{}, calling \function{reload()} for | ||
| 958 | - the other module does not redefine the objects imported from it --- | ||
| 959 | - one way around this is to re-execute the \keyword{from} statement, | ||
| 960 | - another is to use \keyword{import} and qualified names | ||
| 961 | - (\var{module}.\var{name}) instead. | ||
| 962 | - | ||
| 963 | - If a module instantiates instances of a class, reloading the module | ||
| 964 | - that defines the class does not affect the method definitions of the | ||
| 965 | - instances --- they continue to use the old class definition. The | ||
| 966 | - same is true for derived classes. | ||
| 967 | - \end{funcdesc} | ||
| 968 | - | ||
| 969 | 893 | \begin{funcdesc}{repr}{object} | |
| 970 | 894 | Return a string containing a printable representation of an object. | |
| 971 | 895 | This is the same value yielded by conversions (reverse quotes). | |
| Back | FazBrowse Home | New Git URL |
0 commit comments