| [3225] | 1 | r"""Utilities to compile possibly incomplete Python source code.
|
|---|
| 2 |
|
|---|
| 3 | This module provides two interfaces, broadly similar to the builtin
|
|---|
| 4 | function compile(), which take program text, a filename and a 'mode'
|
|---|
| 5 | and:
|
|---|
| 6 |
|
|---|
| 7 | - Return code object if the command is complete and valid
|
|---|
| 8 | - Return None if the command is incomplete
|
|---|
| 9 | - Raise SyntaxError, ValueError or OverflowError if the command is a
|
|---|
| 10 | syntax error (OverflowError and ValueError can be produced by
|
|---|
| 11 | malformed literals).
|
|---|
| 12 |
|
|---|
| 13 | Approach:
|
|---|
| 14 |
|
|---|
| 15 | First, check if the source consists entirely of blank lines and
|
|---|
| 16 | comments; if so, replace it with 'pass', because the built-in
|
|---|
| 17 | parser doesn't always do the right thing for these.
|
|---|
| 18 |
|
|---|
| |
|---|