annotate Doc/lib/libpycompile.tex @ 39042:c02fa187e0f4 legacy-trunk

Part of SF patch #1484695. This removes dead code. The chksum was already verified in .frombuf() on the lines above. If there was a problem an exception is raised, so there was no way this condition could have been true.
author Neal Norwitz <nnorwitz@gmail.com>
date Mon, 10 Jul 2006 00:23:17 +0000
parents 64c83e0f683e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 8936
diff changeset
1 \section{\module{py_compile} ---
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 8936
diff changeset
2 Compile Python source files}
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 8936
diff changeset
3
8936
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
4 % Documentation based on module docstrings, by Fred L. Drake, Jr.
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
5 % <fdrake@acm.org>
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
6
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
7 \declaremodule[pycompile]{standard}{py_compile}
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
8
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
9 \modulesynopsis{Compile Python source files to byte-code files.}
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
10
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
11
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
12 \indexii{file}{byte-code}
24938
e9500709d49c Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
13 The \module{py_compile} module provides a function to generate a
e9500709d49c Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
14 byte-code file from a source file, and another function used when the
e9500709d49c Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
15 module source file is invoked as a script.
8936
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
16
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
17 Though not often needed, this function can be useful when installing
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
18 modules for shared use, especially if some of the users may not have
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
19 permission to write the byte-code cache files in the directory
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
20 containing the source code.
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
21
27250
16a876746285 Patch #661719: Expose compilation errors as exceptions on request.
Martin v. Löwis <martin@v.loewis.de>
parents: 24938
diff changeset
22 \begin{excdesc}{PyCompileError}
16a876746285 Patch #661719: Expose compilation errors as exceptions on request.
Martin v. Löwis <martin@v.loewis.de>
parents: 24938
diff changeset
23 Exception raised when an error occurs while attempting to compile the file.
16a876746285 Patch #661719: Expose compilation errors as exceptions on request.
Martin v. Löwis <martin@v.loewis.de>
parents: 24938
diff changeset
24 \end{excdesc}
8936
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
25
27250
16a876746285 Patch #661719: Expose compilation errors as exceptions on request.
Martin v. Löwis <martin@v.loewis.de>
parents: 24938
diff changeset
26 \begin{funcdesc}{compile}{file\optional{, cfile\optional{, dfile\optional{, doraise}}}}
8936
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
27 Compile a source file to byte-code and write out the byte-code cache
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
28 file. The source code is loaded from the file name \var{file}. The
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
29 byte-code is written to \var{cfile}, which defaults to \var{file}
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
30 \code{+} \code{'c'} (\code{'o'} if optimization is enabled in the
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
31 current interpreter). If \var{dfile} is specified, it is used as
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
32 the name of the source file in error messages instead of \var{file}.
37064
64c83e0f683e More \exception fixes.
Georg Brandl <georg@python.org>
parents: 27250
diff changeset
33 If \var{doraise} is true, a \exception{PyCompileError} is raised when
64c83e0f683e More \exception fixes.
Georg Brandl <georg@python.org>
parents: 27250
diff changeset
34 an error is encountered while compiling \var{file}. If \var{doraise}
64c83e0f683e More \exception fixes.
Georg Brandl <georg@python.org>
parents: 27250
diff changeset
35 is false (the default), an error string is written to \code{sys.stderr},
64c83e0f683e More \exception fixes.
Georg Brandl <georg@python.org>
parents: 27250
diff changeset
36 but no exception is raised.
8936
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
37 \end{funcdesc}
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
38
24938
e9500709d49c Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
39 \begin{funcdesc}{main}{\optional{args}}
e9500709d49c Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
40 Compile several source files. The files named in \var{args} (or on
e9500709d49c Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
41 the command line, if \var{args} is not specified) are compiled and
e9500709d49c Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
42 the resulting bytecode is cached in the normal manner. This
e9500709d49c Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
43 function does not search a directory structure to locate source
e9500709d49c Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
44 files; it only compiles files named explicitly.
e9500709d49c Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
45 \end{funcdesc}
e9500709d49c Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
46
e9500709d49c Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
47 When this module is run as a script, the \function{main()} is used to
e9500709d49c Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
48 compile all the files named on the command line.
e9500709d49c Added a main() function and support to run this module as a script.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
49
8936
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
50 \begin{seealso}
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
51 \seemodule{compileall}{Utilities to compile all Python source files
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
52 in a directory tree.}
5b73d5babc78 Documentation for the py_compile module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
53 \end{seealso}