bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.21k stars 4.06k forks source link

PyInfo() constructor does not use its has_py3_only_sources parameter #21971

Open dws opened 7 months ago

dws commented 7 months ago

Description of the bug:

Commit c475a9db0b237f8e2725c35128253a0ae1dd080e introduced a new routine _PyInfo_init in src/main/starlark/builtins_bzl/common/python/providers.bzl which does the following:

        "has_py2_only_sources": has_py2_only_sources,
        "has_py3_only_sources": has_py2_only_sources,

I believe the second line there should be

        "has_py3_only_sources": has_py3_only_sources,

so that the value of a has_py3_only_sources parameter to the routine is reflected in its return value.

Which category does this issue belong to?

Python Rules

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

BUILD.bazel:

load(":pyinfo.bzl", "pyinfo")

pyinfo()

pyinfo.bzl:

def pyinfo():
    print("expect True: {}".format(PyInfo(transitive_sources = depset(), has_py3_only_sources = True).has_py3_only_sources))

Under Bazel 6.20, building the above prints expect True: True Under Bazel 7..1.1, building the above prints expect True: False

Which operating system are you running Bazel on?

Ubuntu 20.04

What is the output of bazel info release?

release 7.1.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

Yes. The bad line was introduced in commit c475a9db0b237f8e2725c35128253a0ae1dd080e

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

dws commented 7 months ago

@rickeylev FYI