Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 495982

Summary: zsh twisted tab completition is not working if python 3 is default system python
Product: Gentoo Linux Reporter: Jan Matějka (RETIRED) <yac>
Component: Current packagesAssignee: Tim Harder <radhermit>
Status: RESOLVED OBSOLETE    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Jan Matějka (RETIRED) gentoo-dev 2013-12-25 11:38:51 UTC
zsh twisted tab completition is not working if python 3 is default system python

Reproducible: Always

Steps to Reproduce:
1. eselect python set <3.x python>
2. trial <TAB><TAB>
3.
Actual Results:  
 % trial Traceback (most recent call last):
  File "<string>", line 2, in <module>
ImportError: No module named 'twisted'
ERROR: Cannot find twisted completion function files in $dir:q
Comment 1 Jan Matějka (RETIRED) gentoo-dev 2013-12-25 11:40:50 UTC
The original error is SyntaxError due to print function.

The one I reported I'm getting after fixing it.
Comment 2 Jan Matějka (RETIRED) gentoo-dev 2013-12-25 11:49:14 UTC
/usr/share/zsh/5.0.2/functions/Completion/Unix

--- _twisted.old	2013-12-25 12:42:35.156987358 +0100
+++ _twisted	2013-12-25 12:42:47.570987870 +0100
@@ -28,13 +28,11 @@
 
 function load_twisted_completions() {
     [[ -z $commands[twistd] ]] && echo 'ERROR: test command "twistd" not found in path' && return 1
-    shebang=$(head -1 $commands[twistd])
-    [[ $shebang != \#\!* ]] && echo 'ERROR: invalid shebang line for test script "twistd"' && return 1
-    PYTHON=$shebang[3,-1] # strip #! off the shebang
-    PYTHON=${PYTHON# *} # remove any spaces between #! and command
+    PYTHON=python2
 
     #debug PYTHON $PYTHON:q
     python_code='
+from __future__ import print_function
 import twisted, os.path
 dir = os.path.dirname(twisted.__file__)
 print (os.path.join(dir, "python", "zsh"))

Is fixing it for me, however I tested only with completing a dir I have in my PWD elsewhere.

I just skipped the detection of shebang binary because on gentoo it will always be generit `env python` for `which twisted` and we are in controll of what the expected executable name is.
Comment 3 Tim Harder gentoo-dev 2014-12-14 01:38:51 UTC
This shouldn't be an issue anymore with recent versions of zsh since the completions are now generated dynamically using the current command line with the special --_shell-completion option.