Select session does not work with python 2

Bug #1550687 reported by Björn Torkelsson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
byobu
Fix Released
Medium
Dustin Kirkland 

Bug Description

In select-session.py you recently added an eval on the input when choosing with session to join/start new session/or a plain shell, however on python 2 you get a traceback when using eval on input (which is captured by the exception):

--------------- Example ----------------
#!/usr/bin/python

import os
import sys

choice = 1
choice = int(input("\nChoose 1-9 [1]: "))
sys.stdout.write("Choice %d\n" % choice)

choice = 1
choice = int(eval(input("\nChoose 1-9 [1]: ")))
sys.stdout.write("Choice %d\n" % choice)
---------------------------------------------

$ python2.7 inputtest.py

Choose 1-9 [1]: 2
Choice 2

Choose 1-9 [1]: 2
Traceback (most recent call last):
  File "inputtest.py", line 11, in <module>
    choice = int(eval(input("\nChoose 1-9 [1]: ")))
TypeError: eval() arg 1 must be a string or code object

python3 inputtest.py

Choose 1-9 [1]: 2
Choice 2

Choose 1-9 [1]: 2
Choice 2

Related branches

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

kirkland@x250:~/src/byobu/byobu⟫ debcommit
bzr commit -m '* usr/lib/byobu/include/select-session.py: LP: #1550687
  - make sure input/eval is compatible with both python2 and 3' --fixes 'lp:1550687'
Committing to: /srv/media/src/byobu/byobu/
modified debian/changelog
modified usr/lib/byobu/include/select-session.py
Committed revision 2467.

Changed in byobu:
status: New → Fix Committed
importance: Undecided → Medium
assignee: nobody → Dustin Kirkland  (kirkland)
Changed in byobu:
status: Fix Committed → Fix Released
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.