patch 7.4.1315
Problem:    Using a channel handle does not allow for freeing it when unused.
Solution:   Add the Channel variable type.
diff --git a/src/testdir/test_channel.py b/src/testdir/test_channel.py
index 311fbc0..ce6d5c1 100644
--- a/src/testdir/test_channel.py
+++ b/src/testdir/test_channel.py
@@ -1,13 +1,7 @@
 #!/usr/bin/python
 #
 # Server that will accept connections from a Vim channel.
-# Run this server and then in Vim you can open the channel:
-#  :let handle = ch_open('localhost:8765', 'json')
-#
-# Then Vim can send requests to the server:
-#  :let response = ch_sendexpr(handle, 'hello!')
-#
-# See ":help channel-demo" in Vim.
+# Used by test_channel.vim.
 #
 # This requires Python 2.6 or later.
 
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index f0a149d..e894c09 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -83,7 +83,6 @@
   endif
 endfunc
 
-let s:responseHandle = -1
 let s:responseMsg = ''
 func s:RequestHandler(handle, msg)
   let s:responseHandle = a:handle
@@ -92,7 +91,7 @@
 
 func s:communicate(port)
   let handle = ch_open('localhost:' . a:port, s:chopt)
-  if handle < 0
+  if ch_status(handle) == "fail"
     call assert_false(1, "Can't open channel")
     return
   endif
@@ -115,14 +114,22 @@
   " Send a request with a specific handler.
   call ch_sendexpr(handle, 'hello!', 's:RequestHandler')
   sleep 10m
-  call assert_equal(handle, s:responseHandle)
+  if !exists('s:responseHandle')
+    call assert_false(1, 's:responseHandle was not set')
+  else
+    call assert_equal(handle, s:responseHandle)
+  endif
   call assert_equal('got it', s:responseMsg)
 
-  let s:responseHandle = -1
+  unlet s:responseHandle
   let s:responseMsg = ''
   call ch_sendexpr(handle, 'hello!', function('s:RequestHandler'))
   sleep 10m
-  call assert_equal(handle, s:responseHandle)
+  if !exists('s:responseHandle')
+    call assert_false(1, 's:responseHandle was not set')
+  else
+    call assert_equal(handle, s:responseHandle)
+  endif
   call assert_equal('got it', s:responseMsg)
 
   " Send an eval request that works.
@@ -169,7 +176,7 @@
 " Test that we can open two channels.
 func s:two_channels(port)
   let handle = ch_open('localhost:' . a:port, s:chopt)
-  if handle < 0
+  if ch_status(handle) == "fail"
     call assert_false(1, "Can't open channel")
     return
   endif
@@ -177,7 +184,7 @@
   call assert_equal('got it', ch_sendexpr(handle, 'hello!'))
 
   let newhandle = ch_open('localhost:' . a:port, s:chopt)
-  if newhandle < 0
+  if ch_status(newhandle) == "fail"
     call assert_false(1, "Can't open second channel")
     return
   endif
@@ -197,7 +204,7 @@
 " Test that a server crash is handled gracefully.
 func s:server_crash(port)
   let handle = ch_open('localhost:' . a:port, s:chopt)
-  if handle < 0
+  if ch_status(handle) == "fail"
     call assert_false(1, "Can't open channel")
     return
   endif
@@ -219,7 +226,7 @@
 
 func s:channel_handler(port)
   let handle = ch_open('localhost:' . a:port, s:chopt)
-  if handle < 0
+  if ch_status(handle) == "fail"
     call assert_false(1, "Can't open channel")
     return
   endif
@@ -247,7 +254,7 @@
 func Test_connect_waittime()
   let start = reltime()
   let handle = ch_open('localhost:9876', s:chopt)
-  if handle >= 0
+  if ch_status(handle) == "fail"
     " Oops, port does exists.
     call ch_close(handle)
   else
@@ -257,7 +264,7 @@
 
   let start = reltime()
   let handle = ch_open('localhost:9867', {'waittime': 2000})
-  if handle >= 0
+  if ch_status(handle) != "fail"
     " Oops, port does exists.
     call ch_close(handle)
   else