bpo-29770: remove outdated PYO related info (GH-590) (GH-612) · python/cpython@16416c2 (original) (raw)

10 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -155,7 +155,7 @@ Glossary
155 155 bytecode
156 156 Python source code is compiled into bytecode, the internal representation
157 157 of a Python program in the CPython interpreter. The bytecode is also
158 - cached in ``.pyc`` and ``.pyo`` files so that executing the same file is
158 + cached in ``.pyc`` files so that executing the same file is
159 159 faster the second time (recompilation from source to bytecode can be
160 160 avoided). This "intermediate language" is said to run on a
161 161 :term:`virtual machine` that executes the machine code corresponding to
Original file line number Diff line number Diff line change
@@ -464,12 +464,12 @@ The :class:`PyZipFile` constructor takes the same parameters as the
464 464 added to the archive, compiling if necessary.
465 465
466 466 If *pathname* is a file, the filename must end with :file:`.py`, and
467 - just the (corresponding :file:`\*.py[co]`) file is added at the top level
467 + just the (corresponding :file:`\*.pyc`) file is added at the top level
468 468 (no path information). If *pathname* is a file that does not end with
469 469 :file:`.py`, a :exc:`RuntimeError` will be raised. If it is a directory,
470 470 and the directory is not a package directory, then all the files
471 -:file:`\*.py[co]` are added at the top level. If the directory is a
472 - package directory, then all :file:`\*.py[co]` are added under the package
471 +:file:`\*.pyc` are added at the top level. If the directory is a
472 + package directory, then all :file:`\*.pyc` are added under the package
473 473 name as a file path, and if any subdirectories are package directories,
474 474 all of these are added recursively.
475 475
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
9 9 --------------
10 10
11 11 This module adds the ability to import Python modules (:file:`\*.py`,
12 -:file:`\*.py[co]`) and packages from ZIP-format archives. It is usually not
12 +:file:`\*.pyc`) and packages from ZIP-format archives. It is usually not
13 13 needed to use the :mod:`zipimport` module explicitly; it is automatically used
14 14 by the built-in :keyword:`import` mechanism for :data:`sys.path` items that are paths
15 15 to ZIP archives.
Original file line number Diff line number Diff line change
@@ -532,8 +532,8 @@ conflict.
532 532
533 533 .. envvar:: PYTHONDONTWRITEBYTECODE
534 534
535 - If this is set to a non-empty string, Python won't try to write ``.pyc`` or
536 -``.pyo`` files on the import of source modules. This is equivalent to
535 + If this is set to a non-empty string, Python won't try to write ``.pyc``
536 + files on the import of source modules. This is equivalent to
537 537 specifying the :option:`-B` option.
538 538
539 539
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ static const char usage_1[] = "\
53 53 Options and arguments (and corresponding environment variables):\n\
54 54 -b : issue warnings about str(bytes_instance), str(bytearray_instance)\n\
55 55 and comparing bytes/bytearray with str. (-bb: issue errors)\n\
56 --B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x\n\
56 +-B : don't write .pyc files on import; also PYTHONDONTWRITEBYTECODE=x\n\
57 57 -c cmd : program passed in as string (terminates option list)\n\
58 58 -d : debug output from parser; also PYTHONDEBUG=x\n\
59 59 -E : ignore PYTHON* environment variables (such as PYTHONPATH)\n\
Original file line number Diff line number Diff line change
@@ -1102,7 +1102,7 @@ get_decompress_func(void)
1102 1102 _Py_IDENTIFIER(decompress);
1103 1103
1104 1104 if (importing_zlib != 0)
1105 -/* Someone has a zlib.py[co] in their Zip file;
1105 +/* Someone has a zlib.pyc in their Zip file;
1106 1106 let's avoid a stack overflow. */
1107 1107 return NULL;
1108 1108 importing_zlib = 1;
@@ -1261,7 +1261,7 @@ eq_mtime(time_t t1, time_t t2)
1261 1261 return d <= 1;
1262 1262 }
1263 1263
1264 -/* Given the contents of a .py[co] file in a buffer, unmarshal the data
1264 +/* Given the contents of a .pyc file in a buffer, unmarshal the data
1265 1265 and return the code object. Return None if it the magic word doesn't
1266 1266 match (we do this instead of raising an exception as we fall back
1267 1267 to .py if available and we don't want to mask other errors).
@@ -1403,7 +1403,7 @@ get_mtime_of_source(ZipImporter *self, PyObject *path)
1403 1403 PyObject *toc_entry, *stripped;
1404 1404 time_t mtime;
1405 1405
1406 -/* strip 'c' or 'o' from *.py[co] */
1406 +/* strip 'c' from *.pyc */
1407 1407 if (PyUnicode_READY(path) == -1)
1408 1408 return (time_t)-1;
1409 1409 stripped = PyUnicode_FromKindAndData(PyUnicode_KIND(path),
Original file line number Diff line number Diff line change
@@ -185,7 +185,7 @@ exists(wchar_t *filename)
185 185 may extend 'filename' by one character.
186 186 */
187 187 static int
188 -ismodule(wchar_t *filename, int update_filename) /* Is module -- check for .pyc/.pyo too */
188 +ismodule(wchar_t *filename, int update_filename) /* Is module -- check for .pyc too */
189 189 {
190 190 size_t n;
191 191
@@ -196,7 +196,7 @@ ismodule(wchar_t *filename, int update_filename) /* Is module -- check for .pyc/
196 196 n = wcsnlen_s(filename, MAXPATHLEN+1);
197 197 if (n < MAXPATHLEN) {
198 198 int exist = 0;
199 -filename[n] = Py_OptimizeFlag ? L'o' : L'c';
199 +filename[n] = L'c';
200 200 filename[n + 1] = L'\0';
201 201 exist = exists(filename);
202 202 if (!update_filename)
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
1 -# Remove all the .pyc and .pyo files under ../Lib.
1 +# Remove all the .pyc files under ../Lib.
2 2
3 3
4 4 def deltree(root):
5 5 import os
6 6 from os.path import join
7 7
8 -npyc = npyo = 0
8 +npyc = 0
9 9 for root, dirs, files in os.walk(root):
10 10 for name in files:
11 -delete = False
12 -if name.endswith('.pyc'):
13 -delete = True
11 +# to be thorough
12 +if name.endswith(('.pyc', '.pyo')):
14 13 npyc += 1
15 -elif name.endswith('.pyo'):
16 -delete = True
17 -npyo += 1
18 -
19 -if delete:
20 14 os.remove(join(root, name))
21 15
22 -return npyc, npyo
16 +return npyc
23 17
24 -npyc, npyo = deltree("../Lib")
25 -print(npyc, ".pyc deleted,", npyo, ".pyo deleted")
18 +npyc = deltree("../Lib")
19 +print(npyc, ".pyc deleted")
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@ rem Usage: rt [-d] [-O] [-q] [-x64] regrtest_args
4 4 rem -d Run Debug build (python_d.exe). Else release build.
5 5 rem -O Run python.exe or python_d.exe (see -d) with -O.
6 6 rem -q "quick" -- normally the tests are run twice, the first time
7 -rem after deleting all the .py[co] files reachable from Lib/.
8 -rem -q runs the tests just once, and without deleting .py[co] files.
7 +rem after deleting all the .pyc files reachable from Lib/.
8 +rem -q runs the tests just once, and without deleting .pyc files.
9 9 rem -x64 Run the 64-bit build of python (or python_d if -d was specified)
10 10 rem from the 'amd64' dir instead of the 32-bit build in this dir.
11 11 rem All leading instances of these switches are shifted off, and
@@ -45,7 +45,7 @@ set exe=%prefix%python%suffix%.exe
45 45 set cmd="%exe%" %dashO% -Wd -E -bb -m test %regrtestargs%
46 46 if defined qmode goto Qmode
47 47
48 -echo Deleting .pyc/.pyo files ...
48 +echo Deleting .pyc files ...
49 49 "%exe%" "%pcbuild%rmpyc.py"
50 50
51 51 echo Cleaning _pth files ...
@@ -55,7 +55,7 @@ echo on
55 55 %cmd%
56 56 @echo off
57 57
58 -echo About to run again without deleting .pyc/.pyo first:
58 +echo About to run again without deleting .pyc first:
59 59 pause
60 60
61 61 :Qmode
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ int Py_BytesWarningFlag; /* Warn on str(bytes) and str(buffer) */
88 88 int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */
89 89 int Py_FrozenFlag; /* Needed by getpath.c */
90 90 int Py_IgnoreEnvironmentFlag; /* e.g. PYTHONPATH, PYTHONHOME */
91 -int Py_DontWriteBytecodeFlag; /* Suppress writing bytecode files (*.py[co]) */
91 +int Py_DontWriteBytecodeFlag; /* Suppress writing bytecode files (*.pyc) */
92 92 int Py_NoUserSiteDirectory = 0; /* for -s and site.py */
93 93 int Py_UnbufferedStdioFlag = 0; /* Unbuffered binary std{in,out,err} */
94 94 int Py_HashRandomizationFlag = 0; /* for -R and PYTHONHASHSEED */