Skip to content

[Bug]: py_test / py_binary incorrectly handle an exec_properties attribute that is explicitly set to None #605

@bd-tkoolen

Description

@bd-tkoolen

What happened?

If exec_properties for a py_binary or py_test is explicitly set to None, an error of the form

Error: 'NoneType' value has no field or method 'items'

is raised on this line:

non_test_exec_properties = {k: v for k, v in exec_properties.items() if not k.startswith("test.")}

In our case, the explicit value of None came from a symbolic macro that used inherit_attrs = "common". This regression was found when trying upgrade from version 1.3.2 to version 1.6.0. Our workaround is to use

if kwargs.get("exec_properties", None) == None:
        kwargs["exec_properties"] = {}

in symbolic macro implementations that create py_* targets.

This regression appears to have been introduced in #529; CC @keith.

Version

Development (host) and target OS/architectures: irrelevant

Output of bazel --version: bazel 8.1.1

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file: 1.6.0

Language(s) and/or frameworks involved: irrelevant

How to reproduce

py_binary(
    name = "foo",
    srcs = ["foo.py"],
    exec_properties = None,
)

Any other information?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions