Steam for Linux > Limited Beta > Topic Details
Yegg Nov 6, 2012 @ 7:45pm
Issue Report: driverhelper.py contains Python3-incompatible statements
This causes fatal exceptions for me, on a python3-default system. Patch from 2to3:

--- ./ubuntu12_32/driverhelper.py (original)
+++ ./ubuntu12_32/driverhelper.py (refactored)
@@ -149,7 +149,7 @@
continue
if e.__dict__['type'] != 'deb':
continue
- if not e.__dict__.has_key('uri'):
+ if 'uri' not in e.__dict__:
continue
if e.__dict__['uri'].find('/x-updates/') != -1:
return True
@@ -353,7 +353,7 @@

if args[0] == 'get_info':
# Steam waits synchronously for these results
- print json.dumps(pkgInfo.getInfo())
+ print(json.dumps(pkgInfo.getInfo()))
return 0

if args[0] == 'enable_restricted_components':
Showing 1-4 of 4 comments
< >
Yegg Nov 6, 2012 @ 7:46pm 
(Both these changes should be compatible with python2, I believe.)
Frank Nov 7, 2012 @ 9:42am 
Thanks! This issue has been assigned tracking ID 93691.
Araneidae Dec 16, 2012 @ 5:53am 
Afraid I'm seeing further python3 incompatible issues:

Traceback (most recent call last):
File "/home/michael/.local/share/Steam/ubuntu12_32/driverhelper.py", line 431, in <module>
sys.exit(main(sys.argv[1:]))
File "/home/michael/.local/share/Steam/ubuntu12_32/driverhelper.py", line 368, in main
pkgInfo.init((args[1], args[2], args[3]))
File "/home/michael/.local/share/Steam/ubuntu12_32/driverhelper.py", line 276, in init
f = file(self.cache_file, 'w')
NameError: global name 'file' is not defined

I think the answer here is to use
open
instead of
file
.
Last edited by Araneidae; Dec 16, 2012 @ 5:54am
Araneidae Dec 16, 2012 @ 8:33am 
To be more fully compatible with python3 (I guess it's worth trying to write code that works for both), it's also necessary to add
from __future__ import print_function
at the start of the module and to use print as a function throughout; this will work for python 2.6 and later. This is actually a bit of a can of worms, as writing code that works for both versions of python is a trifle delicate, particularly when it comes to exception handling...

P.S. Can I see issue ID 93691 somewhere? I haven't found the bug tracking database yet, don't know if it's publicly visible.
Last edited by Araneidae; Dec 16, 2012 @ 8:34am
Showing 1-4 of 4 comments
< >
Per page: 15 30 50