private-attribute-cpp 2.1.16__tar.gz → 2.1.17__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-2.1.16/private_attribute_cpp.egg-info → private_attribute_cpp-2.1.17}/PKG-INFO +1 -1
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/private_attribute.cpp +26 -15
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/private_attribute.pyi +6 -5
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17/private_attribute_cpp.egg-info}/PKG-INFO +1 -1
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/setup.py +1 -1
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/LICENSE +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/MANIFEST.in +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/README.md +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/picosha2.h +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/private_attribute_cpp.egg-info/SOURCES.txt +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/private_attribute_cpp.egg-info/dependency_links.txt +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/private_attribute_cpp.egg-info/not-zip-safe +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/private_attribute_cpp.egg-info/top_level.txt +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/setup.cfg +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/tests/test_attr_classify_owner.py +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/tests/test_class_private_attrs.py +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/tests/test_gc_collect.py +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/tests/test_private_abc.py +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/tests/test_private_attrs.py +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/tests/test_private_func.py +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/tests/test_private_inheritance.py +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/tests/test_private_method.py +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/tests/test_private_wrap.py +0 -0
- {private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/tests/test_slots_cycle.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: private_attribute_cpp
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.17
|
|
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
|
|
@@ -3682,6 +3682,29 @@ PrivateTempObject_dealloc(PyObject* self) noexcept
|
|
|
3682
3682
|
Py_TYPE(self)->tp_free(self);
|
|
3683
3683
|
}
|
|
3684
3684
|
|
|
3685
|
+
static PyObject*
|
|
3686
|
+
PrivateTempObject_postprocess(PyObject* self, PyObject* type) noexcept
|
|
3687
|
+
{
|
|
3688
|
+
if (!PyType_Check(type)) {
|
|
3689
|
+
PyErr_SetString(PyExc_TypeError, "type must be a type");
|
|
3690
|
+
return NULL;
|
|
3691
|
+
}
|
|
3692
|
+
if ((((PrivateTempObject*)self)->tmp->cleared)) {
|
|
3693
|
+
PyErr_SetString(PyExc_RuntimeError, "temp not init or have been used");
|
|
3694
|
+
return NULL;
|
|
3695
|
+
}
|
|
3696
|
+
if (!PrivateAttrType_postprocess(type, *(((PrivateTempObject*)self)->tmp))) {
|
|
3697
|
+
return NULL;
|
|
3698
|
+
}
|
|
3699
|
+
((PrivateTempObject*)self)->tmp->clear();
|
|
3700
|
+
Py_RETURN_NONE;
|
|
3701
|
+
}
|
|
3702
|
+
|
|
3703
|
+
static PyMethodDef PrivateTempObject_methods[] = {
|
|
3704
|
+
{"postprocess", (PyCFunction)PrivateTempObject_postprocess, METH_O, "postprocess the temp object"},
|
|
3705
|
+
{NULL}
|
|
3706
|
+
};
|
|
3707
|
+
|
|
3685
3708
|
static PyTypeObject PrivateTempType = {
|
|
3686
3709
|
PyVarObject_HEAD_INIT(NULL, 0)
|
|
3687
3710
|
"private_attribute._PrivateTemp", // tp_name
|
|
@@ -3710,7 +3733,7 @@ static PyTypeObject PrivateTempType = {
|
|
|
3710
3733
|
0, //tp_weaklistoffset
|
|
3711
3734
|
0, //tp_iter
|
|
3712
3735
|
0, //tp_iternext
|
|
3713
|
-
|
|
3736
|
+
PrivateTempObject_methods, //tp_methods
|
|
3714
3737
|
0, //tp_members
|
|
3715
3738
|
PrivateTempObject_getsets //tp_getset
|
|
3716
3739
|
};
|
|
@@ -3742,19 +3765,7 @@ postprocess_for_PrivateAttr(PyObject* /*self*/, PyObject* args) noexcept
|
|
|
3742
3765
|
if (!PyArg_ParseTuple(args, "OO", &type, &tmp)) {
|
|
3743
3766
|
return NULL;
|
|
3744
3767
|
}
|
|
3745
|
-
|
|
3746
|
-
PyErr_SetString(PyExc_TypeError, "type must be a type");
|
|
3747
|
-
return NULL;
|
|
3748
|
-
}
|
|
3749
|
-
if (!PyObject_TypeCheck(tmp, &PrivateTempType)) {
|
|
3750
|
-
PyErr_SetString(PyExc_TypeError, "tmp must be a private_temp");
|
|
3751
|
-
return NULL;
|
|
3752
|
-
}
|
|
3753
|
-
if (!PrivateAttrType_postprocess(type, *(((PrivateTempObject*)tmp)->tmp))) {
|
|
3754
|
-
return NULL;
|
|
3755
|
-
}
|
|
3756
|
-
((PrivateTempObject*)tmp)->tmp->clear();
|
|
3757
|
-
Py_RETURN_NONE;
|
|
3768
|
+
return PrivateTempObject_postprocess(tmp, type);
|
|
3758
3769
|
}
|
|
3759
3770
|
|
|
3760
3771
|
#define METACLASS_WEAKREF_CALLBACK_REMOVE_ITEM(name) do {\
|
|
@@ -4122,7 +4133,7 @@ class PrivateAbcMeta(ABCMeta):
|
|
|
4122
4133
|
def __new__(cls, *args, **kwargs):
|
|
4123
4134
|
temp = private_attribute.prepare(*args, **kwargs)
|
|
4124
4135
|
typ = super().__new__(cls, temp.name, temp.bases, temp.attrs, **temp.kwds)
|
|
4125
|
-
private_attribute.postprocess(typ, temp)
|
|
4136
|
+
private_attribute.postprocess(typ, temp) # or temp.postprocess(typ)
|
|
4126
4137
|
return typ
|
|
4127
4138
|
|
|
4128
4139
|
private_attribute.register_metaclass(PrivateAbcMeta)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""A module that provides a metaclass for creating classes with private attributes.
|
|
2
|
-
Private attributes are defined in the `__private_attrs__` sequence and are only
|
|
3
|
-
You can use the `PrivateAttrBase`
|
|
2
|
+
Private attributes are defined in the `__private_attrs__` sequence and are only visitable in class codes.
|
|
3
|
+
You can use the `PrivateAttrBase` as the base class to create classes with private attributes.
|
|
4
4
|
The attributes which are private are not on the instance's `__dict__` and cannot be accessed outside
|
|
5
5
|
but in the methods defined in class it is reachable.
|
|
6
6
|
Usage example:
|
|
@@ -105,6 +105,7 @@ class _PrivateTemp:
|
|
|
105
105
|
def attrs(self) -> dict[str, Any]: ...
|
|
106
106
|
@property
|
|
107
107
|
def kwds(self) -> dict[str, Any]: ...
|
|
108
|
+
def postprocess(self, typ: type, /) -> None: ... # add in 2.1.17
|
|
108
109
|
|
|
109
110
|
def prepare(name: str, bases: tuple, attrs: _PrivateAttrDict, /, **kwds) -> _PrivateTemp:
|
|
110
111
|
"""
|
|
@@ -129,7 +130,7 @@ def prepare(name: str, bases: tuple, attrs: _PrivateAttrDict, /, **kwds) -> _Pri
|
|
|
129
130
|
def __new__(cls, *args, **kwargs):
|
|
130
131
|
temp = private_attribute.prepare(*args, **kwargs)
|
|
131
132
|
typ = super().__new__(cls, temp.name, temp.bases, temp.attrs, **temp.kwds)
|
|
132
|
-
private_attribute.postprocess(typ, temp)
|
|
133
|
+
private_attribute.postprocess(typ, temp) # or temp.postprocess(typ)
|
|
133
134
|
return typ
|
|
134
135
|
|
|
135
136
|
private_attribute.register_metaclass(PrivateAbcMeta)
|
|
@@ -160,7 +161,7 @@ def postprocess(typ: type, temp: _PrivateTemp, /) -> None:
|
|
|
160
161
|
def __new__(cls, *args, **kwargs):
|
|
161
162
|
temp = private_attribute.prepare(*args, **kwargs)
|
|
162
163
|
typ = super().__new__(cls, temp.name, temp.bases, temp.attrs, **temp.kwds)
|
|
163
|
-
private_attribute.postprocess(typ, temp)
|
|
164
|
+
private_attribute.postprocess(typ, temp) # or temp.postprocess(typ)
|
|
164
165
|
return typ
|
|
165
166
|
|
|
166
167
|
private_attribute.register_metaclass(PrivateAbcMeta)
|
|
@@ -190,7 +191,7 @@ def register_metaclass(typ: type, /) -> None:
|
|
|
190
191
|
def __new__(cls, *args, **kwargs):
|
|
191
192
|
temp = private_attribute.prepare(*args, **kwargs)
|
|
192
193
|
typ = super().__new__(cls, temp.name, temp.bases, temp.attrs, **temp.kwds)
|
|
193
|
-
private_attribute.postprocess(typ, temp)
|
|
194
|
+
private_attribute.postprocess(typ, temp) # or temp.postprocess(typ)
|
|
194
195
|
return typ
|
|
195
196
|
|
|
196
197
|
private_attribute.register_metaclass(PrivateAbcMeta)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: private_attribute_cpp
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.17
|
|
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 @@ readme = open('README.md').read()
|
|
|
24
24
|
|
|
25
25
|
setup(
|
|
26
26
|
name='private_attribute_cpp',
|
|
27
|
-
version='2.1.
|
|
27
|
+
version='2.1.17',
|
|
28
28
|
author="HuangHaoHua",
|
|
29
29
|
author_email="13140752715@example.com",
|
|
30
30
|
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
|
|
File without changes
|
{private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/tests/test_attr_classify_owner.py
RENAMED
|
File without changes
|
{private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/tests/test_class_private_attrs.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{private_attribute_cpp-2.1.16 → private_attribute_cpp-2.1.17}/tests/test_private_inheritance.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|