Skip to content

pypy3.9: reports missing branch from function-to-decorator #1326

Closed
@asottile

Description

@asottile

Describe the bug
in pypy 3.9 coverage reports a missing branch from a function to its decorator (though that should be impossible?)

To Reproduce
How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:

What version of Python are you using?

$ ./venv/bin/pypy3  --version --version
Python 3.9.10 (8276b505180f70c5784a698a510f0a17317a85c3, Feb 19 2022, 16:50:47)
[PyPy 7.3.8 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]

What version of coverage.py shows the problem? The output of coverage debug sys is helpful.

coverage debug sys
$ ./venv/bin/coverage debug sys
-- sys -------------------------------------------------------
               coverage_version: 6.3.1
                coverage_module: /tmp/y/venv/lib/pypy3.9/site-packages/coverage/__init__.py
                         tracer: -none-
                        CTracer: unavailable
           plugins.file_tracers: -none-
            plugins.configurers: -none-
      plugins.context_switchers: -none-
              configs_attempted: .coveragerc
                                 setup.cfg
                                 tox.ini
                                 pyproject.toml
                   configs_read: -none-
                    config_file: None
                config_contents: -none-
                      data_file: -none-
                         python: 3.9.10 (8276b505180f70c5784a698a510f0a17317a85c3, Feb 19 2022, 16:50:47)[PyPy 7.3.8 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]
                       platform: Linux-5.13.0-28-generic-x86_64-with-glibc2.31
                 implementation: PyPy
                     executable: /tmp/y/venv/bin/pypy3
                   def_encoding: utf-8
                    fs_encoding: utf-8
                            pid: 6693
                            cwd: /tmp/y
                           path: /tmp/y/venv/bin
                                 /home/asottile/opt/pypy3.9-v7.3.8-linux64/lib/pypy3.9
                                 /tmp/y/venv/lib/pypy3.9/site-packages
                    environment: HOME = /home/asottile
                                 PYTHONSTARTUP = /home/asottile/.pythonrc.py
                   command_line: ./venv/bin/coverage debug sys
                sqlite3_version: 2.6.0
         sqlite3_sqlite_version: 3.7.17
             sqlite3_temp_store: 0
        sqlite3_compile_options: DISABLE_DIRSYNC; ENABLE_COLUMN_METADATA; ENABLE_FTS3
                                 ENABLE_RTREE; ENABLE_UNLOCK_NOTIFY; SECURE_DELETE
                                 TEMP_STORE=1; THREADSAFE=1

What versions of what packages do you have installed? The output of pip freeze is helpful.

(this is just what comes with pypy + coverage)

$ ./venv/bin/pip freeze
cffi==1.15.0
coverage==6.3.1
greenlet==0.4.13
hpy==0.0.3
readline==6.2.4.1

What code shows the problem? Give us a specific commit of a specific repo that we can check out. If you've already worked around the problem, please provide a commit before that fix.

here's a minimal bit of code:

def dec(g):
    def dec_inner(f):
        return f
    return dec_inner


@dec(1)
def f(x):
    print(x)


f(1)

What commands did you run?

$ ./venv/bin/coverage erase && ./venv/bin/coverage run --branch -m t && venv/bin/coverage report --show-missing
1
Name    Stmts   Miss Branch BrPart  Cover   Missing
---------------------------------------------------
t.py        8      0      2      1    90%   8->7
---------------------------------------------------
TOTAL       8      0      2      1    90%

Expected behavior
I expect 100% coverage from that script

Additional context
n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions