private-attribute-cpp 1.4.10__tar.gz → 1.4.11__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.
- {private_attribute_cpp-1.4.10/private_attribute_cpp.egg-info → private_attribute_cpp-1.4.11}/PKG-INFO +2 -1
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/README.md +1 -0
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/private_attribute.cpp +15 -25
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/private_attribute.pyi +1 -1
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11/private_attribute_cpp.egg-info}/PKG-INFO +2 -1
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/setup.py +1 -1
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/LICENSE +0 -0
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/MANIFEST.in +0 -0
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/picosha2.h +0 -0
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/private_attribute_cpp.egg-info/SOURCES.txt +0 -0
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/private_attribute_cpp.egg-info/dependency_links.txt +0 -0
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/private_attribute_cpp.egg-info/not-zip-safe +0 -0
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/private_attribute_cpp.egg-info/top_level.txt +0 -0
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/setup.cfg +0 -0
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/tests/test_class_private_attrs.py +0 -0
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/tests/test_private_abc.py +0 -0
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/tests/test_private_attrs.py +0 -0
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/tests/test_private_func.py +0 -0
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/tests/test_private_inheritance.py +0 -0
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/tests/test_private_method.py +0 -0
- {private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/tests/test_private_wrap.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: private_attribute_cpp
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.11
|
|
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
|
|
@@ -247,6 +247,7 @@ TypeError: Can't instantiate abstract class MyClass without an implementation fo
|
|
|
247
247
|
- All of the object that is the instance of the class "PrivateAttrBase" or its subclass are default to be unable to be pickled.
|
|
248
248
|
- Finally the attributes' names in `__private_attrs__` will be change to a tuple with two hash.
|
|
249
249
|
- Finally the `_PrivateWrap` object will be recoveried to the original object.
|
|
250
|
+
- Don't use a decorator which will return the `_PrivateWrap` in `PrivateWrapProxy` which will raise `TypeError`.
|
|
250
251
|
- One class defined in another class cannot use another class's private attribute.
|
|
251
252
|
- One parent class defined an attribute which not in `__private_attrs__` or not a `PrivateAttrType` instance, the child class shouldn't contain the attribute in its `__private_attrs__`.
|
|
252
253
|
- CPython may change "tp_getattro", "tp_setattro" and so on when you change the attribute "\_\_getattribute\_\_", "\_\_setattr\_\_" and so on. If you are fear about it, you can use `ensure_type` to reset those tp slots. For the other metaclasses, you can use `ensure_metaclass` to reset those tp slots. Also, don't set those methods on these classes in your code.
|
|
@@ -228,6 +228,7 @@ TypeError: Can't instantiate abstract class MyClass without an implementation fo
|
|
|
228
228
|
- All of the object that is the instance of the class "PrivateAttrBase" or its subclass are default to be unable to be pickled.
|
|
229
229
|
- Finally the attributes' names in `__private_attrs__` will be change to a tuple with two hash.
|
|
230
230
|
- Finally the `_PrivateWrap` object will be recoveried to the original object.
|
|
231
|
+
- Don't use a decorator which will return the `_PrivateWrap` in `PrivateWrapProxy` which will raise `TypeError`.
|
|
231
232
|
- One class defined in another class cannot use another class's private attribute.
|
|
232
233
|
- One parent class defined an attribute which not in `__private_attrs__` or not a `PrivateAttrType` instance, the child class shouldn't contain the attribute in its `__private_attrs__`.
|
|
233
234
|
- CPython may change "tp_getattro", "tp_setattro" and so on when you change the attribute "\_\_getattribute\_\_", "\_\_setattr\_\_" and so on. If you are fear about it, you can use `ensure_type` to reset those tp slots. For the other metaclasses, you can use `ensure_metaclass` to reset those tp slots. Also, don't set those methods on these classes in your code.
|
|
@@ -271,10 +271,7 @@ default_random_string(uintptr_t obj_id, const std::string& attr_name) noexcept
|
|
|
271
271
|
result = it->second;
|
|
272
272
|
return result;
|
|
273
273
|
}
|
|
274
|
-
while (
|
|
275
|
-
if (::AllData::all_exist_name.find(result) == ::AllData::all_exist_name.end()) {
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
274
|
+
while (::AllData::all_exist_name.find(result) != ::AllData::all_exist_name.end()) {
|
|
278
275
|
result = original_result + "_" + std::to_string(i);
|
|
279
276
|
i++;
|
|
280
277
|
}
|
|
@@ -372,10 +369,7 @@ custom_random_string(uintptr_t obj_id, const std::string& attr_name, PyObject* f
|
|
|
372
369
|
result = it->second;
|
|
373
370
|
return result;
|
|
374
371
|
}
|
|
375
|
-
while (
|
|
376
|
-
if (::AllData::all_exist_name.find(result) == ::AllData::all_exist_name.end()) {
|
|
377
|
-
break;
|
|
378
|
-
}
|
|
372
|
+
while (::AllData::all_exist_name.find(result) != ::AllData::all_exist_name.end()) {
|
|
379
373
|
result = original_result + "_" + std::to_string(i);
|
|
380
374
|
i++;
|
|
381
375
|
}
|
|
@@ -883,17 +877,11 @@ static PrivateWrapObject* PrivateWrap_New(PyObject *decorator, PyObject *func, P
|
|
|
883
877
|
static void PrivateWrap_dealloc(PrivateWrapObject *self) noexcept;
|
|
884
878
|
static PyObject* PrivateWrap_call(PrivateWrapObject *self, PyObject *args, PyObject *kw) noexcept;
|
|
885
879
|
|
|
886
|
-
static
|
|
887
|
-
|
|
888
|
-
{
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
PyObject *res = ((PrivateWrapObject*)obj)->result;
|
|
894
|
-
Py_INCREF(res);
|
|
895
|
-
return res;
|
|
896
|
-
}
|
|
880
|
+
static PyMemberDef PrivateWrap_members[] = {
|
|
881
|
+
{"result", T_OBJECT, offsetof(PrivateWrapObject, result), READONLY, "The result object"},
|
|
882
|
+
{"__wrapped__", T_OBJECT, offsetof(PrivateWrapObject, result), READONLY, "The result object"},
|
|
883
|
+
{NULL}
|
|
884
|
+
};
|
|
897
885
|
|
|
898
886
|
static PyObject *
|
|
899
887
|
PrivateWrap_funcs(PyObject *obj, void* /*closure*/) noexcept
|
|
@@ -995,9 +983,7 @@ static const char* PrivateWrap_result_doc = "the final result of decorating";
|
|
|
995
983
|
static const char* PrivateWrap_funcs_doc = "the original functions";
|
|
996
984
|
|
|
997
985
|
static PyGetSetDef PrivateWrap_getset[] = {
|
|
998
|
-
{"result", (getter)PrivateWrap_result, NULL, PrivateWrap_result_doc, NULL},
|
|
999
986
|
{"funcs", (getter)PrivateWrap_funcs, NULL, PrivateWrap_funcs_doc, NULL},
|
|
1000
|
-
{"__wrapped__", (getter)PrivateWrap_result, NULL, NULL, NULL},
|
|
1001
987
|
{"__doc__", (getter)PrivateWrap_doc, NULL, NULL, NULL},
|
|
1002
988
|
{"__module__", (getter)PrivateWrap_module, NULL, NULL, NULL},
|
|
1003
989
|
{"__name__", (getter)PrivateWarp_name, NULL, NULL, NULL},
|
|
@@ -1050,21 +1036,25 @@ static PyTypeObject PrivateWrapType = {
|
|
|
1050
1036
|
0, // tp_iter
|
|
1051
1037
|
0, // tp_iternext
|
|
1052
1038
|
0, // tp_methods
|
|
1053
|
-
|
|
1039
|
+
PrivateWrap_members, // tp_members
|
|
1054
1040
|
PrivateWrap_getset, // tp_getset
|
|
1055
1041
|
};
|
|
1056
1042
|
|
|
1057
1043
|
static PrivateWrapObject*
|
|
1058
1044
|
PrivateWrap_New(PyObject *decorator, PyObject *func, PyObject *list) noexcept
|
|
1059
1045
|
{
|
|
1060
|
-
PrivateWrapObject *self =
|
|
1061
|
-
PyObject_New(PrivateWrapObject, &PrivateWrapType);
|
|
1062
1046
|
PyObject *wrapped = PyObject_CallFunctionObjArgs(decorator, func, NULL);
|
|
1063
1047
|
if (!wrapped) {
|
|
1064
|
-
|
|
1048
|
+
return NULL;
|
|
1049
|
+
}
|
|
1050
|
+
if (PyObject_TypeCheck(wrapped, &PrivateWrapType)) {
|
|
1051
|
+
PyErr_SetString(PyExc_TypeError, "decorator returned a '_PrivateWrap' object which is not allowed");
|
|
1052
|
+
Py_DECREF(wrapped);
|
|
1065
1053
|
return NULL;
|
|
1066
1054
|
}
|
|
1067
1055
|
|
|
1056
|
+
PrivateWrapObject *self =
|
|
1057
|
+
PyObject_New(PrivateWrapObject, &PrivateWrapType);
|
|
1068
1058
|
self->func_list = list;
|
|
1069
1059
|
Py_INCREF(list);
|
|
1070
1060
|
|
|
@@ -76,7 +76,7 @@ class PrivateWrapProxy:
|
|
|
76
76
|
class PrivateAttrType(type):
|
|
77
77
|
"metaclass for private attributes"
|
|
78
78
|
def __new__(cls, name: str, bases: tuple,
|
|
79
|
-
attrs: _PrivateAttrDict, /,
|
|
79
|
+
attrs: _PrivateAttrDict, /, *,
|
|
80
80
|
private_func: Callable[[int, str], str]|None = None) -> PrivateAttrType: ...
|
|
81
81
|
|
|
82
82
|
class PrivateAttrBase(metaclass=PrivateAttrType):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: private_attribute_cpp
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.11
|
|
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
|
|
@@ -247,6 +247,7 @@ TypeError: Can't instantiate abstract class MyClass without an implementation fo
|
|
|
247
247
|
- All of the object that is the instance of the class "PrivateAttrBase" or its subclass are default to be unable to be pickled.
|
|
248
248
|
- Finally the attributes' names in `__private_attrs__` will be change to a tuple with two hash.
|
|
249
249
|
- Finally the `_PrivateWrap` object will be recoveried to the original object.
|
|
250
|
+
- Don't use a decorator which will return the `_PrivateWrap` in `PrivateWrapProxy` which will raise `TypeError`.
|
|
250
251
|
- One class defined in another class cannot use another class's private attribute.
|
|
251
252
|
- One parent class defined an attribute which not in `__private_attrs__` or not a `PrivateAttrType` instance, the child class shouldn't contain the attribute in its `__private_attrs__`.
|
|
252
253
|
- CPython may change "tp_getattro", "tp_setattro" and so on when you change the attribute "\_\_getattribute\_\_", "\_\_setattr\_\_" and so on. If you are fear about it, you can use `ensure_type` to reset those tp slots. For the other metaclasses, you can use `ensure_metaclass` to reset those tp slots. Also, don't set those methods on these classes in your code.
|
|
@@ -18,7 +18,7 @@ readme = open('README.md').read()
|
|
|
18
18
|
|
|
19
19
|
setup(
|
|
20
20
|
name='private_attribute_cpp',
|
|
21
|
-
version='1.4.
|
|
21
|
+
version='1.4.11',
|
|
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.',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/tests/test_class_private_attrs.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{private_attribute_cpp-1.4.10 → private_attribute_cpp-1.4.11}/tests/test_private_inheritance.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|