Skip to content

*: Compare strings by == or != instead of by `is` or `is not`

Kirill Smelkov requested to merge kirr/slapos.toolbox:y/str-eq into master

In python is checks object identity, not content:

In [1]: a = 'hello'

In [2]: a += ' world'

In [3]: b = 'hello world'

In [4]: id(a)
Out[4]: 139735676540976

In [5]: id(b)
Out[5]: 139735675829040

In [6]: a is b              <-- NOTE
Out[6]: False

In [7]: a == b              <-- NOTE
Out[7]: True

So comparing strings by is is generally incorrect.

-> Fix strings comparision to use == / != everywhere (at least in found places where string is compared wrt string literal)

We already had similar fix in a8526f4e, but seems the story continues again.

/cc @alain.takoudjou, @Just1, @lu.xu, @jhuge, @tomo

Merge request reports