Closed Bug 1606955 Opened 2 years ago Closed 2 years ago

bootstrap.py TypeError error in python3

Categories

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

defect

Tracking

(firefox74 fixed)

RESOLVED FIXED
mozilla74
Tracking Status
firefox74 --- fixed

People

(Reporter: matt, Assigned: rstewart)

References

Details

(Keywords: in-triage)

Attachments

(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: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/Mac_OS_X_Prerequisites

Specifically downloaded bootstrap.py (python/mozboot/mozboot/bootstrap.py@5fd4cfacc90ddd975c82ba27fdc56f4187b3f180 ) and with python3 as my interpreter:

$ python bootstrap.py

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

Actual results:

...

Traceback (most recent call last):
File "bootstrap.py", line 195, in <module>
sys.exit(main(sys.argv))
File "bootstrap.py", line 186, in main
dasboot.bootstrap()
File "/var/folders/2q/npkhtcmd0vx_98jlhmj_jcxc0000gn/T/tmpxj7679x8/mozboot/bootstrap.py", line 497, in bootstrap
File "/var/folders/2q/npkhtcmd0vx_98jlhmj_jcxc0000gn/T/tmpxj7679x8/mozboot/bootstrap.py", 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:

https://hg.mozilla.org/mozilla-central/file/tip/python/mozboot/mozboot/bootstrap.py#l617

Specifically:

with open(os.path.join(dest, '.hg', 'hgrc'), 'ab') as fh:
fh.write('[paths]\n')

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.

https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/How_to_Submit_a_Patch

Flags: needinfo?(matt)
Status: UNCONFIRMED → ASSIGNED
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 rstewart@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/46f55426366a
open hgrc in text mode for py 2 and 3 compatability. r=firefox-build-system-reviewers,rstewart
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74
You need to log in before you can comment on or make changes to this bug.