updated for version 7.3.1236
Problem:    Python: WindowSetattr() missing support for NUMBER_UNSIGNED.
Solution:   Add NUMBER_UNSIGNED, add more tests. Various fixes. (ZyX)
diff --git a/src/testdir/test87.in b/src/testdir/test87.in
index 6b89117..88a8d88 100644
--- a/src/testdir/test87.in
+++ b/src/testdir/test87.in
@@ -290,7 +290,7 @@
 :" threading
 :let l = [0]
 :py3 l=vim.bindeval('l')
-:py3 <<EOF
+py3 <<EOF
 import threading
 import time
 
@@ -320,7 +320,7 @@
 :" settrace
 :let l = []
 :py3 l=vim.bindeval('l')
-:py3 <<EOF
+py3 <<EOF
 import sys
 
 def traceit(frame, event, arg):
@@ -335,9 +335,9 @@
 EOF
 :py3 sys.settrace(traceit)
 :py3 trace_main()
+:py3 sys.settrace(None)
 :py3 del traceit
 :py3 del trace_main
-:py3 sys.settrace(None)
 :$put =string(l)
 :"
 :" Vars
@@ -898,6 +898,7 @@
         '{"": 1}',              # Same, but with unicode object
         'FailingMapping()',     #
         'FailingMappingKey()',  #
+        'FailingNumber()',      #
     ))
 
 def convertfrompymapping_test(expr):
@@ -912,46 +913,68 @@
         'FailingIterNext()',
     ))
 
+def number_test(expr, natural=False, unsigned=False):
+    if natural:
+        unsigned = True
+    return subexpr_test(expr, 'NumberToLong', (
+        '[]',
+        'None',
+    ) + (('-1',) if unsigned else ())
+    + (('0',) if natural else ()))
+
 class FailingTrue(object):
     def __bool__(self):
-        raise NotImplementedError
+        raise NotImplementedError('bool')
 
 class FailingIter(object):
     def __iter__(self):
-        raise NotImplementedError
+        raise NotImplementedError('iter')
 
 class FailingIterNext(object):
     def __iter__(self):
         return self
 
     def __next__(self):
-        raise NotImplementedError
+        raise NotImplementedError('next')
 
 class FailingMappingKey(object):
     def __getitem__(self, item):
-        raise NotImplementedError
+        raise NotImplementedError('getitem:mappingkey')
 
     def keys(self):
         return list("abcH")
 
 class FailingMapping(object):
     def __getitem__(self):
-        raise NotImplementedError
+        raise NotImplementedError('getitem:mapping')
 
     def keys(self):
-        raise NotImplementedError
+        raise NotImplementedError('keys')
 
 class FailingList(list):
     def __getitem__(self, idx):
         if i == 2:
-            raise NotImplementedError
+            raise NotImplementedError('getitem:list')
         else:
             return super(FailingList, self).__getitem__(idx)
 
+class NoArgsCall(object):
+    def __call__(self):
+        pass
+
+class FailingCall(object):
+    def __call__(self, path):
+        raise NotImplementedError('call')
+
+class FailingNumber(object):
+    def __int__(self):
+        raise NotImplementedError('int')
+
 cb.append("> Output")
 cb.append(">> OutputSetattr")
 ee('del sys.stdout.softspace')
-ee('sys.stdout.softspace = []')
+number_test('sys.stdout.softspace = %s', unsigned=True)
+number_test('sys.stderr.softspace = %s', unsigned=True)
 ee('sys.stdout.attr = None')
 cb.append(">> OutputWrite")
 ee('sys.stdout.write(None)')
@@ -960,18 +983,34 @@
 ee('sys.stdout.writelines([1])')
 iter_test('sys.stdout.writelines(%s)')
 cb.append("> VimCommand")
-ee('vim.command(1)')
+stringtochars_test('vim.command(%s)')
+ee('vim.command("", 2)')
 #! Not checked: vim->python exceptions translating: checked later
 cb.append("> VimToPython")
 #! Not checked: everything: needs errors in internal python functions
 cb.append("> VimEval")
-ee('vim.eval(1)')
+stringtochars_test('vim.eval(%s)')
+ee('vim.eval("", FailingTrue())')
 #! Not checked: everything: needs errors in internal python functions
 cb.append("> VimEvalPy")
-ee('vim.bindeval(1)')
+stringtochars_test('vim.bindeval(%s)')
+ee('vim.eval("", 2)')
 #! Not checked: vim->python exceptions translating: checked later
 cb.append("> VimStrwidth")
-ee('vim.strwidth(1)')
+stringtochars_test('vim.strwidth(%s)')
+cb.append("> VimForeachRTP")
+ee('vim.foreach_rtp(None)')
+ee('vim.foreach_rtp(NoArgsCall())')
+ee('vim.foreach_rtp(FailingCall())')
+ee('vim.foreach_rtp(int, 2)')
+cb.append('> import')
+old_rtp = vim.options['rtp']
+vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\')
+ee('import xxx_no_such_module_xxx')
+ee('import failing_import')
+ee('import failing')
+vim.options['rtp'] = old_rtp
+del old_rtp
 cb.append("> Dictionary")
 cb.append(">> DictionaryConstructor")
 ee('vim.Dictionary("abcI")')
@@ -1050,8 +1089,8 @@
 ee('vim.current.window.buffer = 0')
 ee('vim.current.window.cursor = (100000000, 100000000)')
 ee('vim.current.window.cursor = True')
-ee('vim.current.window.height = "abcK"')
-ee('vim.current.window.width  = "abcL"')
+number_test('vim.current.window.height = %s', unsigned=True)
+number_test('vim.current.window.width = %s', unsigned=True)
 ee('vim.current.window.xxxxxx = True')
 cb.append("> WinList")
 cb.append(">> WinListItem")
@@ -1059,6 +1098,7 @@
 cb.append("> Buffer")
 cb.append(">> StringToLine (indirect)")
 ee('vim.current.buffer[0] = "\\na"')
+ee('vim.current.buffer[0] = b"\\na"')
 cb.append(">> SetBufferLine (indirect)")
 ee('vim.current.buffer[0] = True')
 cb.append(">> SetBufferLineList (indirect)")
@@ -1085,8 +1125,8 @@
 ee('vim.current.buffer.range(1, 2, 3)')
 cb.append("> BufMap")
 cb.append(">> BufMapItem")
-ee('vim.buffers[None]')
 ee('vim.buffers[100000000]')
+number_test('vim.buffers[%s]', natural=True)
 cb.append("> Current")
 cb.append(">> CurrentGetattr")
 ee('vim.current.xxx')
@@ -1110,12 +1150,16 @@
 del convertfrompyobject_test
 del convertfrompymapping_test
 del iter_test
+del number_test
 del FailingTrue
 del FailingIter
 del FailingIterNext
 del FailingMapping
 del FailingMappingKey
 del FailingList
+del NoArgsCall
+del FailingCall
+del FailingNumber
 EOF
 :delfunction F
 :"
@@ -1124,6 +1168,16 @@
 sys.path.insert(0, os.path.join(os.getcwd(), 'python_before'))
 sys.path.append(os.path.join(os.getcwd(), 'python_after'))
 vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\')
+l = []
+def callback(path):
+    l.append(os.path.relpath(path))
+vim.foreach_rtp(callback)
+cb.append(repr(l))
+del l
+def callback(path):
+    return os.path.relpath(path)
+cb.append(repr(vim.foreach_rtp(callback)))
+del callback
 from module import dir as d
 from modulex import ddir
 cb.append(d + ',' + ddir)
@@ -1131,10 +1185,19 @@
 cb.append(before.dir)
 import after
 cb.append(after.dir)
+import topmodule as tm
+import topmodule.submodule as tms
+import topmodule.submodule.subsubmodule.subsubsubmodule as tmsss
+cb.append(tm.__file__[-len('modulex/topmodule/__init__.py'):])
+cb.append(tms.__file__[-len('modulex/topmodule/submodule/__init__.py'):])
+cb.append(tmsss.__file__[-len('modulex/topmodule/submodule/subsubmodule/subsubsubmodule.py'):])
 del before
 del after
 del d
 del ddir
+del tm
+del tms
+del tmsss
 EOF
 :"
 :" Test exceptions
@@ -1188,6 +1251,7 @@
 :call garbagecollect(1)
 :"
 :/^start:/,$wq! test.out
+:" vim: et ts=4 isk-=\:
 :call getchar()
 ENDTEST