private-attribute-cpp 1.4.8__tar.gz → 1.4.9__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.
Files changed (22) hide show
  1. private_attribute_cpp-1.4.9/MANIFEST.in +2 -0
  2. {private_attribute_cpp-1.4.8/private_attribute_cpp.egg-info → private_attribute_cpp-1.4.9}/PKG-INFO +1 -1
  3. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/private_attribute.cpp +21 -12
  4. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9/private_attribute_cpp.egg-info}/PKG-INFO +1 -1
  5. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/setup.py +2 -2
  6. private_attribute_cpp-1.4.8/MANIFEST.in +0 -2
  7. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/LICENSE +0 -0
  8. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/README.md +0 -0
  9. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/picosha2.h +0 -0
  10. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/private_attribute.pyi +0 -0
  11. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/private_attribute_cpp.egg-info/SOURCES.txt +0 -0
  12. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/private_attribute_cpp.egg-info/dependency_links.txt +0 -0
  13. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/private_attribute_cpp.egg-info/not-zip-safe +0 -0
  14. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/private_attribute_cpp.egg-info/top_level.txt +0 -0
  15. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/setup.cfg +0 -0
  16. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/tests/test_class_private_attrs.py +0 -0
  17. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/tests/test_private_abc.py +0 -0
  18. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/tests/test_private_attrs.py +0 -0
  19. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/tests/test_private_func.py +0 -0
  20. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/tests/test_private_inheritance.py +0 -0
  21. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/tests/test_private_method.py +0 -0
  22. {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.9}/tests/test_private_wrap.py +0 -0
@@ -0,0 +1,2 @@
1
+ include README.md
2
+ include picosha2.h
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: private_attribute_cpp
3
- Version: 1.4.8
3
+ Version: 1.4.9
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
@@ -229,7 +229,7 @@ generate_private_attr_name(uintptr_t obj_id, const std::string& attr_name) noexc
229
229
 
230
230
  std::mt19937 rng(seed);
231
231
 
232
- static const std::string printable_chars =
232
+ static const std::string printable_chars =
233
233
  "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ";
234
234
 
235
235
  std::uniform_int_distribution<long long> dist(0, printable_chars.size() - 1);
@@ -296,7 +296,7 @@ public:
296
296
  : type(type), value(value), traceback(traceback) {
297
297
  }
298
298
 
299
- ~RestorePythonException() {
299
+ ~RestorePythonException() noexcept {
300
300
  Py_XDECREF(type);
301
301
  Py_XDECREF(value);
302
302
  Py_XDECREF(traceback);
@@ -498,7 +498,7 @@ id_getattr(const std::string& attr_name, PyObject* obj, PyObject* typ) noexcept
498
498
  if (::AllData::all_object_attr[final_id][obj_id].find(obj_private_name) != ::AllData::all_object_attr[final_id][obj_id].end()) {
499
499
  PyObject* python_obj = ::AllData::all_object_attr[final_id][obj_id][obj_private_name];
500
500
  if (!python_obj) {
501
- PyErr_SetString(PyExc_SystemError, "attribute is NULL");
501
+ PyErr_Format(PyExc_SystemError, "%s (%d): attribute is NULL", __FILE__, __LINE__);
502
502
  return NULL;
503
503
  }
504
504
  // if obj is a type, call result.__get__(None, obj)
@@ -948,7 +948,7 @@ PrivateWarp_name(PyObject* obj, void* /*closure*/) noexcept
948
948
  }
949
949
 
950
950
  static PyObject*
951
- PrivateWrap_qualname(PyObject* obj, void* /*closure*/)
951
+ PrivateWrap_qualname(PyObject* obj, void* /*closure*/) noexcept
952
952
  {
953
953
  if (!obj) {
954
954
  return PyUnicode_FromString("_PrivateWrap");
@@ -1097,7 +1097,7 @@ typedef struct {
1097
1097
  } PrivateWrapProxyObject;
1098
1098
 
1099
1099
  static PyObject*
1100
- PrivateWrapProxy_call(PrivateWrapProxyObject *self, PyObject *args, PyObject* /*kwgs */) noexcept
1100
+ PrivateWrapProxy_call(PrivateWrapProxyObject *self, PyObject *args, PyObject* /* kwgs */) noexcept
1101
1101
  {
1102
1102
  PyObject *func;
1103
1103
  if (!PyArg_ParseTuple(args, "O", &func)) return NULL;
@@ -1709,6 +1709,15 @@ analyse_all_code(PyObject* obj, std::unordered_map<uintptr_t, PyCodeObject*>& ma
1709
1709
  }
1710
1710
  PyObject* wrap = PyObject_GetAttrString(obj, "__wrapped__");
1711
1711
  if (wrap) {
1712
+ if (wrap == obj) {
1713
+ PyObject* code = PyObject_GetAttrString(obj, "__code__");
1714
+ if (code) {
1715
+ analyse_all_code(code, map, _seen);
1716
+ } else {
1717
+ PyErr_Clear();
1718
+ }
1719
+ return;
1720
+ }
1712
1721
  analyse_all_code(wrap, map, _seen);
1713
1722
  return;
1714
1723
  }
@@ -1724,7 +1733,7 @@ analyse_all_code(PyObject* obj, std::unordered_map<uintptr_t, PyCodeObject*>& ma
1724
1733
  }
1725
1734
 
1726
1735
  static std::string
1727
- real_class_name(const std::string& name, const std::string& class_name)
1736
+ real_class_name(const std::string& name, const std::string& class_name) noexcept
1728
1737
  {
1729
1738
  // if the name starts with "__" but does not end with "__", change to _ClassName__name
1730
1739
  if (name.length() >= 2 && name.substr(0, 2) == "__" && name.substr(name.length() - 2) != "__") {
@@ -1796,7 +1805,7 @@ struct PrivateAttrCreationData
1796
1805
  need_remove_subclass.clear();
1797
1806
  cleared = true;
1798
1807
  }
1799
-
1808
+
1800
1809
  ~PrivateAttrCreationData() noexcept {
1801
1810
  clear();
1802
1811
  }
@@ -1963,7 +1972,7 @@ python_original_tp_finalize(PyObject* self) noexcept
1963
1972
  get_del((PyTypeObject*)self->ob_type, &del);
1964
1973
  if (del) {
1965
1974
  PyObject *exc_type = NULL, *exc_value = NULL, *exc_tb = NULL;
1966
- PyErr_Fetch(&exc_type, &exc_value, &exc_tb);
1975
+ PyErr_Fetch(&exc_type, &exc_value, &exc_tb);
1967
1976
  PyObject *result = PyObject_CallFunctionObjArgs(del, self, NULL);
1968
1977
  if (result == NULL) {
1969
1978
  // python < 3.13 use PyErr_WriteUnraisable, python >= 3.13 use PyErr_FormatUnraisable
@@ -1991,7 +2000,7 @@ PrivateAttrType_preprocess(PyObject* args, PyObject* kwds, PrivateAttrCreationDa
1991
2000
  "__get__", "__set__", "__delete__", "__new__", "__set_name__", "__class__", NULL};
1992
2001
 
1993
2002
  if (!args) {
1994
- PyErr_SetString(PyExc_SystemError, "arg is NULL");
2003
+ PyErr_Format(PyExc_SystemError, "%s (%d): args is NULL", __FILE__, __LINE__);
1995
2004
  return false;
1996
2005
  }
1997
2006
 
@@ -2205,8 +2214,8 @@ PrivateAttrType_create(PyTypeObject* type, PrivateAttrCreationData& data) noexce
2205
2214
 
2206
2215
  if (!PyObject_IsInstance(new_type, (PyObject*)type)) {
2207
2216
  Py_DECREF(new_type);
2208
- PyErr_SetString(PyExc_TypeError,
2209
- ("base type creation did not return an instance of '" +
2217
+ PyErr_SetString(PyExc_TypeError,
2218
+ ("base type creation did not return an instance of '" +
2210
2219
  std::string(type->tp_name) + "'").c_str());
2211
2220
  return nullptr;
2212
2221
  }
@@ -2344,7 +2353,7 @@ PrivateAttrType_postprocess(PyObject* new_type, PrivateAttrCreationData& data) n
2344
2353
  uintptr_t type_id = (uintptr_t)(type_instance);
2345
2354
  if (PyDict_ContainsString(type_instance->tp_dict, "__static_attributes__")) {
2346
2355
  PyErr_Format(PyExc_SystemError,
2347
- "%s: %d: '__static_attributes__' will expose private attribute names and cannot be used in private attribute types", __FILE__, __LINE__);
2356
+ "%s (%d): '__static_attributes__' will expose private attribute names and cannot be used in private attribute types", __FILE__, __LINE__);
2348
2357
  return false;
2349
2358
  }
2350
2359
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: private_attribute_cpp
3
- Version: 1.4.8
3
+ Version: 1.4.9
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
@@ -18,7 +18,7 @@ readme = open('README.md').read()
18
18
 
19
19
  setup(
20
20
  name='private_attribute_cpp',
21
- version='1.4.8',
21
+ version='1.4.9',
22
22
  author="HuangHaoHua",
23
23
  author_email="13140752715@example.com",
24
24
  description='A Python package that provides a way to define private attributes in C++ implementation.',
@@ -34,4 +34,4 @@ setup(
34
34
  packages=[""],
35
35
 
36
36
  url="https://github.com/Locked-chess-official/private_attribute_cpp"
37
- )
37
+ )
@@ -1,2 +0,0 @@
1
- include README.md
2
- include picosha2.h