terminator icon indicating copy to clipboard operation
terminator copied to clipboard

terminator crashes: TypeError: Item 0: Must be number, not str

Open bdrung opened this issue 2 years ago • 2 comments

Describe the bug

terminator -e command crashes when called via x-terminal-emulator symlink:

Traceback (most recent call last):
  File "/usr/bin/x-terminal-emulator", line 133, in <module>
    TERMINATOR.layout_done()
  File "/usr/lib/python3/dist-packages/terminatorlib/terminator.py", line 329, in layout_done
    terminal.spawn_child()
  File "/usr/lib/python3/dist-packages/terminatorlib/terminal.py", line 1482, in spawn_child
    self.vte.feed(_('Unable to find a shell'))
TypeError: Item 0: Must be number, not str

To Reproduce

Steps to reproduce in a clean environment (you can start at step 5 if you want to test in your environment):

  1. Launch ubuntu-22.04-desktop-amd64.iso in a VM
  2. Try Ubuntu
  3. Open terminal
  4. Install terminator:
echo "deb http://archive.ubuntu.com/ubuntu/ jammy universe" | sudo tee -a /etc/apt/sources.list
sudo apt update
sudo apt -y install terminator
  1. Run following command. This command will open terminator and print "success".
terminator -e "sh -c 'echo success; sleep 2'"
  1. Run the same command via the x-terminal-emulator symlink:
x-terminal-emulator -e "sh -c 'echo success; sleep 2'"

Same result when running:

x-terminal-emulator -u -g /dev/null -e "sh -c 'echo success; sleep 2'"

Desktop (please complete the following information):

  • OS or Linux Distribution: Ubuntu
  • Version 22.04
  • Display Technology: Wayland

Ubuntu 22.04 ships terminator 2.1.1-1

Bug-Ubuntu: https://launchpad.net/bugs/1983099

bdrung avatar Jul 29 '22 12:07 bdrung

Same error happens from a different origin when trying to add the terminal number (padded or not). Error msg when clicking to add the terminal number:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/terminatorlib/terminator.py", line 592, in do_enumerate
    term.feed(numstr % (idx + 1))
  File "/usr/lib/python3/dist-packages/terminatorlib/terminal.py", line 1584, in feed
    self.vte.feed_child(text)
TypeError: Item 0: Must be number, not str

Terminator version:

$ terminator -v
terminator 2.1.1

OS:

$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

Potential fix: Because I really need this functionality, I digged a bit and found that the fix for this is to add the ".encode()" to the 'text' on function feed() from terminatorlib/terminal.py:

    def feed(self, text):
        """Feed the supplied text to VTE"""
        self.vte.feed_child(text.encode())

pwakano avatar Aug 08 '22 04:08 pwakano

Damnit, I thought I fixed all of these "feed" bugs already. Would you mind making the changes into a PR which I can then pull in to the code?

mattrose avatar Aug 18 '22 11:08 mattrose

fixed #659

mattrose avatar Nov 08 '22 23:11 mattrose