private-attribute-cpp 1.4.7__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.7/private_attribute_cpp.egg-info → private_attribute_cpp-1.4.9}/PKG-INFO +1 -1
  3. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/private_attribute.cpp +147 -135
  4. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9/private_attribute_cpp.egg-info}/PKG-INFO +1 -1
  5. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/setup.py +2 -2
  6. private_attribute_cpp-1.4.7/MANIFEST.in +0 -2
  7. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/LICENSE +0 -0
  8. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/README.md +0 -0
  9. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/picosha2.h +0 -0
  10. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/private_attribute.pyi +0 -0
  11. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/private_attribute_cpp.egg-info/SOURCES.txt +0 -0
  12. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/private_attribute_cpp.egg-info/dependency_links.txt +0 -0
  13. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/private_attribute_cpp.egg-info/not-zip-safe +0 -0
  14. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/private_attribute_cpp.egg-info/top_level.txt +0 -0
  15. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/setup.cfg +0 -0
  16. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/tests/test_class_private_attrs.py +0 -0
  17. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/tests/test_private_abc.py +0 -0
  18. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/tests/test_private_attrs.py +0 -0
  19. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/tests/test_private_func.py +0 -0
  20. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/tests/test_private_inheritance.py +0 -0
  21. {private_attribute_cpp-1.4.7 → private_attribute_cpp-1.4.9}/tests/test_private_method.py +0 -0
  22. {private_attribute_cpp-1.4.7 → 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.7
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
@@ -24,7 +24,7 @@
24
24
  // python under 3.13 doesn't have PyDict_ContainsString, so we implement it ourselves
25
25
  #if PY_VERSION_HEX < 0x030D0000
26
26
  static int
27
- PyDict_ContainsString(PyObject *op, const char *key)
27
+ PyDict_ContainsString(PyObject *op, const char *key) noexcept
28
28
  {
29
29
  PyObject *key_obj = PyUnicode_FromString(key);
30
30
  if (key_obj == NULL) {
@@ -39,7 +39,7 @@ PyDict_ContainsString(PyObject *op, const char *key)
39
39
  static const auto module_running_time = std::chrono::system_clock::now();
40
40
 
41
41
  static std::string
42
- time_to_string()
42
+ time_to_string() noexcept
43
43
  {
44
44
  std::time_t original_time = std::chrono::system_clock::to_time_t(module_running_time);
45
45
  std::tm original_tm = *std::localtime(&original_time);
@@ -50,6 +50,8 @@ time_to_string()
50
50
 
51
51
  static const auto module_running_time_string = time_to_string();
52
52
 
53
+ static const std::string compile_time = __DATE__ " " __TIME__;
54
+
53
55
  class AllPyobjectAttrCacheKey
54
56
  {
55
57
  private:
@@ -57,21 +59,21 @@ private:
57
59
  std::string attr_onehash;
58
60
  std::string another_string_hash;
59
61
  public:
60
- AllPyobjectAttrCacheKey(uintptr_t obj_id, const std::string& attr_name) : obj_id(obj_id) {
61
- std::string one_name = "_" + std::to_string(obj_id) + "_" + attr_name;
62
+ AllPyobjectAttrCacheKey(uintptr_t obj_id, const std::string& attr_name) noexcept : obj_id(obj_id) {
63
+ std::string one_name = "_" + std::to_string(obj_id) + "_" + compile_time + attr_name;
62
64
  std::string another_name = "_" + module_running_time_string + attr_name;
63
65
  picosha2::hash256_hex_string(one_name, attr_onehash);
64
66
  picosha2::hash256_hex_string(another_name, another_string_hash);
65
67
  }
66
68
 
67
- std::size_t gethash() const {
69
+ std::size_t gethash() const noexcept {
68
70
  std::size_t h1 = std::hash<uintptr_t>{}(obj_id);
69
71
  std::size_t h2 = std::hash<std::string>{}(attr_onehash);
70
72
  std::size_t h3 = std::hash<std::string>{}(another_string_hash);
71
73
  return h1 ^ (h2 << 1) ^ (h3 << 2);
72
74
  }
73
75
 
74
- bool operator==(const AllPyobjectAttrCacheKey& other) const {
76
+ bool operator==(const AllPyobjectAttrCacheKey& other) const noexcept {
75
77
  return this->obj_id == other.obj_id && this->attr_onehash == other.attr_onehash && this->another_string_hash == other.another_string_hash;
76
78
  }
77
79
  };
@@ -82,12 +84,12 @@ private:
82
84
  std::string first;
83
85
  std::string second;
84
86
  public:
85
- TwoStringTuple(const std::string& first, const std::string& second) : first(first), second(second) {}
86
- bool operator==(const TwoStringTuple& other) const {
87
+ TwoStringTuple(const std::string& first, const std::string& second) noexcept : first(first), second(second) {}
88
+ bool operator==(const TwoStringTuple& other) const noexcept {
87
89
  return this->first == other.first && this->second == other.second;
88
90
  }
89
91
 
90
- std::size_t gethash() const {
92
+ std::size_t gethash() const noexcept {
91
93
  std::size_t h1 = std::hash<std::string>{}(first);
92
94
  std::size_t h2 = std::hash<std::string>{}(second);
93
95
  return h1 ^ (h2 << 1);
@@ -97,14 +99,14 @@ public:
97
99
  namespace std {
98
100
  template<>
99
101
  struct hash<AllPyobjectAttrCacheKey> {
100
- std::size_t operator()(const AllPyobjectAttrCacheKey& key) const {
102
+ std::size_t operator()(const AllPyobjectAttrCacheKey& key) const noexcept {
101
103
  return key.gethash();
102
104
  }
103
105
  };
104
106
 
105
107
  template<>
106
108
  struct hash<TwoStringTuple> {
107
- std::size_t operator()(const TwoStringTuple& key) const {
109
+ std::size_t operator()(const TwoStringTuple& key) const noexcept {
108
110
  return key.gethash();
109
111
  }
110
112
  };
@@ -152,24 +154,24 @@ struct FinalObject
152
154
  {
153
155
  PyObject* result = NULL;
154
156
  int status = 0;
155
- FinalObject(PyObject* result)
157
+ FinalObject(PyObject* result) noexcept
156
158
  : result(result) {
157
159
  Py_XINCREF(result);
158
160
  }
159
- FinalObject(int status): status(status) {}
160
- ~FinalObject() {
161
+ FinalObject(int status) noexcept: status(status) {}
162
+ ~FinalObject() noexcept {
161
163
  Py_XDECREF(result);
162
164
  }
163
165
  };
164
166
 
165
- static TwoStringTuple get_string_hash_tuple2(const std::string& name);
166
- static PyCodeObject* get_now_code();
167
- static uintptr_t type_set_attr_long_long_guidance(uintptr_t type, const std::string& name);
168
- static bool type_private_attr(uintptr_t type, const std::string& name);
169
- static FinalObject type_get_final_attr(uintptr_t type_id, const std::string& name);
167
+ static TwoStringTuple get_string_hash_tuple2(const std::string& name) noexcept;
168
+ static PyCodeObject* get_now_code() noexcept;
169
+ static uintptr_t type_set_attr_long_long_guidance(uintptr_t type, const std::string& name) noexcept;
170
+ static bool type_private_attr(uintptr_t type, const std::string& name) noexcept;
171
+ static FinalObject type_get_final_attr(uintptr_t type_id, const std::string& name) noexcept;
170
172
 
171
173
  static bool
172
- is_class_code(uintptr_t typ_id, PyCodeObject* code)
174
+ is_class_code(uintptr_t typ_id, PyCodeObject* code) noexcept
173
175
  {
174
176
  if (::AllData::type_allowed_code_map.find(typ_id) != ::AllData::type_allowed_code_map.end()){
175
177
  auto& code_map = ::AllData::type_allowed_code_map[typ_id];
@@ -182,7 +184,7 @@ is_class_code(uintptr_t typ_id, PyCodeObject* code)
182
184
  }
183
185
 
184
186
  static bool
185
- is_type_private(uintptr_t typ_id, const std::string& name)
187
+ is_type_private(uintptr_t typ_id, const std::string& name) noexcept
186
188
  {
187
189
  if (::AllData::all_type_attr_set.find(typ_id) != ::AllData::all_type_attr_set.end()){
188
190
  auto& attr_set = ::AllData::all_type_attr_set[typ_id];
@@ -195,7 +197,7 @@ is_type_private(uintptr_t typ_id, const std::string& name)
195
197
  }
196
198
 
197
199
  static bool
198
- attr_classify(uintptr_t typ_id, const std::string& name, PyCodeObject* code)
200
+ attr_classify(uintptr_t typ_id, const std::string& name, PyCodeObject* code) noexcept
199
201
  {
200
202
  if (is_class_code(typ_id, code)) {
201
203
  return true;
@@ -218,16 +220,16 @@ attr_classify(uintptr_t typ_id, const std::string& name, PyCodeObject* code)
218
220
  }
219
221
 
220
222
  static std::string
221
- generate_private_attr_name(uintptr_t obj_id, const std::string& attr_name)
223
+ generate_private_attr_name(uintptr_t obj_id, const std::string& attr_name) noexcept
222
224
  {
223
- std::string combined = std::to_string(obj_id) + "_" + attr_name;
225
+ std::string combined = std::to_string(obj_id) + "_" + compile_time + "_" + attr_name;
224
226
  std::string hash_str = picosha2::hash256_hex_string(combined);
225
227
 
226
228
  unsigned long long seed = std::stoul(hash_str.substr(0, 8), nullptr, 16);
227
229
 
228
230
  std::mt19937 rng(seed);
229
231
 
230
- static const std::string printable_chars =
232
+ static const std::string printable_chars =
231
233
  "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ";
232
234
 
233
235
  std::uniform_int_distribution<long long> dist(0, printable_chars.size() - 1);
@@ -248,7 +250,7 @@ generate_private_attr_name(uintptr_t obj_id, const std::string& attr_name)
248
250
  }
249
251
 
250
252
  static std::string
251
- default_random_string(uintptr_t obj_id, const std::string& attr_name)
253
+ default_random_string(uintptr_t obj_id, const std::string& attr_name) noexcept
252
254
  {
253
255
  AllPyobjectAttrCacheKey key(obj_id, attr_name);
254
256
  std::string result;
@@ -290,11 +292,11 @@ default_random_string(uintptr_t obj_id, const std::string& attr_name)
290
292
  class RestorePythonException : public std::exception
291
293
  {
292
294
  public:
293
- RestorePythonException(PyObject* type, PyObject* value, PyObject* traceback)
295
+ RestorePythonException(PyObject* type, PyObject* value, PyObject* traceback) noexcept
294
296
  : type(type), value(value), traceback(traceback) {
295
297
  }
296
298
 
297
- ~RestorePythonException() {
299
+ ~RestorePythonException() noexcept {
298
300
  Py_XDECREF(type);
299
301
  Py_XDECREF(value);
300
302
  Py_XDECREF(traceback);
@@ -321,7 +323,7 @@ public:
321
323
  other.traceback = nullptr;
322
324
  }
323
325
 
324
- void restore() {
326
+ void restore() noexcept {
325
327
  PyErr_Restore(type, value, traceback);
326
328
  type = value = traceback = nullptr;
327
329
  }
@@ -394,7 +396,7 @@ custom_random_string(uintptr_t obj_id, const std::string& attr_name, PyObject* f
394
396
  }
395
397
 
396
398
  static void
397
- clear_obj(uintptr_t obj_id)
399
+ clear_obj(uintptr_t obj_id) noexcept
398
400
  {
399
401
  std::unique_lock<std::shared_mutex> lock(::AllData::cache_mutex);
400
402
  auto it = ::AllData::obj_attr_keys.find(obj_id);
@@ -409,7 +411,7 @@ clear_obj(uintptr_t obj_id)
409
411
  }
410
412
 
411
413
  static const char*
412
- get_name_from_tp_name(PyTypeObject* typ)
414
+ get_name_from_tp_name(PyTypeObject* typ) noexcept
413
415
  {
414
416
  const char* name = typ->tp_name;
415
417
  if (name == NULL) {
@@ -422,11 +424,11 @@ get_name_from_tp_name(PyTypeObject* typ)
422
424
  return final_name;
423
425
  }
424
426
 
425
- static void ensure_tp(PyTypeObject* type_instance);
426
- static void ensure_subclass_tp(PyTypeObject* type_instance);
427
+ static void ensure_tp(PyTypeObject* type_instance) noexcept;
428
+ static void ensure_subclass_tp(PyTypeObject* type_instance) noexcept;
427
429
 
428
430
  static PyObject*
429
- id_getattr(const std::string& attr_name, PyObject* obj, PyObject* typ)
431
+ id_getattr(const std::string& attr_name, PyObject* obj, PyObject* typ) noexcept
430
432
  {
431
433
  uintptr_t obj_id, typ_id, final_id;
432
434
  obj_id = (uintptr_t) obj;
@@ -496,7 +498,7 @@ id_getattr(const std::string& attr_name, PyObject* obj, PyObject* typ)
496
498
  if (::AllData::all_object_attr[final_id][obj_id].find(obj_private_name) != ::AllData::all_object_attr[final_id][obj_id].end()) {
497
499
  PyObject* python_obj = ::AllData::all_object_attr[final_id][obj_id][obj_private_name];
498
500
  if (!python_obj) {
499
- PyErr_SetString(PyExc_SystemError, "attribute is NULL");
501
+ PyErr_Format(PyExc_SystemError, "%s (%d): attribute is NULL", __FILE__, __LINE__);
500
502
  return NULL;
501
503
  }
502
504
  // if obj is a type, call result.__get__(None, obj)
@@ -533,7 +535,7 @@ id_getattr(const std::string& attr_name, PyObject* obj, PyObject* typ)
533
535
  }
534
536
 
535
537
  static PyObject*
536
- type_getattr(PyObject* typ, const std::string& attr_name)
538
+ type_getattr(PyObject* typ, const std::string& attr_name) noexcept
537
539
  {
538
540
  uintptr_t typ_id = (uintptr_t)typ;
539
541
  FinalObject final_object = type_get_final_attr(typ_id, attr_name);
@@ -567,7 +569,7 @@ type_getattr(PyObject* typ, const std::string& attr_name)
567
569
  }
568
570
 
569
571
  static int
570
- id_setattr(const std::string& attr_name, PyObject* obj, PyObject* typ, PyObject* value)
572
+ id_setattr(const std::string& attr_name, PyObject* obj, PyObject* typ, PyObject* value) noexcept
571
573
  {
572
574
  uintptr_t obj_id, typ_id, final_id;
573
575
  obj_id = (uintptr_t) obj;
@@ -636,10 +638,10 @@ id_setattr(const std::string& attr_name, PyObject* obj, PyObject* typ, PyObject*
636
638
  return 0;
637
639
  }
638
640
 
639
- static int type_delattr(PyObject* typ, const std::string& attr_name);
641
+ static int type_delattr(PyObject* typ, const std::string& attr_name) noexcept;
640
642
 
641
643
  static int
642
- type_setattr(PyObject* typ, const std::string& attr_name, PyObject* value)
644
+ type_setattr(PyObject* typ, const std::string& attr_name, PyObject* value) noexcept
643
645
  {
644
646
  if (!value) {
645
647
  return type_delattr(typ, attr_name);
@@ -711,7 +713,7 @@ type_setattr(PyObject* typ, const std::string& attr_name, PyObject* value)
711
713
  }
712
714
 
713
715
  static int
714
- id_delattr(const std::string& attr_name, PyObject* obj, PyObject* typ)
716
+ id_delattr(const std::string& attr_name, PyObject* obj, PyObject* typ) noexcept
715
717
  {
716
718
  uintptr_t obj_id, typ_id, final_id;
717
719
  obj_id = (uintptr_t) obj;
@@ -789,7 +791,7 @@ id_delattr(const std::string& attr_name, PyObject* obj, PyObject* typ)
789
791
  }
790
792
 
791
793
  static int
792
- type_delattr(PyObject* typ, const std::string& attr_name)
794
+ type_delattr(PyObject* typ, const std::string& attr_name) noexcept
793
795
  {
794
796
  uintptr_t typ_id = (uintptr_t) typ;
795
797
  uintptr_t final_id = type_set_attr_long_long_guidance(typ_id, attr_name);
@@ -877,12 +879,12 @@ typedef struct {
877
879
  PyObject *func_list;
878
880
  } PrivateWrapObject;
879
881
 
880
- static PrivateWrapObject* PrivateWrap_New(PyObject *decorator, PyObject *func, PyObject *list);
881
- static void PrivateWrap_dealloc(PrivateWrapObject *self);
882
- static PyObject* PrivateWrap_call(PrivateWrapObject *self, PyObject *args, PyObject *kw);
882
+ static PrivateWrapObject* PrivateWrap_New(PyObject *decorator, PyObject *func, PyObject *list) noexcept;
883
+ static void PrivateWrap_dealloc(PrivateWrapObject *self) noexcept;
884
+ static PyObject* PrivateWrap_call(PrivateWrapObject *self, PyObject *args, PyObject *kw) noexcept;
883
885
 
884
886
  static PyObject *
885
- PrivateWrap_result(PyObject *obj, void* /*closure*/)
887
+ PrivateWrap_result(PyObject *obj, void* /*closure*/) noexcept
886
888
  {
887
889
  if (!obj) {
888
890
  Py_RETURN_NONE;
@@ -894,7 +896,7 @@ PrivateWrap_result(PyObject *obj, void* /*closure*/)
894
896
  }
895
897
 
896
898
  static PyObject *
897
- PrivateWrap_funcs(PyObject *obj, void* /*closure*/)
899
+ PrivateWrap_funcs(PyObject *obj, void* /*closure*/) noexcept
898
900
  {
899
901
  if (!obj) {
900
902
  Py_RETURN_NONE;
@@ -904,7 +906,7 @@ PrivateWrap_funcs(PyObject *obj, void* /*closure*/)
904
906
  }
905
907
 
906
908
  static PyObject*
907
- PrivateWrap_doc(PyObject *obj, void* /*closure*/)
909
+ PrivateWrap_doc(PyObject *obj, void* /*closure*/) noexcept
908
910
  {
909
911
  if (!obj) {
910
912
  return PyUnicode_FromString("PrivateWrap");
@@ -918,7 +920,7 @@ PrivateWrap_doc(PyObject *obj, void* /*closure*/)
918
920
  }
919
921
 
920
922
  static PyObject*
921
- PrivateWrap_module(PyObject *obj, void* /*closure*/)
923
+ PrivateWrap_module(PyObject *obj, void* /*closure*/) noexcept
922
924
  {
923
925
  if (!obj) {
924
926
  return PyUnicode_FromString("private_attribute");
@@ -932,7 +934,7 @@ PrivateWrap_module(PyObject *obj, void* /*closure*/)
932
934
  }
933
935
 
934
936
  static PyObject*
935
- PrivateWarp_name(PyObject* obj, void* /*closure*/)
937
+ PrivateWarp_name(PyObject* obj, void* /*closure*/) noexcept
936
938
  {
937
939
  if (!obj) {
938
940
  return PyUnicode_FromString("_PrivateWrap");
@@ -946,7 +948,7 @@ PrivateWarp_name(PyObject* obj, void* /*closure*/)
946
948
  }
947
949
 
948
950
  static PyObject*
949
- PrivateWrap_qualname(PyObject* obj, void* /*closure*/)
951
+ PrivateWrap_qualname(PyObject* obj, void* /*closure*/) noexcept
950
952
  {
951
953
  if (!obj) {
952
954
  return PyUnicode_FromString("_PrivateWrap");
@@ -961,7 +963,7 @@ PrivateWrap_qualname(PyObject* obj, void* /*closure*/)
961
963
 
962
964
  // __annotate__
963
965
  static PyObject*
964
- PrivateWrap_annotate(PyObject* obj, void* /*closure*/)
966
+ PrivateWrap_annotate(PyObject* obj, void* /*closure*/) noexcept
965
967
  {
966
968
  if (!obj) {
967
969
  Py_RETURN_NONE;
@@ -976,7 +978,7 @@ PrivateWrap_annotate(PyObject* obj, void* /*closure*/)
976
978
 
977
979
  // __type_params__
978
980
  static PyObject*
979
- PrivateWrap_type_params(PyObject* obj, void* /*closure*/)
981
+ PrivateWrap_type_params(PyObject* obj, void* /*closure*/) noexcept
980
982
  {
981
983
  if (!obj) {
982
984
  Py_RETURN_NONE;
@@ -1006,7 +1008,7 @@ static PyGetSetDef PrivateWrap_getset[] = {
1006
1008
  };
1007
1009
 
1008
1010
  static PyObject *
1009
- PrivateWrap_getattro(PyObject *obj, PyObject *name)
1011
+ PrivateWrap_getattro(PyObject *obj, PyObject *name) noexcept
1010
1012
  {
1011
1013
  PyObject *res = PyObject_GenericGetAttr(obj, name);
1012
1014
  if (res != NULL) {
@@ -1053,7 +1055,7 @@ static PyTypeObject PrivateWrapType = {
1053
1055
  };
1054
1056
 
1055
1057
  static PrivateWrapObject*
1056
- PrivateWrap_New(PyObject *decorator, PyObject *func, PyObject *list)
1058
+ PrivateWrap_New(PyObject *decorator, PyObject *func, PyObject *list) noexcept
1057
1059
  {
1058
1060
  PrivateWrapObject *self =
1059
1061
  PyObject_New(PrivateWrapObject, &PrivateWrapType);
@@ -1072,7 +1074,7 @@ PrivateWrap_New(PyObject *decorator, PyObject *func, PyObject *list)
1072
1074
  }
1073
1075
 
1074
1076
  static void
1075
- PrivateWrap_dealloc(PrivateWrapObject *self)
1077
+ PrivateWrap_dealloc(PrivateWrapObject *self) noexcept
1076
1078
  {
1077
1079
  Py_XDECREF(self->result);
1078
1080
  Py_XDECREF(self->func_list);
@@ -1080,7 +1082,7 @@ PrivateWrap_dealloc(PrivateWrapObject *self)
1080
1082
  }
1081
1083
 
1082
1084
  static PyObject*
1083
- PrivateWrap_call(PrivateWrapObject *self, PyObject *args, PyObject *kw)
1085
+ PrivateWrap_call(PrivateWrapObject *self, PyObject *args, PyObject *kw) noexcept
1084
1086
  {
1085
1087
  return PyObject_Call(self->result, args, kw);
1086
1088
  }
@@ -1095,7 +1097,7 @@ typedef struct {
1095
1097
  } PrivateWrapProxyObject;
1096
1098
 
1097
1099
  static PyObject*
1098
- PrivateWrapProxy_call(PrivateWrapProxyObject *self, PyObject *args, PyObject* /*kwgs */)
1100
+ PrivateWrapProxy_call(PrivateWrapProxyObject *self, PyObject *args, PyObject* /* kwgs */) noexcept
1099
1101
  {
1100
1102
  PyObject *func;
1101
1103
  if (!PyArg_ParseTuple(args, "O", &func)) return NULL;
@@ -1121,8 +1123,8 @@ PrivateWrapProxy_call(PrivateWrapProxyObject *self, PyObject *args, PyObject* /*
1121
1123
  );
1122
1124
  }
1123
1125
 
1124
- static void PrivateWrapProxy_dealloc(PrivateWrapProxyObject *self);
1125
- static PyObject* PrivateWrapProxy_New(PyTypeObject *type, PyObject *args, PyObject *kwds);
1126
+ static void PrivateWrapProxy_dealloc(PrivateWrapProxyObject *self) noexcept;
1127
+ static PyObject* PrivateWrapProxy_New(PyTypeObject *type, PyObject *args, PyObject *kwds) noexcept;
1126
1128
  static const char* PrivateWrapProxy_doc = R"(
1127
1129
  PrivateWrapProxy is a proxy for private attributes.
1128
1130
  Usage:
@@ -1195,7 +1197,7 @@ static PyTypeObject PrivateWrapProxyType = {
1195
1197
  };
1196
1198
 
1197
1199
  static PyObject*
1198
- PrivateWrapProxy_New(PyTypeObject *type, PyObject *args, PyObject* /*kwds*/)
1200
+ PrivateWrapProxy_New(PyTypeObject *type, PyObject *args, PyObject* /*kwds*/) noexcept
1199
1201
  {
1200
1202
  PrivateWrapProxyObject *self;
1201
1203
  PyObject *decorator;
@@ -1227,7 +1229,7 @@ PrivateWrapProxy_New(PyTypeObject *type, PyObject *args, PyObject* /*kwds*/)
1227
1229
  }
1228
1230
 
1229
1231
  static void
1230
- PrivateWrapProxy_dealloc(PrivateWrapProxyObject *self)
1232
+ PrivateWrapProxy_dealloc(PrivateWrapProxyObject *self) noexcept
1231
1233
  {
1232
1234
  Py_XDECREF(self->decorator);
1233
1235
  Py_XDECREF(self->func_list);
@@ -1241,12 +1243,12 @@ typedef struct {
1241
1243
  PyHeapTypeObject base; // PyObject_HEAD_INIT(NULL)
1242
1244
  } PrivateAttrTypeObject;
1243
1245
 
1244
- static void PrivateAttr_object_init_private_dict(uintptr_t obj_id, uintptr_t type_id);
1245
- static int PrivateAttr_tp_setattro(PyObject* self, PyObject* name, PyObject* value);
1246
- static void PrivateAttr_tp_finalize(PyObject* self);
1246
+ static void PrivateAttr_object_init_private_dict(uintptr_t obj_id, uintptr_t type_id) noexcept;
1247
+ static int PrivateAttr_tp_setattro(PyObject* self, PyObject* name, PyObject* value) noexcept;
1248
+ static void PrivateAttr_tp_finalize(PyObject* self) noexcept;
1247
1249
 
1248
1250
  static PyObject*
1249
- PrivateAttr_tp_getattro(PyObject* self, PyObject* name)
1251
+ PrivateAttr_tp_getattro(PyObject* self, PyObject* name) noexcept
1250
1252
  {
1251
1253
  PyTypeObject* typ = Py_TYPE(self);
1252
1254
  uintptr_t type_id = (uintptr_t)typ;
@@ -1275,7 +1277,7 @@ PrivateAttr_tp_getattro(PyObject* self, PyObject* name)
1275
1277
  }
1276
1278
 
1277
1279
  static int
1278
- PrivateAttr_tp_setattro(PyObject* self, PyObject* name, PyObject* value)
1280
+ PrivateAttr_tp_setattro(PyObject* self, PyObject* name, PyObject* value) noexcept
1279
1281
  {
1280
1282
  PyTypeObject* typ = Py_TYPE(self);
1281
1283
  uintptr_t typ_id = (uintptr_t)typ;
@@ -1308,7 +1310,7 @@ PrivateAttr_tp_setattro(PyObject* self, PyObject* name, PyObject* value)
1308
1310
  }
1309
1311
 
1310
1312
  static void
1311
- PrivateAttr_tp_finalize(PyObject* self)
1313
+ PrivateAttr_tp_finalize(PyObject* self) noexcept
1312
1314
  {
1313
1315
  uintptr_t id_self = (uintptr_t)self;
1314
1316
  PyTypeObject* typ = Py_TYPE(self);
@@ -1370,7 +1372,7 @@ PrivateAttr_tp_finalize(PyObject* self)
1370
1372
  }
1371
1373
 
1372
1374
  static void
1373
- PrivateAttr_object_init_private_dict(uintptr_t obj_id, uintptr_t type_id)
1375
+ PrivateAttr_object_init_private_dict(uintptr_t obj_id, uintptr_t type_id) noexcept
1374
1376
  {
1375
1377
  if (::AllData::all_object_mutex.find(type_id) == ::AllData::all_object_mutex.end()) {
1376
1378
  ::AllData::all_object_mutex[type_id] = {};
@@ -1391,10 +1393,10 @@ PrivateAttr_object_init_private_dict(uintptr_t obj_id, uintptr_t type_id)
1391
1393
  }
1392
1394
  }
1393
1395
 
1394
- static PyObject* PrivateAttrType_new(PyTypeObject* type, PyObject* args, PyObject* kwds);
1395
- static PyObject* PrivateAttrType_getattr(PyObject* cls, PyObject* name);
1396
- static int PrivateAttrType_setattr(PyObject* cls, PyObject* name, PyObject* value);
1397
- static void PrivateAttrType_del(PyObject* cls);
1396
+ static PyObject* PrivateAttrType_new(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept;
1397
+ static PyObject* PrivateAttrType_getattr(PyObject* cls, PyObject* name) noexcept;
1398
+ static int PrivateAttrType_setattr(PyObject* cls, PyObject* name, PyObject* value) noexcept;
1399
+ static void PrivateAttrType_del(PyObject* cls) noexcept;
1398
1400
 
1399
1401
  static PyTypeObject PrivateAttrType = {
1400
1402
  PyVarObject_HEAD_INIT(NULL, 0)
@@ -1438,13 +1440,13 @@ static PyTypeObject PrivateAttrType = {
1438
1440
  };
1439
1441
 
1440
1442
  static PyObject*
1441
- get_string_hash_tuple(const std::string& name)
1443
+ get_string_hash_tuple(const std::string& name) noexcept
1442
1444
  {
1443
1445
  std::string name1;
1444
1446
  std::string name2;
1445
1447
  name1 = module_running_time_string + "_" + name;
1446
1448
  uintptr_t type_id = reinterpret_cast<uintptr_t>(&PrivateAttrType);
1447
- name2 = std::to_string(type_id) + "_" + name1;
1449
+ name2 = std::to_string(type_id) + "_" + compile_time + "_" + name1;
1448
1450
  std::string name1hash, name2hash;
1449
1451
  picosha2::hash256_hex_string(name1, name1hash);
1450
1452
  picosha2::hash256_hex_string(name2, name2hash);
@@ -1452,13 +1454,13 @@ get_string_hash_tuple(const std::string& name)
1452
1454
  }
1453
1455
 
1454
1456
  static TwoStringTuple
1455
- get_string_hash_tuple2(const std::string& name)
1457
+ get_string_hash_tuple2(const std::string& name) noexcept
1456
1458
  {
1457
1459
  std::string name1;
1458
1460
  std::string name2;
1459
1461
  name1 = module_running_time_string + "_" + name;
1460
1462
  uintptr_t type_id = reinterpret_cast<uintptr_t>(&PrivateAttrType);
1461
- name2 = std::to_string(type_id) + "_" + name1;
1463
+ name2 = std::to_string(type_id) + "_" + compile_time + "_" + name1;
1462
1464
  std::string name1hash, name2hash;
1463
1465
  picosha2::hash256_hex_string(name1, name1hash);
1464
1466
  picosha2::hash256_hex_string(name2, name2hash);
@@ -1466,7 +1468,7 @@ get_string_hash_tuple2(const std::string& name)
1466
1468
  }
1467
1469
 
1468
1470
  static FinalObject
1469
- type_get_final_attr(uintptr_t type_id, const std::string& name)
1471
+ type_get_final_attr(uintptr_t type_id, const std::string& name) noexcept
1470
1472
  {
1471
1473
  TwoStringTuple hash_tuple = get_string_hash_tuple2(name);
1472
1474
  if (::AllData::all_type_attr_set.find(type_id) != ::AllData::all_type_attr_set.end()) {
@@ -1580,7 +1582,7 @@ type_get_final_attr(uintptr_t type_id, const std::string& name)
1580
1582
  }
1581
1583
 
1582
1584
  static uintptr_t
1583
- type_set_attr_long_long_guidance(uintptr_t type_id, const std::string& name)
1585
+ type_set_attr_long_long_guidance(uintptr_t type_id, const std::string& name) noexcept
1584
1586
  {
1585
1587
  TwoStringTuple hash_tuple = get_string_hash_tuple2(name);
1586
1588
  if (::AllData::all_type_attr_set.find(type_id) != ::AllData::all_type_attr_set.end()) {
@@ -1602,7 +1604,7 @@ type_set_attr_long_long_guidance(uintptr_t type_id, const std::string& name)
1602
1604
  }
1603
1605
 
1604
1606
  static bool
1605
- type_private_attr(uintptr_t type_id, const std::string& name)
1607
+ type_private_attr(uintptr_t type_id, const std::string& name) noexcept
1606
1608
  {
1607
1609
  TwoStringTuple hash_tuple = get_string_hash_tuple2(name);
1608
1610
  if (::AllData::all_type_attr_set.find(type_id) != ::AllData::all_type_attr_set.end()) {
@@ -1624,7 +1626,7 @@ type_private_attr(uintptr_t type_id, const std::string& name)
1624
1626
  }
1625
1627
 
1626
1628
  static PyCodeObject*
1627
- get_now_code()
1629
+ get_now_code() noexcept
1628
1630
  {
1629
1631
  PyFrameObject* f = PyEval_GetFrame();
1630
1632
  if (!f) {
@@ -1635,7 +1637,7 @@ get_now_code()
1635
1637
  }
1636
1638
 
1637
1639
  static void
1638
- analyse_all_code(PyObject* obj, std::unordered_map<uintptr_t, PyCodeObject*>& map, std::unordered_set<uintptr_t>& _seen)
1640
+ analyse_all_code(PyObject* obj, std::unordered_map<uintptr_t, PyCodeObject*>& map, std::unordered_set<uintptr_t>& _seen) noexcept
1639
1641
  {
1640
1642
  uintptr_t obj_id = (uintptr_t)obj;
1641
1643
  if (_seen.find(obj_id) != _seen.end()) {
@@ -1707,6 +1709,15 @@ analyse_all_code(PyObject* obj, std::unordered_map<uintptr_t, PyCodeObject*>& ma
1707
1709
  }
1708
1710
  PyObject* wrap = PyObject_GetAttrString(obj, "__wrapped__");
1709
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
+ }
1710
1721
  analyse_all_code(wrap, map, _seen);
1711
1722
  return;
1712
1723
  }
@@ -1722,7 +1733,7 @@ analyse_all_code(PyObject* obj, std::unordered_map<uintptr_t, PyCodeObject*>& ma
1722
1733
  }
1723
1734
 
1724
1735
  static std::string
1725
- 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
1726
1737
  {
1727
1738
  // if the name starts with "__" but does not end with "__", change to _ClassName__name
1728
1739
  if (name.length() >= 2 && name.substr(0, 2) == "__" && name.substr(name.length() - 2) != "__") {
@@ -1748,7 +1759,7 @@ struct PrivateAttrCreationData
1748
1759
  PyObject* attrs = nullptr;
1749
1760
  bool cleared = false;
1750
1761
 
1751
- void clear() {
1762
+ void clear() noexcept {
1752
1763
  if (cleared) {
1753
1764
  return;
1754
1765
  }
@@ -1794,14 +1805,14 @@ struct PrivateAttrCreationData
1794
1805
  need_remove_subclass.clear();
1795
1806
  cleared = true;
1796
1807
  }
1797
-
1798
- ~PrivateAttrCreationData() {
1808
+
1809
+ ~PrivateAttrCreationData() noexcept {
1799
1810
  clear();
1800
1811
  }
1801
1812
  };
1802
1813
 
1803
1814
  static bool
1804
- need_analyse_type(PyObject* type)
1815
+ need_analyse_type(PyObject* type) noexcept
1805
1816
  {
1806
1817
  if (PyObject_IsInstance(type, (PyObject*)&PrivateAttrType)) {
1807
1818
  return true;
@@ -1831,7 +1842,7 @@ need_analyse_type(PyObject* type)
1831
1842
  }
1832
1843
 
1833
1844
  static void
1834
- get_getattribute_and_getattr(PyTypeObject* cls, PyObject** getattribute, PyObject** getattr)
1845
+ get_getattribute_and_getattr(PyTypeObject* cls, PyObject** getattribute, PyObject** getattr) noexcept
1835
1846
  {
1836
1847
  bool has_getattribute = false;
1837
1848
  bool has_getattr = false;
@@ -1862,7 +1873,7 @@ get_getattribute_and_getattr(PyTypeObject* cls, PyObject** getattribute, PyObjec
1862
1873
  }
1863
1874
 
1864
1875
  static void
1865
- get_setattr_and_delattr(PyTypeObject* cls, PyObject** setattr, PyObject** delattr)
1876
+ get_setattr_and_delattr(PyTypeObject* cls, PyObject** setattr, PyObject** delattr) noexcept
1866
1877
  {
1867
1878
  bool has_setattr = false;
1868
1879
  bool has_delattr = false;
@@ -1893,7 +1904,7 @@ get_setattr_and_delattr(PyTypeObject* cls, PyObject** setattr, PyObject** delatt
1893
1904
  }
1894
1905
 
1895
1906
  static void
1896
- get_del(PyTypeObject* cls, PyObject** del)
1907
+ get_del(PyTypeObject* cls, PyObject** del) noexcept
1897
1908
  {
1898
1909
  if (PyDict_ContainsString(cls->tp_dict, "__del__")) {
1899
1910
  *del = PyDict_GetItemString(cls->tp_dict, "__del__");
@@ -1908,7 +1919,7 @@ get_del(PyTypeObject* cls, PyObject** del)
1908
1919
  }
1909
1920
 
1910
1921
  static PyObject*
1911
- python_original_tp_getattro(PyObject* self, PyObject* name)
1922
+ python_original_tp_getattro(PyObject* self, PyObject* name) noexcept
1912
1923
  {
1913
1924
  PyObject* getattriute = NULL;
1914
1925
  PyObject* getattr = NULL;
@@ -1931,7 +1942,7 @@ python_original_tp_getattro(PyObject* self, PyObject* name)
1931
1942
  }
1932
1943
 
1933
1944
  static int
1934
- python_original_tp_setattro(PyObject* self, PyObject* name, PyObject* value)
1945
+ python_original_tp_setattro(PyObject* self, PyObject* name, PyObject* value) noexcept
1935
1946
  {
1936
1947
  PyObject* setattr = NULL;
1937
1948
  PyObject* delattr = NULL;
@@ -1955,13 +1966,13 @@ python_original_tp_setattro(PyObject* self, PyObject* name, PyObject* value)
1955
1966
  }
1956
1967
 
1957
1968
  static void
1958
- python_original_tp_finalize(PyObject* self)
1969
+ python_original_tp_finalize(PyObject* self) noexcept
1959
1970
  {
1960
1971
  PyObject* del = NULL;
1961
1972
  get_del((PyTypeObject*)self->ob_type, &del);
1962
1973
  if (del) {
1963
1974
  PyObject *exc_type = NULL, *exc_value = NULL, *exc_tb = NULL;
1964
- PyErr_Fetch(&exc_type, &exc_value, &exc_tb);
1975
+ PyErr_Fetch(&exc_type, &exc_value, &exc_tb);
1965
1976
  PyObject *result = PyObject_CallFunctionObjArgs(del, self, NULL);
1966
1977
  if (result == NULL) {
1967
1978
  // python < 3.13 use PyErr_WriteUnraisable, python >= 3.13 use PyErr_FormatUnraisable
@@ -1982,14 +1993,14 @@ python_original_tp_finalize(PyObject* self)
1982
1993
  }
1983
1994
 
1984
1995
  static bool
1985
- PrivateAttrType_preprocess(PyObject* args, PyObject* kwds, PrivateAttrCreationData& data)
1996
+ PrivateAttrType_preprocess(PyObject* args, PyObject* kwds, PrivateAttrCreationData& data) noexcept
1986
1997
  {
1987
1998
  static const char* invalid_name[] = {"__private_attrs__", "__slots__", "__getattribute__", "__getattr__", "__init__",
1988
1999
  "__setattr__", "__delattr__", "__name__", "__module__", "__doc__", "__getstate__", "__setstate__",
1989
2000
  "__get__", "__set__", "__delete__", "__new__", "__set_name__", "__class__", NULL};
1990
2001
 
1991
2002
  if (!args) {
1992
- PyErr_SetString(PyExc_SystemError, "arg is NULL");
2003
+ PyErr_Format(PyExc_SystemError, "%s (%d): args is NULL", __FILE__, __LINE__);
1993
2004
  return false;
1994
2005
  }
1995
2006
 
@@ -2187,7 +2198,7 @@ PrivateAttrType_preprocess(PyObject* args, PyObject* kwds, PrivateAttrCreationDa
2187
2198
  }
2188
2199
 
2189
2200
  static PyObject*
2190
- PrivateAttrType_create(PyTypeObject* type, PrivateAttrCreationData& data)
2201
+ PrivateAttrType_create(PyTypeObject* type, PrivateAttrCreationData& data) noexcept
2191
2202
  {
2192
2203
  PyObject* type_args = PyTuple_Pack(3, data.name, data.bases, data.attrs_copy);
2193
2204
  if (!type_args) {
@@ -2203,8 +2214,8 @@ PrivateAttrType_create(PyTypeObject* type, PrivateAttrCreationData& data)
2203
2214
 
2204
2215
  if (!PyObject_IsInstance(new_type, (PyObject*)type)) {
2205
2216
  Py_DECREF(new_type);
2206
- PyErr_SetString(PyExc_TypeError,
2207
- ("base type creation did not return an instance of '" +
2217
+ PyErr_SetString(PyExc_TypeError,
2218
+ ("base type creation did not return an instance of '" +
2208
2219
  std::string(type->tp_name) + "'").c_str());
2209
2220
  return nullptr;
2210
2221
  }
@@ -2212,12 +2223,12 @@ PrivateAttrType_create(PyTypeObject* type, PrivateAttrCreationData& data)
2212
2223
  return new_type;
2213
2224
  }
2214
2225
 
2215
- static getattrofunc get_need_tp_getattro(PyTypeObject* cls);
2216
- static setattrofunc get_need_tp_setattro(PyTypeObject* cls);
2217
- static destructor get_need_tp_finalize(PyTypeObject* cls);
2226
+ static getattrofunc get_need_tp_getattro(PyTypeObject* cls) noexcept;
2227
+ static setattrofunc get_need_tp_setattro(PyTypeObject* cls) noexcept;
2228
+ static destructor get_need_tp_finalize(PyTypeObject* cls) noexcept;
2218
2229
 
2219
2230
  static void
2220
- ensure_tp(PyTypeObject* type_instance)
2231
+ ensure_tp(PyTypeObject* type_instance) noexcept
2221
2232
  {
2222
2233
  uintptr_t type_id = (uintptr_t)(type_instance);
2223
2234
  {
@@ -2289,7 +2300,7 @@ ensure_tp(PyTypeObject* type_instance)
2289
2300
  }
2290
2301
 
2291
2302
  static void
2292
- ensure_subclass_tp(PyTypeObject* type_instance)
2303
+ ensure_subclass_tp(PyTypeObject* type_instance) noexcept
2293
2304
  {
2294
2305
  // type.__subclasses__
2295
2306
  PyObject* type_subclasses = (PyObject*)type_instance->tp_subclasses;
@@ -2328,7 +2339,7 @@ ensure_subclass_tp(PyTypeObject* type_instance)
2328
2339
  }
2329
2340
 
2330
2341
  static bool
2331
- PrivateAttrType_postprocess(PyObject* new_type, PrivateAttrCreationData& data)
2342
+ PrivateAttrType_postprocess(PyObject* new_type, PrivateAttrCreationData& data) noexcept
2332
2343
  {
2333
2344
  if (!new_type) {
2334
2345
  return false;
@@ -2341,7 +2352,8 @@ PrivateAttrType_postprocess(PyObject* new_type, PrivateAttrCreationData& data)
2341
2352
  PyTypeObject* type_instance = (PyTypeObject*)new_type;
2342
2353
  uintptr_t type_id = (uintptr_t)(type_instance);
2343
2354
  if (PyDict_ContainsString(type_instance->tp_dict, "__static_attributes__")) {
2344
- PyErr_SetString(PyExc_SystemError, "'__static_attributes__' will expose private attribute names and cannot be used in private attribute types");
2355
+ PyErr_Format(PyExc_SystemError,
2356
+ "%s (%d): '__static_attributes__' will expose private attribute names and cannot be used in private attribute types", __FILE__, __LINE__);
2345
2357
  return false;
2346
2358
  }
2347
2359
 
@@ -2454,7 +2466,7 @@ PrivateAttrType_postprocess(PyObject* new_type, PrivateAttrCreationData& data)
2454
2466
  }
2455
2467
 
2456
2468
  static PyObject*
2457
- PrivateAttrType_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
2469
+ PrivateAttrType_new(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept
2458
2470
  {
2459
2471
  PrivateAttrCreationData data;
2460
2472
  PyObject* new_type = nullptr;
@@ -2477,7 +2489,7 @@ PrivateAttrType_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
2477
2489
  }
2478
2490
 
2479
2491
  static PyObject*
2480
- PrivateAttrType_getattr(PyObject* cls, PyObject* name)
2492
+ PrivateAttrType_getattr(PyObject* cls, PyObject* name) noexcept
2481
2493
  {
2482
2494
  if (!PyType_Check(cls)) {
2483
2495
  PyErr_SetString(PyExc_TypeError, "cls must be a type");
@@ -2509,7 +2521,7 @@ PrivateAttrType_getattr(PyObject* cls, PyObject* name)
2509
2521
  }
2510
2522
 
2511
2523
  static int
2512
- init_all_slots()
2524
+ init_all_slots() noexcept
2513
2525
  {
2514
2526
  AllSlots::original_getattro = python_original_tp_getattro;
2515
2527
  AllSlots::original_setattro = python_original_tp_setattro;
@@ -2518,7 +2530,7 @@ init_all_slots()
2518
2530
  }
2519
2531
 
2520
2532
  static getattrofunc
2521
- get_need_tp_getattro(PyTypeObject* cls)
2533
+ get_need_tp_getattro(PyTypeObject* cls) noexcept
2522
2534
  {
2523
2535
  if (PyDict_ContainsString(cls->tp_dict, "__getattribute__") || PyDict_ContainsString(cls->tp_dict, "__getattr__")) {
2524
2536
  return AllSlots::original_getattro;
@@ -2540,7 +2552,7 @@ get_need_tp_getattro(PyTypeObject* cls)
2540
2552
  }
2541
2553
 
2542
2554
  static setattrofunc
2543
- get_need_tp_setattro(PyTypeObject* cls)
2555
+ get_need_tp_setattro(PyTypeObject* cls) noexcept
2544
2556
  {
2545
2557
  if (PyDict_ContainsString(cls->tp_dict, "__setattr__") || PyDict_ContainsString(cls->tp_dict, "__delattr__")) {
2546
2558
  return AllSlots::original_setattro;
@@ -2562,7 +2574,7 @@ get_need_tp_setattro(PyTypeObject* cls)
2562
2574
  }
2563
2575
 
2564
2576
  static destructor
2565
- get_need_tp_finalize(PyTypeObject* cls)
2577
+ get_need_tp_finalize(PyTypeObject* cls) noexcept
2566
2578
  {
2567
2579
  if (PyDict_ContainsString(cls->tp_dict, "__del__")) {
2568
2580
  return AllSlots::original_finalize;
@@ -2584,7 +2596,7 @@ get_need_tp_finalize(PyTypeObject* cls)
2584
2596
  }
2585
2597
 
2586
2598
  static void
2587
- type_change_all_slots(PyTypeObject* cls, const char* name)
2599
+ type_change_all_slots(PyTypeObject* cls, const char* name) noexcept
2588
2600
  {
2589
2601
  if (strcmp(name, "__getattribute__") == 0 || strcmp(name, "__getattr__") == 0) {
2590
2602
  cls->tp_getattro = PrivateAttr_tp_getattro;
@@ -2599,7 +2611,7 @@ type_change_all_slots(PyTypeObject* cls, const char* name)
2599
2611
  }
2600
2612
 
2601
2613
  static void
2602
- subtype_change_all_slots(PyTypeObject* cls, const char* name)
2614
+ subtype_change_all_slots(PyTypeObject* cls, const char* name) noexcept
2603
2615
  {
2604
2616
  // tp_subclasses: {id(type): weakref.ref(type)}
2605
2617
  PyObject* tp_subclasses = (PyObject*)cls->tp_subclasses;
@@ -2642,7 +2654,7 @@ subtype_change_all_slots(PyTypeObject* cls, const char* name)
2642
2654
  }
2643
2655
 
2644
2656
  static int
2645
- PrivateAttrType_setattr(PyObject* cls, PyObject* name, PyObject* value)
2657
+ PrivateAttrType_setattr(PyObject* cls, PyObject* name, PyObject* value) noexcept
2646
2658
  {
2647
2659
  if (!PyType_Check(cls)) {
2648
2660
  PyErr_SetString(PyExc_TypeError, "cls must be a type");
@@ -2711,7 +2723,7 @@ PrivateAttrType_setattr(PyObject* cls, PyObject* name, PyObject* value)
2711
2723
  }
2712
2724
 
2713
2725
  static void
2714
- PrivateAttrType_finalize(PyObject* cls)
2726
+ PrivateAttrType_finalize(PyObject* cls) noexcept
2715
2727
  {
2716
2728
  uintptr_t typ_id = (uintptr_t) cls;
2717
2729
  if (::AllData::all_type_attr_set.find(typ_id) != ::AllData::all_type_attr_set.end()) {
@@ -2776,7 +2788,7 @@ PrivateAttrType_finalize(PyObject* cls)
2776
2788
  }
2777
2789
 
2778
2790
  static void
2779
- PrivateAttrType_del(PyObject* cls)
2791
+ PrivateAttrType_del(PyObject* cls) noexcept
2780
2792
  {
2781
2793
  PrivateAttrType_finalize(cls);
2782
2794
  PyType_Type.tp_dealloc(cls);
@@ -2786,7 +2798,7 @@ static const char* PrivateAttrBase_doc = "The class to help to create private at
2786
2798
 
2787
2799
  // PrivateAttrBase
2788
2800
  static PyObject*
2789
- create_private_attr_base_simple(void)
2801
+ create_private_attr_base_simple(void) noexcept
2790
2802
  {
2791
2803
  PyObject* name = PyUnicode_FromString("PrivateAttrBase");
2792
2804
  if (!name) return NULL;
@@ -2839,7 +2851,7 @@ typedef struct {
2839
2851
  } PrivateTempObject;
2840
2852
 
2841
2853
  static PyObject*
2842
- PrivateTempObject_name(PyObject* self, void* /*closure*/)
2854
+ PrivateTempObject_name(PyObject* self, void* /*closure*/) noexcept
2843
2855
  {
2844
2856
  PyObject* name = ((PrivateTempObject*)self)->tmp->name;
2845
2857
  if (!name) {
@@ -2851,7 +2863,7 @@ PrivateTempObject_name(PyObject* self, void* /*closure*/)
2851
2863
  }
2852
2864
 
2853
2865
  static PyObject*
2854
- PrivateTempObject_base(PyObject* self, void* /*closure*/)
2866
+ PrivateTempObject_base(PyObject* self, void* /*closure*/) noexcept
2855
2867
  {
2856
2868
  PyObject* base = ((PrivateTempObject*)self)->tmp->bases;
2857
2869
  if (!base) {
@@ -2863,7 +2875,7 @@ PrivateTempObject_base(PyObject* self, void* /*closure*/)
2863
2875
  }
2864
2876
 
2865
2877
  static PyObject*
2866
- PrivateTempObject_attrs(PyObject* self, void* /*closure*/)
2878
+ PrivateTempObject_attrs(PyObject* self, void* /*closure*/) noexcept
2867
2879
  {
2868
2880
  PyObject* attrs = ((PrivateTempObject*)self)->tmp->attrs_copy;
2869
2881
  if (!attrs) {
@@ -2875,7 +2887,7 @@ PrivateTempObject_attrs(PyObject* self, void* /*closure*/)
2875
2887
  }
2876
2888
 
2877
2889
  static PyObject*
2878
- PrivateTempObject_kwds(PyObject* self, void* /*closure*/)
2890
+ PrivateTempObject_kwds(PyObject* self, void* /*closure*/) noexcept
2879
2891
  {
2880
2892
  PyObject* kwds = ((PrivateTempObject*)self)->tmp->base_kwds;
2881
2893
  if (!kwds) {
@@ -2895,7 +2907,7 @@ static PyGetSetDef PrivateTempObject_getsets[] = {
2895
2907
  };
2896
2908
 
2897
2909
  static void
2898
- PrivateTempObject_dealloc(PyObject* self)
2910
+ PrivateTempObject_dealloc(PyObject* self) noexcept
2899
2911
  {
2900
2912
  ((PrivateTempObject*)self)->tmp->clear();
2901
2913
  delete ((PrivateTempObject*)self)->tmp;
@@ -2936,7 +2948,7 @@ static PyTypeObject PrivateTempType = {
2936
2948
  };
2937
2949
 
2938
2950
  static PyObject*
2939
- prepare_for_PrivateAttr(PyObject* /*self*/, PyObject* args, PyObject* kwargs)
2951
+ prepare_for_PrivateAttr(PyObject* /*self*/, PyObject* args, PyObject* kwargs) noexcept
2940
2952
  {
2941
2953
  PrivateAttrCreationData* tmp_data = new PrivateAttrCreationData();
2942
2954
  if (!PrivateAttrType_preprocess(args, kwargs, *tmp_data)) {
@@ -2955,7 +2967,7 @@ prepare_for_PrivateAttr(PyObject* /*self*/, PyObject* args, PyObject* kwargs)
2955
2967
  }
2956
2968
 
2957
2969
  static PyObject*
2958
- postprocess_for_PrivateAttr(PyObject* /*self*/, PyObject* args)
2970
+ postprocess_for_PrivateAttr(PyObject* /*self*/, PyObject* args) noexcept
2959
2971
  {
2960
2972
  PyObject* type;
2961
2973
  PyObject* tmp;
@@ -2978,7 +2990,7 @@ postprocess_for_PrivateAttr(PyObject* /*self*/, PyObject* args)
2978
2990
  }
2979
2991
 
2980
2992
  static void
2981
- register_finalize(PyObject* cls)
2993
+ register_finalize(PyObject* cls) noexcept
2982
2994
  {
2983
2995
  Py_ssize_t original_ref = Py_REFCNT(cls);
2984
2996
  PyTypeObject* base = Py_TYPE(cls)->tp_base;
@@ -2994,7 +3006,7 @@ register_finalize(PyObject* cls)
2994
3006
 
2995
3007
 
2996
3008
  static PyObject*
2997
- metaclass_weakref_callback(PyObject* self, PyObject* /*weakref*/)
3009
+ metaclass_weakref_callback(PyObject* self, PyObject* /*weakref*/) noexcept
2998
3010
  {
2999
3011
  void* pointer = PyCapsule_GetPointer(self, "metaclass_id");
3000
3012
  if (!pointer) {
@@ -3021,7 +3033,7 @@ static PyMethodDef weakref_callback_def = {
3021
3033
  };
3022
3034
 
3023
3035
  static PyObject*
3024
- register_metaclass(PyObject* /*self*/, PyObject* metaclass)
3036
+ register_metaclass(PyObject* /*self*/, PyObject* metaclass) noexcept
3025
3037
  {
3026
3038
  if (!PyType_Check(metaclass)) {
3027
3039
  PyErr_SetString(PyExc_TypeError, "metaclass must be a type");
@@ -3062,7 +3074,7 @@ register_metaclass(PyObject* /*self*/, PyObject* metaclass)
3062
3074
  }
3063
3075
 
3064
3076
  static PyObject*
3065
- ensure_type_tp(PyObject* /*self*/, PyObject* type)
3077
+ ensure_type_tp(PyObject* /*self*/, PyObject* type) noexcept
3066
3078
  {
3067
3079
  if (!PyType_Check(type)) {
3068
3080
  PyErr_SetString(PyExc_TypeError, "type must be a type");
@@ -3077,7 +3089,7 @@ ensure_type_tp(PyObject* /*self*/, PyObject* type)
3077
3089
  }
3078
3090
 
3079
3091
  static PyObject*
3080
- ensure_metaclass_tp(PyObject* /*self*/, PyObject* metaclass)
3092
+ ensure_metaclass_tp(PyObject* /*self*/, PyObject* metaclass) noexcept
3081
3093
  {
3082
3094
  uintptr_t id = (uintptr_t)metaclass;
3083
3095
  if (::AllData::all_register_type_weak_ref.find(id) != ::AllData::all_register_type_weak_ref.end()) {
@@ -3089,7 +3101,7 @@ ensure_metaclass_tp(PyObject* /*self*/, PyObject* metaclass)
3089
3101
  }
3090
3102
 
3091
3103
  static PyObject*
3092
- PrivateModule_get_PrivateWrapProxy(PyObject* /*self*/, void* /*closure*/)
3104
+ PrivateModule_get_PrivateWrapProxy(PyObject* /*self*/, void* /*closure*/) noexcept
3093
3105
  {
3094
3106
  PyObject* PythonPrivateWrapProxy = (PyObject*)&PrivateWrapProxyType;
3095
3107
  Py_INCREF(PythonPrivateWrapProxy);
@@ -3098,7 +3110,7 @@ PrivateModule_get_PrivateWrapProxy(PyObject* /*self*/, void* /*closure*/)
3098
3110
 
3099
3111
  // type PrivateAttrType
3100
3112
  static PyObject*
3101
- PrivateModule_get_PrivateAttrType(PyObject* /*self*/, void* /*closure*/)
3113
+ PrivateModule_get_PrivateAttrType(PyObject* /*self*/, void* /*closure*/) noexcept
3102
3114
  {
3103
3115
  PyObject* PythonPrivateAttrType = (PyObject*)&PrivateAttrType;
3104
3116
  Py_INCREF(PythonPrivateAttrType);
@@ -3106,7 +3118,7 @@ PrivateModule_get_PrivateAttrType(PyObject* /*self*/, void* /*closure*/)
3106
3118
  }
3107
3119
 
3108
3120
  static PyObject*
3109
- PrivateModule_get_PrivateAttrBase(PyObject* /*self*/, void* /*closure*/)
3121
+ PrivateModule_get_PrivateAttrBase(PyObject* /*self*/, void* /*closure*/) noexcept
3110
3122
  {
3111
3123
  static PyObject* PrivateAttrBase = create_private_attr_base_simple();
3112
3124
  if (!PrivateAttrBase) {
@@ -3120,7 +3132,7 @@ PrivateModule_get_PrivateAttrBase(PyObject* /*self*/, void* /*closure*/)
3120
3132
  }
3121
3133
 
3122
3134
  static PyObject*
3123
- PrivateModule_dir(PyObject* self, PyObject* /*args*/)
3135
+ PrivateModule_dir(PyObject* self, PyObject* /*args*/) noexcept
3124
3136
  {
3125
3137
  PyObject* parent_dir = PyObject_CallMethod((PyObject*)&PyModule_Type, "__dir__", "O", self);
3126
3138
  if (!parent_dir) return NULL;
@@ -3144,7 +3156,7 @@ PrivateModule_dir(PyObject* self, PyObject* /*args*/)
3144
3156
  }
3145
3157
 
3146
3158
  static int
3147
- PrivateModule_setattro(PyObject* cls, PyObject* name, PyObject* value)
3159
+ PrivateModule_setattro(PyObject* cls, PyObject* name, PyObject* value) noexcept
3148
3160
  {
3149
3161
  // if name is "__class__" it do nothing and return success
3150
3162
  if (PyUnicode_Check(name)) {
@@ -3277,7 +3289,7 @@ static PyModuleDef def = {
3277
3289
  };
3278
3290
 
3279
3291
  PyMODINIT_FUNC
3280
- PyInit_private_attribute(void)
3292
+ PyInit_private_attribute(void) noexcept
3281
3293
  {
3282
3294
  if (init_all_slots() <0 ||
3283
3295
  PyType_Ready(&PrivateWrapType) < 0 ||
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: private_attribute_cpp
3
- Version: 1.4.7
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.7',
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