[Piglit] [PATCH 04/20] framework: Update import statements to support Python 3.x in addition to 2.x.

Kenneth Graunke kenneth at whitecape.org
Wed Apr 17 02:52:28 PDT 2013


Hi Jon,

There's a lot going on in this patch, for example:
1. Search and replace of, say, ConfigParser with configparser
2. try/expect blocks for using both Python 2/3 names for various things
3. Modifying the path all over the place.
4. Reorganizing imports

It'd be nice to split this into multiple patches.  I've taken a stab at 
that, and will send that out shortly.  I retained your authorship on the 
patches since you actually wrote 98% of the code in them, so you deserve 
the credit.  Let me know what you think!

One thing I didn't understand was the change from:
    os.path.dirname(os.path.realpath(sys.argv[0]))
to:
    os.path.dirname(__file__)

I created a /home/kwg/Projects/piglit/foo.py script and ran it via both 
"python2 foo.py" and "python3 foo.py" and got:

/home/kwg/Projects/piglit
(nothing)

So they don't seem to be the same, and the old code appears to work fine 
on both Python 2 and Python 3.

I think we can avoid this, however, by using explicit relative imports. 
  I'll send the patch out for that.

Thanks again!
--Ken


More information about the Piglit mailing list