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

master: replace most str occurences by string_types #3139

Closed
wants to merge 1 commit into from

Conversation

rjarry
Copy link
Contributor

@rjarry rjarry commented Apr 21, 2017

When configuring some services in master.cfg with:

from __future__ import unicode_literals
from buildbot.plugins.db import steps
b = steps.ShellCommand(
    name='do stuff',
    command=['stuff'],
)

there are errors with python 2:

BuildStep name must be a string: u'do stuff'

BuildStep is only an example, there are other constructors that do not accept unicode strings.

Since almost all internal API work on unicode strings, replace most checks that a variable is a string by testing if it is an instance of string_types (from future.utils).

Contributor Checklist:

  • I have updated the appropriate documentation

When configuring some services in master.cfg with:

    from __future__ import unicode_literals
    from buildbot.plugins.db import steps
    b = steps.ShellCommand(
        name='do stuff',
        command=['stuff'],
    )

there are errors with python 2:

    BuildStep name must be a string: u'do stuff'

BuildStep is only an example, there are other constructors that do not
accept unicode strings.

Since almost all internal API work on unicode strings, replace most
checks that a variable is a string by testing if it is an instance of
string_types (from future.utils).

Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
@mention-bot
Copy link

@rjarry, thanks for your PR! By analyzing the history of the files in this pull request, we identified @catlee, @ewongbb and @tardyp to be potential reviewers.

@codecov
Copy link

codecov bot commented Apr 21, 2017

Codecov Report

Merging #3139 into master will increase coverage by <.01%.
The diff coverage is 95.65%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3139      +/-   ##
==========================================
+ Coverage   88.32%   88.32%   +<.01%     
==========================================
  Files         314      314              
  Lines       32995    33007      +12     
==========================================
+ Hits        29142    29154      +12     
  Misses       3853     3853
Impacted Files Coverage Δ
master/buildbot/steps/shellsequence.py 95.94% <100%> (+0.05%) ⬆️
master/buildbot/reporters/mail.py 95.44% <100%> (ø) ⬆️
master/buildbot/process/buildstep.py 90.55% <100%> (ø) ⬆️
master/buildbot/mq/simple.py 100% <100%> (ø) ⬆️
master/buildbot/util/__init__.py 94.56% <100%> (ø) ⬆️
master/buildbot/scripts/base.py 93.68% <100%> (+0.03%) ⬆️
master/buildbot/process/log.py 97.19% <100%> (+0.02%) ⬆️
master/buildbot/steps/source/base.py 93.75% <100%> (+0.04%) ⬆️
master/buildbot/worker/base.py 89.75% <100%> (+0.03%) ⬆️
master/buildbot/config.py 98.41% <100%> (ø) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cb752cd...7ce8c38. Read the comment docs.

Copy link
Member

@tardyp tardyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the principle I of course agree with this change.
However this is not really tested.
We should have tests ensuring the step works with both types.

Another option is to enforce unicode everywhere.

from buildbot.util import bytes2unicode
if isintance(foo, string_types)
   foo = bytes2unicode(foo)
else:
  config.error("foo must be string or unicode")

That way, I will be more confident that the unit tests will catch incompatibilities

@rjarry
Copy link
Contributor Author

rjarry commented Apr 21, 2017

Ok I understand. I'll have a look at maybe enhancing the tests and force convert to unicode.

@stale stale bot added the stalled label Jun 30, 2017
@stale
Copy link

stale bot commented Jun 30, 2017

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot closed this Jun 30, 2017
@stale
Copy link

stale bot commented Jun 30, 2017

closing due to our stalled pull request policy

@rjarry rjarry deleted the unicode-friendly branch February 13, 2018 11:45
@p12tic
Copy link
Member

p12tic commented Dec 10, 2020

Removing labels as we no longer need this in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants