boostorg / boostorg/python

Extends dict key error

Open
#245 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
537
Forks
223
Avg merge
11h 22m
Merged PRs (30d)
2

Description

I have written two snippets, with cpp and python

```c++
#include
#include
#include

using namespace boost::python;

struct testdict : public boost::python::dict {
testdict()
{
std::cout << "constructor" << std::endl;
}

virtual ~testdict()
{
std::cout << "destructor" << std::endl;
}
};

BOOST_PYTHON_MODULE(boost) {
class_>("testdict");
};
```

```python
#!/usr/bin/python3
# coding=utf-8

import boost

data = boost.testdict()

data['key'] = 1

print(data)
print('key' in data)
```

compile cpp code and run python code the output is not expected

```
constructor
{'key': 1}
False
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.