Skip to content

Commit ce222c8

Browse files
authored
bpo-29770: remove outdated PYO related info (GH-590) (GH-613)
1 parent 518d8fc commit ce222c8

10 files changed

Lines changed: 26 additions & 32 deletions

File tree

Doc/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Glossary
127127
bytecode
128128
Python source code is compiled into bytecode, the internal representation
129129
of a Python program in the CPython interpreter. The bytecode is also
130-
cached in ``.pyc`` and ``.pyo`` files so that executing the same file is
130+
cached in ``.pyc`` files so that executing the same file is
131131
faster the second time (recompilation from source to bytecode can be
132132
avoided). This "intermediate language" is said to run on a
133133
:term:`virtual machine` that executes the machine code corresponding to

Doc/library/zipfile.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,12 @@ The :class:`PyZipFile` constructor takes the same parameters as the
418418
added to the archive, compiling if necessary.
419419

420420
If *pathname* is a file, the filename must end with :file:`.py`, and
421-
just the (corresponding :file:`\*.py[co]`) file is added at the top level
421+
just the (corresponding :file:`\*.pyc`) file is added at the top level
422422
(no path information). If *pathname* is a file that does not end with
423423
:file:`.py`, a :exc:`RuntimeError` will be raised. If it is a directory,
424424
and the directory is not a package directory, then all the files
425-
:file:`\*.py[co]` are added at the top level. If the directory is a
426-
package directory, then all :file:`\*.py[co]` are added under the package
425+
:file:`\*.pyc` are added at the top level. If the directory is a
426+
package directory, then all :file:`\*.pyc` are added under the package
427427
name as a file path, and if any subdirectories are package directories,
428428
all of these are added recursively.
429429

Doc/library/zipimport.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
--------------
1010

1111
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
1313
needed to use the :mod:`zipimport` module explicitly; it is automatically used
1414
by the built-in :keyword:`import` mechanism for :data:`sys.path` items that are paths
1515
to ZIP archives.

Doc/using/cmdline.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,8 @@ conflict.
518518

519519
.. envvar:: PYTHONDONTWRITEBYTECODE
520520

521-
If this is set to a non-empty string, Python won't try to write ``.pyc`` or
522-
``.pyo`` files on the import of source modules. This is equivalent to
521+
If this is set to a non-empty string, Python won't try to write ``.pyc``
522+
files on the import of source modules. This is equivalent to
523523
specifying the :option:`-B` option.
524524

525525

Modules/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static char *usage_1 = "\
5050
Options and arguments (and corresponding environment variables):\n\
5151
-b : issue warnings about str(bytes_instance), str(bytearray_instance)\n\
5252
and comparing bytes/bytearray with str. (-bb: issue errors)\n\
53-
-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x\n\
53+
-B : don't write .pyc files on import; also PYTHONDONTWRITEBYTECODE=x\n\
5454
-c cmd : program passed in as string (terminates option list)\n\
5555
-d : debug output from parser; also PYTHONDEBUG=x\n\
5656
-E : ignore PYTHON* environment variables (such as PYTHONPATH)\n\

Modules/zipimport.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ get_decompress_func(void)
11041104
_Py_IDENTIFIER(decompress);
11051105

11061106
if (importing_zlib != 0)
1107-
/* Someone has a zlib.py[co] in their Zip file;
1107+
/* Someone has a zlib.pyc in their Zip file;
11081108
let's avoid a stack overflow. */
11091109
return NULL;
11101110
importing_zlib = 1;
@@ -1264,11 +1264,11 @@ eq_mtime(time_t t1, time_t t2)
12641264
}
12651265

12661266
/* Issue #29537: handle issue27286 bytecode incompatibility
1267-
* See Lib/importlib/_bootstrap_external.py for general discussion
1267+
* See Lib/importlib/_bootstrap_external.py for general discussion
12681268
*/
12691269
extern PY_UINT32_T _Py_BACKCOMPAT_MAGIC_NUMBER;
12701270

1271-
/* Given the contents of a .py[co] file in a buffer, unmarshal the data
1271+
/* Given the contents of a .pyc file in a buffer, unmarshal the data
12721272
and return the code object. Return None if it the magic word doesn't
12731273
match (we do this instead of raising an exception as we fall back
12741274
to .py if available and we don't want to mask other errors).
@@ -1414,7 +1414,7 @@ get_mtime_of_source(ZipImporter *self, PyObject *path)
14141414
PyObject *toc_entry, *stripped;
14151415
time_t mtime;
14161416

1417-
/* strip 'c' or 'o' from *.py[co] */
1417+
/* strip 'c' from *.pyc */
14181418
if (PyUnicode_READY(path) == -1)
14191419
return (time_t)-1;
14201420
stripped = PyUnicode_FromKindAndData(PyUnicode_KIND(path),

PC/getpathp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ exists(wchar_t *filename)
133133
may extend 'filename' by one character.
134134
*/
135135
static int
136-
ismodule(wchar_t *filename, int update_filename) /* Is module -- check for .pyc/.pyo too */
136+
ismodule(wchar_t *filename, int update_filename) /* Is module -- check for .pyc too */
137137
{
138138
int n;
139139

@@ -144,7 +144,7 @@ ismodule(wchar_t *filename, int update_filename) /* Is module -- check for .pyc/
144144
n = wcsnlen_s(filename, MAXPATHLEN+1);
145145
if (n < MAXPATHLEN) {
146146
int exist = 0;
147-
filename[n] = Py_OptimizeFlag ? L'o' : L'c';
147+
filename[n] = L'c';
148148
filename[n + 1] = L'\0';
149149
exist = exists(filename);
150150
if (!update_filename)

PCbuild/rmpyc.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
1-
# Remove all the .pyc and .pyo files under ../Lib.
1+
# Remove all the .pyc files under ../Lib.
22

33

44
def deltree(root):
55
import os
66
from os.path import join
77

8-
npyc = npyo = 0
8+
npyc = 0
99
for root, dirs, files in os.walk(root):
1010
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')):
1413
npyc += 1
15-
elif name.endswith('.pyo'):
16-
delete = True
17-
npyo += 1
18-
19-
if delete:
2014
os.remove(join(root, name))
2115

22-
return npyc, npyo
16+
return npyc
2317

24-
npyc, npyo = deltree("../Lib")
25-
print(npyc, ".pyc deleted,", npyo, ".pyo deleted")
18+
npyc = deltree("../Lib")
19+
print(npyc, ".pyc deleted")

PCbuild/rt.bat

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ rem Usage: rt [-d] [-O] [-q] [-x64] regrtest_args
44
rem -d Run Debug build (python_d.exe). Else release build.
55
rem -O Run python.exe or python_d.exe (see -d) with -O.
66
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.
99
rem -x64 Run the 64-bit build of python (or python_d if -d was specified)
1010
rem from the 'amd64' dir instead of the 32-bit build in this dir.
1111
rem All leading instances of these switches are shifted off, and
@@ -45,14 +45,14 @@ set exe=%prefix%python%suffix%.exe
4545
set cmd="%exe%" %dashO% -Wd -E -bb "%pcbuild%..\lib\test\regrtest.py" %regrtestargs%
4646
if defined qmode goto Qmode
4747

48-
echo Deleting .pyc/.pyo files ...
48+
echo Deleting .pyc files ...
4949
"%exe%" "%pcbuild%rmpyc.py"
5050

5151
echo on
5252
%cmd%
5353
@echo off
5454

55-
echo About to run again without deleting .pyc/.pyo first:
55+
echo About to run again without deleting .pyc first:
5656
pause
5757

5858
:Qmode

Python/pylifecycle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ int Py_BytesWarningFlag; /* Warn on str(bytes) and str(buffer) */
8585
int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */
8686
int Py_FrozenFlag; /* Needed by getpath.c */
8787
int Py_IgnoreEnvironmentFlag; /* e.g. PYTHONPATH, PYTHONHOME */
88-
int Py_DontWriteBytecodeFlag; /* Suppress writing bytecode files (*.py[co]) */
88+
int Py_DontWriteBytecodeFlag; /* Suppress writing bytecode files (*.pyc) */
8989
int Py_NoUserSiteDirectory = 0; /* for -s and site.py */
9090
int Py_UnbufferedStdioFlag = 0; /* Unbuffered binary std{in,out,err} */
9191
int Py_HashRandomizationFlag = 0; /* for -R and PYTHONHASHSEED */

0 commit comments

Comments
 (0)