Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incompatible_string_join_requires_strings: string.join(list) accepts invalid (non-string) list elements #7802

Open
laurentlb opened this issue Mar 21, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@laurentlb
Copy link
Contributor

commented Mar 21, 2019

With --incompatible_string_join_requires_strings=false, this code is accepted by Bazel:

>> ",".join(["a", 1, None, (2, 3)])
.. 
"a,1,None,(2, 3)"

However the argument of string.join should an iterable of strings. Bazel currently implicitly converts each item to a string (https://github.com/bazelbuild/starlark/blob/master/spec.md#stringjoin).

In the future, this will be an error and we'll set --incompatible_string_join_requires_strings to true. If your code relies on the old behavior, you may do the conversion explicitly:

- ", ".join(my_list)
+ ", ".join([str(e) for e in my_list])

bazel-io pushed a commit that referenced this issue Mar 28, 2019

Introduce new flag `--incompatible_string_join_requires_strings`
#7802

RELNOTES:
  A new flag `--incompatible_string_join_requires_strings` is introduced. The sequence argument of `string.join` must contain only string elements.
PiperOrigin-RevId: 240775005

@laurentlb laurentlb changed the title string.join(list) accepts invalid (non-string) list elements incompatible_string_join_requires_strings: string.join(list) accepts invalid (non-string) list elements Mar 28, 2019

@dkelmer

This comment has been minimized.

Copy link
Contributor

commented Apr 3, 2019

@laurentlb, is the migration window 1 release? I added the breaking-change-0.26 label if it is, but if it's not, that needs to be updated

emusand added a commit to emusand/bazel that referenced this issue Apr 16, 2019

Introduce new flag `--incompatible_string_join_requires_strings`
bazelbuild#7802

RELNOTES:
  A new flag `--incompatible_string_join_requires_strings` is introduced. The sequence argument of `string.join` must contain only string elements.
PiperOrigin-RevId: 240775005

irengrig added a commit to irengrig/bazel that referenced this issue May 3, 2019

Introduce new flag `--incompatible_string_join_requires_strings`
bazelbuild#7802

RELNOTES:
  A new flag `--incompatible_string_join_requires_strings` is introduced. The sequence argument of `string.join` must contain only string elements.
PiperOrigin-RevId: 240775005
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.