overloading.py not compatible with python2.6

Bug #1470589 reported by Tom Henderson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PyBindGen
Fix Committed
Undecided
Unassigned

Bug Description

ns-3 will not find pybindgen on a Python2.6 system (CentOS 6.6) due to this incompatibility:

Checking for python module 'pybindgen'
['/usr/bin/python', '-c', "\nimport pybindgen as current_module\nversion = getattr(current_module, '__version__', None)\nif version is not None:\n\tprint(str(version))\nelse:\n\tprint('unknown version')\n"]
err: Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/tmp/ns-3-allinone/pybindgen/pybindgen/__init__.py", line 2, in <module>
    from pybindgen.module import Module
  File "/tmp/ns-3-allinone/pybindgen/pybindgen/module.py", line 48, in <module>
    from pybindgen.function import Function, OverloadedFunction, CustomFunctionWrapper
  File "/tmp/ns-3-allinone/pybindgen/pybindgen/function.py", line 20, in <module>
    from pybindgen import overloading
  File "/tmp/ns-3-allinone/pybindgen/pybindgen/overloading.py", line 277
    docstrings_set = {wrap.docstring for wrap in self.all_wrappers if wrap.docstring is not None}
                                       ^
SyntaxError: invalid syntax

not found
from /tmp/ns-3-allinone/ns-3-dev/bindings/python: Could not find the python module 'pybindgen'

This patch fixed it for me:

--- pybindgen/overloading.py 2014-09-14 15:39:02 +0000
+++ pybindgen/overloading.py 2015-07-01 17:26:08 +0000
@@ -274,7 +274,10 @@
                             NotSupportedError):
                         pass
             # check available docstrings for the overloads
- docstrings_set = {wrap.docstring for wrap in self.all_wrappers if wrap.docstring is not None}
+ docstrings_set = {}
+ if wrap.docstring is not None:
+ for wrap in self.all_wrappers:
+ docstrings_set.add (wrap.docstring)
             docstring = None
             if len(docstrings_set) is 1:
                 docstring = docstrings_set.pop()

Related branches

Revision history for this message
Tom Henderson (tomh-tomh) wrote :

actually, this patch is broken; instead, the attached should work

Revision history for this message
Gustavo Carneiro (gjc) wrote :

Thanks, Tom!

I think this part is wrong:

+ docstrings_set = {}

{} is an empty dict, not an empty set. An empty set needs to be spelled out `set()`.

Fixed, committed, and pushed.

Changed in pybindgen:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.