mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
push_source() and pop_source() entry points for shlex instances.
These basically just make available to the user what userhook() does to the source stack. Documentation included.
This commit is contained in:
parent
159830ec3a
commit
bd1a489759
1 changed files with 22 additions and 3 deletions
|
@ -66,15 +66,34 @@ request in effect, or the previous source was a stream
|
||||||
result is a relative pathname, the directory part of the name of the
|
result is a relative pathname, the directory part of the name of the
|
||||||
file immediately before it on the source inclusion stack is prepended
|
file immediately before it on the source inclusion stack is prepended
|
||||||
(this behavior is like the way the C preprocessor handles
|
(this behavior is like the way the C preprocessor handles
|
||||||
\code{\#include "file.h"}). The result of the manipulations is treated
|
\code{\#include "file.h"}).
|
||||||
as a filename, and returned as the first component of the tuple, with
|
|
||||||
\function{open()} called on it to yield the second component.
|
The result of the manipulations is treated as a filename, and returned
|
||||||
|
as the first component of the tuple, with
|
||||||
|
\function{open()} called on it to yield the second component. (Note:
|
||||||
|
this is the reverse of the order of arguments in instance initialization!)
|
||||||
|
|
||||||
This hook is exposed so that you can use it to implement directory
|
This hook is exposed so that you can use it to implement directory
|
||||||
search paths, addition of file extensions, and other namespace hacks.
|
search paths, addition of file extensions, and other namespace hacks.
|
||||||
There is no corresponding `close' hook, but a shlex instance will call
|
There is no corresponding `close' hook, but a shlex instance will call
|
||||||
the \method{close()} method of the sourced input stream when it
|
the \method{close()} method of the sourced input stream when it
|
||||||
returns \EOF.
|
returns \EOF.
|
||||||
|
|
||||||
|
For more explicit control of source stacking, use the next two
|
||||||
|
methods.
|
||||||
|
\end{methoddesc}
|
||||||
|
|
||||||
|
\begin{methoddesc}{push_source}{stream\optional{, filename}}
|
||||||
|
Push an input source stream onto the input stack. If the filename
|
||||||
|
argument is specified it will later be available for use in error
|
||||||
|
messages. This is the same method used internally by the
|
||||||
|
\method{sourcehook} method. (New in 2.1)
|
||||||
|
\end{methoddesc}
|
||||||
|
|
||||||
|
\begin{methoddesc}{pop_source}{}}
|
||||||
|
Pop the last-pushed input source from the input stack.
|
||||||
|
This is the same method used internally when the lexer reaches
|
||||||
|
\EOF on a stacked input stream. (New in 2.1)
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}{error_leader}{\optional{file\optional{, line}}}
|
\begin{methoddesc}{error_leader}{\optional{file\optional{, line}}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue