diff --git a/pep-0304.txt b/pep-0304.txt index 1ec916270..7e65b7224 100644 --- a/pep-0304.txt +++ b/pep-0304.txt @@ -30,22 +30,22 @@ environment variables which Python understands. Its interpretation is: - If not present Python bytecode is generated in exactly the same way - as is currently done. sys.pythonbytecodebase is set to the root + as is currently done. sys.bytecodebase is set to the root directory (either / on Unix or the root directory of the startup drive -- typically ``C:\`` -- on Windows). - If present and it refers to an existing directory, - sys.pythonbytecodebase is set to that directory and bytecode files + sys.bytecodebase is set to that directory and bytecode files are written into a directory structure rooted at that location. -- If present but empty, sys.pythonbytecodebase is set to None and +- If present but empty, sys.bytecodebase is set to None and generation of bytecode files is suppressed altogether. - If present and it does not refer to an existing directory, a warning - is displayed, sys.pythonbytecodebase is set to None and generation + is displayed, sys.bytecodebase is set to None and generation of bytecode files is suppressed altogether. -After startup, all runtime references are to sys.pythonbytecodebase, +After startup, all runtime references are to sys.bytecodebase, not the PYTHONBYTECODEBASE environment variable. sys.path is not modified. @@ -54,7 +54,7 @@ Glossary -------- - "bytecode base" refers to the current setting of - sys.pythonbytecodebase. + sys.bytecodebase. - "augmented directory" refers to the directory formed from the bytecode base and the directory name of the source file. @@ -91,7 +91,7 @@ Conceptually, the augmented directory for a bytecode file is the directory in which the source file exists prefixed by the bytecode base. In a Unix environment this would be:: - pcb = os.path.abspath(sys.pythonbytecodebase) + pcb = os.path.abspath(sys.bytecodebase) if sourcefile[0] == os.sep: sourcefile = sourcefile[1:] augdir = os.path.join(pcb, os.path.dirname(sourcefile)) @@ -100,7 +100,7 @@ drive letter of the directory containing the source file is treated as a directory component after removing the trailing colon. The augmented directory is thus derived as :: - pcb = os.path.abspath(sys.pythonbytecodebase) + pcb = os.path.abspath(sys.bytecodebase) drive, base = os.path.splitdrive(os.path.dirname(sourcefile)) drive = drive[:-1] if base[0] == "\\": base = base[1:] @@ -118,16 +118,16 @@ to the sys module, effectively:: probe = os.path.join(pcb, "foo") open(probe, "w") os.unlink(probe) - sys.pythonbytecodebase = pcb + sys.bytecodebase = pcb except IOError: - sys.pythonbytecodebase = None + sys.bytecodebase = None This allows the user to specify the bytecode base as a relative path, but not have it subject to changes to the current working directory. (I can't imagine you'd want it to move around during program execution.) -There is nothing special about sys.pythonbytecodebase. The user may +There is nothing special about sys.bytecodebase. The user may change it at runtime if she so chooses, but normally it will not be modified. @@ -180,7 +180,7 @@ Issues minimized. When running as root the interpreter should check to see if PYTHONBYTECODEBASE refers to a directory which is writable by anyone other than root. If so, it could raise an exception or - warning and set sys.pythonbytecodebase to None. Or, see the next + warning and set sys.bytecodebase to None. Or, see the next item. - More security - What if PYTHONBYTECODEBASE refers to a general @@ -207,35 +207,37 @@ is not writable by the current user. - The bytecode base is /tmp. /usr/lib/python2.3/urllib.pyc exists, but is out-of-date. When urllib is imported, the generated bytecode - file is written to urllib.pyc in the augmented directory. - Intermediate directories will be created as needed. + file is written to urllib.pyc in the augmented directory which has + the value /tmp/usr/lib/python2.3. Intermediate directories will be + created as needed. - The bytecode base is None. No urllib.pyc file is found. When urllib is imported, no bytecode file is written. - The bytecode base is /tmp. No urllib.pyc file is found. When urllib is imported, the generated bytecode file is written to the - augmented directory, creating intermediate directories as needed. + augmented directory which has the value /tmp/usr/lib/python2.3. + Intermediate directories will be created as needed. - At startup, PYTHONBYTECODEBASE is /tmp/foobar, which does not exist. - A warning is emitted, sys.pythonbytecodebase is set to None and no + A warning is emitted, sys.bytecodebase is set to None and no bytecode files are written during program execution unless - sys.pythonbytecodebase is later changed to refer to a valid, + sys.bytecodebase is later changed to refer to a valid, writable directory. - At startup, PYTHONBYTECODEBASE is set to /, which exists, but is not writable by the current user. A warning is emitted, - sys.pythonbytecodebase is set to None and no bytecode files are - written during program execution unless sys.pythonbytecodebase is + sys.bytecodebase is set to None and no bytecode files are + written during program execution unless sys.bytecodebase is later changed to refer to a valid, writable directory. Note that even though the augmented directory constructed for a particular bytecode file may be writable by the current user, what counts is that the bytecode base directory itself is writable. - At startup PYTHONBYTECODEBASE is set to the empty string. - sys.pythonbytecodebase is set to None. No warning is generated, - however. If no urllib.pyc file is found when urllib is imported, no - bytecode file is written. + sys.bytecodebase is set to None. No warning is generated, however. + If no urllib.pyc file is found when urllib is imported, no bytecode + file is written. In the Windows examples which follow, the urllib source code resides in ``C:\PYTHON22\urllib.py``. ``C:\PYTHON22`` is in sys.path but is @@ -248,20 +250,21 @@ not writable by the current user. - The bytecode base is set to ``C:\TEMP``. ``C:\PYTHON22\urllib.pyc`` exists, but is out-of-date. When urllib is imported, a new bytecode - file is written to the augmented directory. Intermediate - directories will be created as needed. + file is written to the augmented directory which has the value + ``C:\TEMP\C\PYTHON22``. Intermediate directories will be created as + needed. - At startup PYTHONBYTECODEBASE is set to ``TEMP`` and the current working directory at application startup is ``H:\NET``. The potential bytecode base is thus ``H:\NET\TEMP``. If this directory - exists and is writable by the current user, sys.pythonbytecodebase - will be set to that value. If not, a warning will be emitted and - sys.pythonbytecodebase will be set to None. + exists and is writable by the current user, sys.bytecodebase will be + set to that value. If not, a warning will be emitted and + sys.bytecodebase will be set to None. - The bytecode base is ``C:\TEMP``. No urllib.pyc file is found. When urllib is imported, the generated bytecode file is written to - the augmented directory, creating intermediate directories as - needed. + the augmented directory which has the value ``C:\TEMP\C\PYTHON22``. + Intermediate directories will be created as needed. References