Bug 127128

Summary: Inspector scripts are not compatible with Python v3
Product: WebKit Reporter: Marcel Tiede <marcel.tiede>
Component: WebKitGTKAssignee: Zan Dobersek <zan>
Status: RESOLVED FIXED    
Severity: Normal CC: joepeck, timothy, zan
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
Patch benjamin: review+

Description Marcel Tiede 2014-01-16 11:58:59 PST
Trying to build the current unstable release 2.3.4 under Archlinux fails. Archlinux is using python3 as "/usr/bin/python".

---
File "./Source/JavaScriptCore/inspector/scripts/jsmin.py", line 33, in <module>
    from StringIO import StringIO
ImportError: No module named 'StringIO'
---

As I'm not a python developer I tried fixing this by simply loading the python3 Module io for StringIO, what revealed the next error:

---
 File "./Source/JavaScriptCore/inspector/scripts/generate-combined-inspector-json.py", line 32
    print "usage: %s [json files or directory of json files ...]" % os.path.basename(sys.argv[0])
                                                                ^
SyntaxError: invalid syntax
---

Using parentheses for all print commands in the file "generate-combined-inspector-json.py" fixed the compilation issue.
Comment 1 Zan Dobersek 2014-01-17 03:12:23 PST
Created attachment 221453 [details]
Patch
Comment 2 Benjamin Poulain 2014-01-17 13:06:56 PST
Comment on attachment 221453 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=221453&action=review

cool!

> Source/JavaScriptCore/inspector/scripts/jsmin.py:36
> +try:
> +    from StringIO import StringIO
> +except ImportError:
> +    from io import StringIO

Maybe add a Python3 comment here so that we know to remove it in the future?
Comment 3 Zan Dobersek 2014-01-18 01:00:22 PST
Committed r162250: <http://trac.webkit.org/changeset/162250>