Closed Bug 1654795 Opened 4 years ago Closed 4 years ago

mach clang-formant -c HEAD fails with TypeError: a bytes-like object is required, not 'str'

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

defect

Tracking

(firefox-esr68 unaffected, firefox-esr78 unaffected, firefox78 unaffected, firefox79 unaffected, firefox80 fixed)

RESOLVED FIXED
mozilla80
Tracking Status
firefox-esr68 --- unaffected
firefox-esr78 --- unaffected
firefox78 --- unaffected
firefox79 --- unaffected
firefox80 --- fixed

People

(Reporter: emilio, Assigned: emilio)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression)

Attachments

(1 file)

$ ./mach clang-format -c HEAD                                                                                                                                                                                                        
Error running mach:

    ['clang-format', '-c', 'HEAD']

The error occurred in the implementation of the invoked mach command.

This should never occur and is likely a bug in the implementation of that
command.
You can invoke |./mach busted| to check if this issue is already on file. If it
isn't, please use |./mach busted file clang-format| to report it. If |./mach busted| is
misbehaving, you can also inspect the dependencies of bug 1543241.

If filing a bug, please include the full output of mach, including this error
message.

The details of the failure are as follows:

TypeError: a bytes-like object is required, not 'str'

  File "/home/emilio/src/moz/gecko-5/python/mozbuild/mozbuild/code-analysis/mach_commands.py", line 1723, in clang_format
    return self._run_clang_format_diff(self._clang_format_diff,
  File "/home/emilio/src/moz/gecko-5/python/mozbuild/mozbuild/code-analysis/mach_commands.py", line 2150, in _run_clang_format_diff
    diff_process = Popen(self._get_clang_format_diff_command(commit), stdout=PIPE)
  File "/home/emilio/src/moz/gecko-5/python/mozbuild/mozbuild/code-analysis/mach_commands.py", line 2092, in _get_clang_format_diff_command
    pattern = pattern.replace('.*', '**')

I bet it's a regression from bug 1606475

Assignee: nobody → emilio
Status: NEW → ASSIGNED

Using six.ensure_str will be a better approach here because in py3 using just str will convert a bytes string into str string while keeping the the b letter in it while ensure_str will decode pattern if it is of type bytes to a proper str.
I couldn't comment on phabricator as I didn't have permission.

Flags: needinfo?(emilio)

Huh, how didn't you have permission? Anyhow thanks for the suggestion! I'm far from a Python2 / 3 expert and it makes sense to me, so I applied it :)

Flags: needinfo?(emilio)
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/04c1d72c0353
Fix mach clang-format python3 error. r=andi

I'm just a contributor maybe thats why I didn't have the permission to comment

Hmm, I think as long as you have an account you should be able to comment, were you logged in?

Yeah, I was logged in.

Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla80

Set release status flags based on info from the regressing bug 1606475

Has Regression Range: --- → yes
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: