Closed Bug 601649 Opened 9 years ago Closed 9 years ago

Client.py doesn't work with python3

Categories

(MailNews Core :: Build Config, defect, minor)

defect
Not set
minor

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 3.3a1

People

(Reporter: fredbezies, Assigned: Callek)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:2.0b7pre) Gecko/20100101 Firefox/4.0b7pre
Build Identifier: 

Archlinux upgraded today its python version to python3 in its testing repository, and created a python2 package with python 2.7 in it.

[fred@fredo-arch src]$ python2
Python 2.7 (r27:82500, Aug 17 2010, 12:18:26) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.

[fred@fredo-arch src]$ python
Python 3.1.2 (r312:79147, Oct  4 2010, 12:45:09) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.

When I wanted to update my shredder source code, I got this :

[fred@fredo-arch src]$ python client.py checkout --verbose
  File "client.py", line 100
    print "Executing command:", cmd
                             ^
SyntaxError: invalid syntax

Reproducible: Always

Steps to Reproduce:
1.Update to Python 3
2.run python client.py checkout --verbose

Actual Results:  
Crash.

Expected Results:  
client.py grabbing updates.
Component: General → Build Config
Product: Core → Thunderbird
QA Contact: general → build-config
Which comm-central branch are you trying to pull? Trunk should already catch that.

http://mxr.mozilla.org/comm-central/source/client.py?mark=61-68#61
Severity: normal → minor
OS: Linux → All
Product: Thunderbird → MailNews Core
QA Contact: build-config → build-config
Hardware: x86_64 → All
Well, it doesn't work with python 3.1.2

And my computer is trying to pull trunk code. As there is a /usr/bin/python2 symlink for /usr/bin/python2.7, I can workaround this problem by doing :

python2 client.py checkout --verbose instead of python client.py checkout
By the way, I tried to reproduce by hand the sniffing version line.

Here is what I get :

[fred@fredo-arch ~]$ python
Python 3.1.2 (r312:79147, Oct  4 2010, 12:45:09) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> pyver = sys.version_info
>>> pyver[0]
3

So there is a problem somewhere ;)
Ok, lets see:

#1 can you try |sys.exit("test")| in your py3 shell and tell me if that errors on you?

#2 can you try running |http://callek.pastebin.mozilla.org/806504| and see if THAT errors on you?

#3 can you try running |http://callek.pastebin.mozilla.org/806505|

I'd be interested to see which fails for you.

Also can you do an |hg identify| in your repo where client.py is located, I'd also like to know what revision you are running.
Status: NEW → UNCONFIRMED
Ever confirmed: false
1) Python 3.1.2 (r312:79147, Oct  4 2010, 12:45:09) 
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> sys.exit("test")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'sys' is not defined


2) ERROR: Python series 3 is not supported, use series 2 >= 2.4

3) [fred@fredo-arch download]$ python 806505.txt
  File "806505.txt", line 70
    print "Purposely fail py3 semantics"
                                       ^
SyntaxError: invalid syntax

4) [fred@fredo-arch src]$ hg identify
086d167a0505 tip
(In reply to comment #5)
> 2) ERROR: Python series 3 is not supported, use series 2 >= 2.4
> 
> 3) [fred@fredo-arch download]$ python 806505.txt
>   File "806505.txt", line 70
>     print "Purposely fail py3 semantics"
>                                        ^
> SyntaxError: invalid syntax
> 

Argh, py3.1 is parsing "ahead" of where it needs to execute and bailing. :/  I might have an idea, but need to investigate. And since I don't really want to install py3.1 on my system I'll rely on you to test my theory. Will do it within the week though.
Assignee: nobody → bugspam.Callek
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
No problem. If I can help you, I'll do it with pleasure.
Ok, after investigating this, it turns out that the full context needs to be valid py<ver> for it to begin executing. Which means that the whole file needs py3 syntax to parse the pyver test, and thus bail out.

I have an idea to make the error more prevalent (use |print "..."| instead of |sys.exit| with a proper comment)

But otherwise, I don't see an easy way to avoid the traceback, unless I was to split out the entirety of client.py to a new file, except for the ver check; which I don't want to do.
Attachment #481395 - Flags: review?(bugzilla)
Comment on attachment 481395 [details] [diff] [review]
Make py3 error (more) clearly.

Yep, let's give this a try.
Attachment #481395 - Flags: review?(bugzilla) → review+
Pushed as: http://hg.mozilla.org/comm-central/rev/426abd4c74c7

Frederic, is this satisfactory at least until we (start) supporting py3 ?
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Flags: in-testsuite-
Target Milestone: --- → Thunderbird 3.3a1
Version: unspecified → Trunk
I think so. I will not have time to test this at least until tuesday morning.
You need to log in before you can comment on or make changes to this bug.