private-attribute-cpp 1.4.2__tar.gz → 1.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: private_attribute_cpp
3
- Version: 1.4.2
3
+ Version: 1.4.3
4
4
  Summary: A Python package that provides a way to define private attributes in C++ implementation.
5
5
  Home-page: https://github.com/Locked-chess-official/private_attribute_cpp
6
6
  Author: HuangHaoHua
@@ -138,8 +138,6 @@ namespace {
138
138
  static std::unordered_map<uintptr_t, destructor> all_type_finalize;
139
139
 
140
140
  static std::shared_mutex all_register_new_metaclass_mutex;
141
- static std::vector<PyTypeObject*> all_register_new_metaclass;
142
- static std::unordered_set<uintptr_t> all_register_new_metaclass_id;
143
141
  static std::unordered_map<uintptr_t, PyObject*> all_register_type_weak_ref;
144
142
  };
145
143
  };
@@ -1754,6 +1752,18 @@ struct PrivateAttrCreationData
1754
1752
  if (cleared) {
1755
1753
  return;
1756
1754
  }
1755
+ if (name) {
1756
+ Py_DECREF(name);
1757
+ name = nullptr;
1758
+ }
1759
+ if (bases) {
1760
+ Py_DECREF(bases);
1761
+ bases = nullptr;
1762
+ }
1763
+ if (attrs) {
1764
+ Py_DECREF(attrs);
1765
+ attrs = nullptr;
1766
+ }
1757
1767
  if (attrs_copy) {
1758
1768
  Py_DECREF(attrs_copy);
1759
1769
  attrs_copy = nullptr;
@@ -1987,6 +1997,9 @@ PrivateAttrType_preprocess(PyObject* args, PyObject* kwds, PrivateAttrCreationDa
1987
1997
  if (!PyArg_ParseTuple(args, "OOO", &data.name, &data.bases, &data.attrs)) {
1988
1998
  return false;
1989
1999
  }
2000
+ Py_INCREF(data.name);
2001
+ Py_INCREF(data.bases);
2002
+ Py_INCREF(data.attrs);
1990
2003
 
1991
2004
  if (!PyUnicode_Check(data.name)) {
1992
2005
  PyErr_SetString(PyExc_TypeError, "name must be a string");
@@ -2315,6 +2328,10 @@ PrivateAttrType_postprocess(PyObject* new_type, PrivateAttrCreationData& data)
2315
2328
  if (!new_type) {
2316
2329
  return false;
2317
2330
  }
2331
+ if (!PyType_Check(new_type)) {
2332
+ PyErr_SetString(PyExc_TypeError, "created object is not a type");
2333
+ return false;
2334
+ }
2318
2335
 
2319
2336
  PyTypeObject* type_instance = (PyTypeObject*)new_type;
2320
2337
  uintptr_t type_id = (uintptr_t)(type_instance);
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: private_attribute_cpp
3
- Version: 1.4.2
3
+ Version: 1.4.3
4
4
  Summary: A Python package that provides a way to define private attributes in C++ implementation.
5
5
  Home-page: https://github.com/Locked-chess-official/private_attribute_cpp
6
6
  Author: HuangHaoHua
@@ -19,7 +19,7 @@ readme = open('README.md').read()
19
19
 
20
20
  setup(
21
21
  name='private_attribute_cpp',
22
- version='1.4.2',
22
+ version='1.4.3',
23
23
  author="HuangHaoHua",
24
24
  author_email="13140752715@example.com",
25
25
  description='A Python package that provides a way to define private attributes in C++ implementation.',