Without this patch vim crashes on added tests (`0 in vim.Dictionary()` and `""
in vim.Dictionary()`)
# HG changeset patch
# User ZyX <[email protected]>
# Date 1383332846 -14400
# Fri Nov 01 23:07:26 2013 +0400
# Branch python-dictionary-contains
# Node ID 5aed0175472a6f79ed2727441ffe524ec7282837
# Parent 92c9748e0ccbc42a5e28ce8fb9b8818e756a06da
Make DictionaryContains return -1 on error
diff -r 92c9748e0ccb -r 5aed0175472a src/if_py_both.h
--- a/src/if_py_both.h Sun Oct 06 17:46:56 2013 +0200
+++ b/src/if_py_both.h Fri Nov 01 23:07:26 2013 +0400
@@ -1624,6 +1624,9 @@
PyObject *rObj = _DictionaryItem(self, keyObject, DICT_FLAG_RETURN_BOOL);
int ret;
+ if (rObj == NULL)
+ return -1;
+
ret = (rObj == Py_True);
Py_DECREF(rObj);
# HG changeset patch
# User ZyX <[email protected]>
# Date 1383334079 -14400
# Fri Nov 01 23:27:59 2013 +0400
# Branch python-dictionary-contains
# Node ID b0d62098e1943986fccd6f1429594c7f717d07b2
# Parent 5aed0175472a6f79ed2727441ffe524ec7282837
Add tests
diff -r 5aed0175472a -r b0d62098e194 src/testdir/test86.in
--- a/src/testdir/test86.in Fri Nov 01 23:07:26 2013 +0400
+++ b/src/testdir/test86.in Fri Nov 01 23:27:59 2013 +0400
@@ -1088,6 +1088,9 @@
stringtochars_test('d.get(%s)')
ee('d.pop("a")')
ee('dl.pop("a")')
+cb.append(">> DictionaryContains")
+ee('"" in d')
+ee('0 in d')
cb.append(">> DictionaryIterNext")
ee('for i in ned: ned["a"] = 1')
del i
diff -r 5aed0175472a -r b0d62098e194 src/testdir/test86.ok
--- a/src/testdir/test86.ok Fri Nov 01 23:07:26 2013 +0400
+++ b/src/testdir/test86.ok Fri Nov 01 23:27:59 2013 +0400
@@ -516,6 +516,9 @@
<<< Finished
d.pop("a"):KeyError:('a',)
dl.pop("a"):error:('dictionary is locked',)
+>> DictionaryContains
+"" in d:ValueError:('empty keys are not allowed',)
+0 in d:TypeError:('expected str() or unicode() instance, but got int',)
>> DictionaryIterNext
for i in ned: ned["a"] = 1:RuntimeError:('hashtab changed during iteration',)
>> DictionaryAssItem
diff -r 5aed0175472a -r b0d62098e194 src/testdir/test87.in
--- a/src/testdir/test87.in Fri Nov 01 23:07:26 2013 +0400
+++ b/src/testdir/test87.in Fri Nov 01 23:27:59 2013 +0400
@@ -1039,6 +1039,9 @@
stringtochars_test('d.get(%s)')
ee('d.pop("a")')
ee('dl.pop("a")')
+cb.append(">> DictionaryContains")
+ee('"" in d')
+ee('0 in d')
cb.append(">> DictionaryIterNext")
ee('for i in ned: ned["a"] = 1')
del i
diff -r 5aed0175472a -r b0d62098e194 src/testdir/test87.ok
--- a/src/testdir/test87.ok Fri Nov 01 23:07:26 2013 +0400
+++ b/src/testdir/test87.ok Fri Nov 01 23:27:59 2013 +0400
@@ -505,6 +505,9 @@
<<< Finished
d.pop("a"):(<class 'KeyError'>, KeyError('a',))
dl.pop("a"):(<class 'vim.error'>, error('dictionary is locked',))
+>> DictionaryContains
+"" in d:(<class 'ValueError'>, ValueError('empty keys are not allowed',))
+0 in d:(<class 'TypeError'>, TypeError('expected bytes() or str() instance,
but got int',))
>> DictionaryIterNext
for i in ned: ned["a"] = 1:(<class 'RuntimeError'>, RuntimeError('hashtab
changed during iteration',))
>> DictionaryAssItem
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff -crN vim-small-patches.92c9748e0ccb/src/if_py_both.h vim-small-patches.b0d62098e194/src/if_py_both.h
*** vim-small-patches.92c9748e0ccb/src/if_py_both.h 2013-11-01 23:28:23.121082250 +0400
--- vim-small-patches.b0d62098e194/src/if_py_both.h 2013-11-01 23:28:23.130082191 +0400
***************
*** 1624,1629 ****
--- 1624,1632 ----
PyObject *rObj = _DictionaryItem(self, keyObject, DICT_FLAG_RETURN_BOOL);
int ret;
+ if (rObj == NULL)
+ return -1;
+
ret = (rObj == Py_True);
Py_DECREF(rObj);
diff -crN vim-small-patches.92c9748e0ccb/src/testdir/test86.in vim-small-patches.b0d62098e194/src/testdir/test86.in
*** vim-small-patches.92c9748e0ccb/src/testdir/test86.in 2013-11-01 23:28:23.122082243 +0400
--- vim-small-patches.b0d62098e194/src/testdir/test86.in 2013-11-01 23:28:23.131082185 +0400
***************
*** 1088,1093 ****
--- 1088,1096 ----
stringtochars_test('d.get(%s)')
ee('d.pop("a")')
ee('dl.pop("a")')
+ cb.append(">> DictionaryContains")
+ ee('"" in d')
+ ee('0 in d')
cb.append(">> DictionaryIterNext")
ee('for i in ned: ned["a"] = 1')
del i
diff -crN vim-small-patches.92c9748e0ccb/src/testdir/test86.ok vim-small-patches.b0d62098e194/src/testdir/test86.ok
*** vim-small-patches.92c9748e0ccb/src/testdir/test86.ok 2013-11-01 23:28:23.115082288 +0400
--- vim-small-patches.b0d62098e194/src/testdir/test86.ok 2013-11-01 23:28:23.124082230 +0400
***************
*** 516,521 ****
--- 516,524 ----
<<< Finished
d.pop("a"):KeyError:('a',)
dl.pop("a"):error:('dictionary is locked',)
+ >> DictionaryContains
+ "" in d:ValueError:('empty keys are not allowed',)
+ 0 in d:TypeError:('expected str() or unicode() instance, but got int',)
>> DictionaryIterNext
for i in ned: ned["a"] = 1:RuntimeError:('hashtab changed during iteration',)
>> DictionaryAssItem
diff -crN vim-small-patches.92c9748e0ccb/src/testdir/test87.in vim-small-patches.b0d62098e194/src/testdir/test87.in
*** vim-small-patches.92c9748e0ccb/src/testdir/test87.in 2013-11-01 23:28:23.117082276 +0400
--- vim-small-patches.b0d62098e194/src/testdir/test87.in 2013-11-01 23:28:23.126082219 +0400
***************
*** 1039,1044 ****
--- 1039,1047 ----
stringtochars_test('d.get(%s)')
ee('d.pop("a")')
ee('dl.pop("a")')
+ cb.append(">> DictionaryContains")
+ ee('"" in d')
+ ee('0 in d')
cb.append(">> DictionaryIterNext")
ee('for i in ned: ned["a"] = 1')
del i
diff -crN vim-small-patches.92c9748e0ccb/src/testdir/test87.ok vim-small-patches.b0d62098e194/src/testdir/test87.ok
*** vim-small-patches.92c9748e0ccb/src/testdir/test87.ok 2013-11-01 23:28:23.118082270 +0400
--- vim-small-patches.b0d62098e194/src/testdir/test87.ok 2013-11-01 23:28:23.127082213 +0400
***************
*** 505,510 ****
--- 505,513 ----
<<< Finished
d.pop("a"):(<class 'KeyError'>, KeyError('a',))
dl.pop("a"):(<class 'vim.error'>, error('dictionary is locked',))
+ >> DictionaryContains
+ "" in d:(<class 'ValueError'>, ValueError('empty keys are not allowed',))
+ 0 in d:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',))
>> DictionaryIterNext
for i in ned: ned["a"] = 1:(<class 'RuntimeError'>, RuntimeError('hashtab changed during iteration',))
>> DictionaryAssItem