Closed Bug 1606955 Opened 4 years ago Closed 4 years ago TypeError error in python3


(Firefox Build System :: Bootstrap Configuration, defect, P3)



(firefox74 fixed)

Tracking Status
firefox74 --- fixed


(Reporter: matt, Assigned: rstewart)



(Keywords: in-triage)


(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:72.0) Gecko/20100101 Firefox/72.0

Steps to reproduce:

Followed the instructions at:

Specifically downloaded (python/mozboot/mozboot/ ) and with python3 as my interpreter:

$ python

(Note, I was able to bootstrap successfully with python2.)

Actual results:


Traceback (most recent call last):
File "", line 195, in <module>
File "", line 186, in main
File "/var/folders/2q/npkhtcmd0vx_98jlhmj_jcxc0000gn/T/tmpxj7679x8/mozboot/", line 497, in bootstrap
File "/var/folders/2q/npkhtcmd0vx_98jlhmj_jcxc0000gn/T/tmpxj7679x8/mozboot/", line 618, in hg_clone_firefox
TypeError: a bytes-like object is required, not 'str'

Expected results:

Script should not have bombed.

The issue appears to be here:


with open(os.path.join(dest, '.hg', 'hgrc'), 'ab') as fh:

Opening a file in binary mode and writing a string will cause a TypeError in python3, but not python2.

Fix should be to just open the file in text mode.

Keywords: in-triage
Priority: -- → P3
Assignee: nobody → rstewart

Hi Matt -- thanks for the patch. Can you submit it on Phabricator? You can set firefox-build-system-reviewers as the reviewer and I'll sign off on it.

Flags: needinfo?(matt)
Ever confirmed: true

Hi Ricky -- I submitted the patch to Phabricator. While doing some extra testing locally, I realized that the bootstrap process still bombs out in python3, trying to import urlparse, which was renamed in py3. I'm happy to go down the rabbit hole here, but before I do, I just want to make sure that the bootstrap process is intended to be py3 compatible. I assumed it would be since py2 is EOL now, but if this hasn't been a priority yet, it could be a bigger project than just fixing a few imports. So, I guess, let me know if you think it's worthwhile to pull this thread or if my efforts would be better placed elsewhere.

Flags: needinfo?(matt) → needinfo?(rstewart)

Hi Matt, thanks for checking in. Yes, bootstrapping should work with Python 3. :) Bug 1568964 tracks this work.

Unfortunately I think it will be a bigger problem than fixing a few imports. Namely, bug 1568964 depends on bug 1524639 which is going to be more complicated and is something that I'll probably be working on myself.

You're still welcome to submit patches for obvious issues as you find them, but I wouldn't recommend going on the rabbit hole on this particular issue unless you're ready to go deeper than you might have anticipated :)

Flags: needinfo?(rstewart)
Pushed by
open hgrc in text mode for py 2 and 3 compatability. r=firefox-build-system-reviewers,rstewart
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74
You need to log in before you can comment on or make changes to this bug.