Menu

#679 PyTango.server tries to import missing __builtin__ module on Python 3

closed-fixed
None
PyTango
5
2014-09-30
2014-08-09
No

http://www.tango-controls.org/static/PyTango/latest/doc/html/quicktour.html#server shows the new API.
I'm on Ubuntu 14.04 and I installed the python3-pytango package, however when I try to import "PyTango.server" as showed in the example I get an error:

Python 3.4.0 (default, Apr 11 2014, 13:05:18) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyTango                    
>>> PyTango.__version__               
'8.1.1'
>>> PyTango.__version_long__
'8.1.1final0'
>>> PyTango.Release.version_long
'8.1.1final0'
>>> import PyTango.constants
>>> PyTango.constants.TgLibVers
'8.1.2'
>>> from PyTango.server import Device
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/PyTango/server.py", line 158, in <module>
    import __builtin__
ImportError: No module named '__builtin__'

PyTango.server tries to import the "__builtin__" module and fails because on Python 3 the module is called "builtins". However the __builtin__ module doesn't appear to be used, and if I remove that line I can import PyTango.server successfully. I haven't tested if the rest works, but I took a look at the code and the rest seems compatible with Python 3 (except for a couple of docstrings that suggest the use of "class Foo: __metaclass__ = Meta" instead of "class Foo(metaclass=Meta): ..."). There are also a few other unused imports (and extra trailing whitespace throughout the file), so maybe those should be checked as well, possibly using some lint tool.

FWIW before upgrading to Ubuntu 14.04 I also tried with Ubuntu 13.10.
There the "server" module is missing, but there is a seemingly equivalent "api2" module (probably a work-in-progress version of what became the "server" module).
With Python 3 I got the same error on Ubuntu 13.10:

>>> import PyTango
>>> PyTango.__version__
'8.0.4'
>>> import PyTango.api2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/PyTango/api2.py", line 220, in <module>
    import __builtin__

Discussion

  • Tiago Coutinho

    Tiago Coutinho - 2014-09-10
    • status: open --> open-fixed
    • assigned_to: Tiago Coutinho
     
  • Tiago Coutinho

    Tiago Coutinho - 2014-09-10

    You are right: __builtin__ is not used so I removed it.
    Also removed other unused import statements.

    I keep documenting __metaclass__ only in python 2 way because otherwise the documentation would grow enormously.

    The HLAPI feature (TEP 0001) only became official in PyTango 8.1.2.
    It is true that before the feature was distributed as "api2" module but it was for testing purposes only. The correct way is to use PyTango.server.
    I also updated the TEP 0001 documentation in SVN.

    Thanks for reporting.

    Fixed in PyTango SVN trunk since revision #26440
    Will become visible in next PyTango release 8.1.4

     
  • Tiago Coutinho

    Tiago Coutinho - 2014-09-30
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB