py_compile "invalidation_mode" argument doesn't prevent recompilation

Open
#96,964 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
compilers

Research direction

Start with the py_compile.compile entry point and trace how its invalidation_mode options are handled when a cfile already exists. Reproduce the example with valid invalidation modes and verify that an up-to-date cfile is not recompiled; add regression coverage for the observed behavior.

Written by the indexing model from the issue text.

Description

type-bug

Bug report

I use the function py_compile.compile to compile my .py files into .pyc files.

Example of use:

file = "source/path/to/my/file.py"
cfile = "path/to/my/file.pyc"
py_compile.compile(file, cfile)

This function never checks the validity of "cfile" against "file" for any of the valid "invalidation_mode" options, so "file" is always recompiled even when it is not necessary.

Your environment

Tested on python 3.8.8, but the problem seems to be present on higher versions of python (3.10 at least)

Dominant language
Python
Stars
77.2k
Forks
36k
Avg merge
1d 9h
Merged PRs (30d)
558

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/cpython

All issues in python/cpython

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.