2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-23 05:42:30 +00:00

Fix dict bug

[SVN r16866]
This commit is contained in:
Dave Abrahams
2003-01-11 00:18:59 +00:00
parent 72b214b8db
commit e13a11eb7f
3 changed files with 4 additions and 2 deletions

View File

@@ -65,8 +65,8 @@ object dict_base::get(object_cref k) const
{
if (check_exact(this))
{
return object(detail::borrowed_reference(
PyDict_GetItem(this->ptr(),k.ptr())));
PyObject* result = PyDict_GetItem(this->ptr(),k.ptr());
return object(detail::borrowed_reference(result ? result : Py_None));
}
else
{

View File

@@ -61,6 +61,7 @@ void test_templates(object print)
//print(tmp[1]);
tmp[1.5] = 13;
print(tmp.get(1.5));
print(tmp.get(44));
print(tmp);
print(tmp.get(2,"default"));
print(tmp.has_key(key));

View File

@@ -20,6 +20,7 @@
>>> test_templates(printer)
a test string
13
None
{1.5: 13, 1: 'a test string'}
default
0