private-attribute-cpp 1.4.8__tar.gz → 1.4.10__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/MANIFEST.in +2 -0
- {private_attribute_cpp-1.4.8/private_attribute_cpp.egg-info → private_attribute_cpp-1.4.10}/PKG-INFO +1 -1
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/private_attribute.cpp +86 -39
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10/private_attribute_cpp.egg-info}/PKG-INFO +1 -1
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/setup.py +2 -2
- private_attribute_cpp-1.4.8/MANIFEST.in +0 -2
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/LICENSE +0 -0
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/README.md +0 -0
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/picosha2.h +0 -0
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/private_attribute.pyi +0 -0
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/private_attribute_cpp.egg-info/SOURCES.txt +0 -0
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/private_attribute_cpp.egg-info/dependency_links.txt +0 -0
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/private_attribute_cpp.egg-info/not-zip-safe +0 -0
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/private_attribute_cpp.egg-info/top_level.txt +0 -0
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/setup.cfg +0 -0
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/tests/test_class_private_attrs.py +0 -0
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/tests/test_private_abc.py +0 -0
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/tests/test_private_attrs.py +0 -0
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/tests/test_private_func.py +0 -0
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/tests/test_private_inheritance.py +0 -0
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/tests/test_private_method.py +0 -0
- {private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/tests/test_private_wrap.py +0 -0
{private_attribute_cpp-1.4.8/private_attribute_cpp.egg-info → private_attribute_cpp-1.4.10}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: private_attribute_cpp
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.10
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
|
@@ -2882,8 +2891,7 @@ PrivateTempObject_kwds(PyObject* self, void* /*closure*/) noexcept
|
|
|
2882
2891
|
{
|
|
2883
2892
|
PyObject* kwds = ((PrivateTempObject*)self)->tmp->base_kwds;
|
|
2884
2893
|
if (!kwds) {
|
|
2885
|
-
|
|
2886
|
-
return nullptr;
|
|
2894
|
+
return PyDict_New();
|
|
2887
2895
|
}
|
|
2888
2896
|
Py_INCREF(kwds);
|
|
2889
2897
|
return kwds;
|
|
@@ -3132,14 +3140,14 @@ PrivateModule_dir(PyObject* self, PyObject* /*args*/) noexcept
|
|
|
3132
3140
|
Py_DECREF(parent_dir);
|
|
3133
3141
|
return NULL;
|
|
3134
3142
|
}
|
|
3135
|
-
PyList_Append(attr_list,
|
|
3136
|
-
PyList_Append(attr_list,
|
|
3137
|
-
PyList_Append(attr_list,
|
|
3138
|
-
PyList_Append(attr_list,
|
|
3139
|
-
PyList_Append(attr_list,
|
|
3140
|
-
PyList_Append(attr_list,
|
|
3141
|
-
PyList_Append(attr_list,
|
|
3142
|
-
PyList_Append(attr_list,
|
|
3143
|
+
PyList_Append(attr_list, PyUnicode_InternFromString("PrivateWrapProxy"));
|
|
3144
|
+
PyList_Append(attr_list, PyUnicode_InternFromString("PrivateAttrType"));
|
|
3145
|
+
PyList_Append(attr_list, PyUnicode_InternFromString("PrivateAttrBase"));
|
|
3146
|
+
PyList_Append(attr_list, PyUnicode_InternFromString("prepare"));
|
|
3147
|
+
PyList_Append(attr_list, PyUnicode_InternFromString("postprocess"));
|
|
3148
|
+
PyList_Append(attr_list, PyUnicode_InternFromString("register_metaclass"));
|
|
3149
|
+
PyList_Append(attr_list, PyUnicode_InternFromString("ensure_type"));
|
|
3150
|
+
PyList_Append(attr_list, PyUnicode_InternFromString("ensure_metaclass"));
|
|
3143
3151
|
PyObject* result = PySequence_Concat(parent_dir, attr_list);
|
|
3144
3152
|
Py_DECREF(parent_dir);
|
|
3145
3153
|
Py_DECREF(attr_list);
|
|
@@ -3159,13 +3167,6 @@ PrivateModule_setattro(PyObject* cls, PyObject* name, PyObject* value) noexcept
|
|
|
3159
3167
|
return PyObject_GenericSetAttr(cls, name, value);
|
|
3160
3168
|
}
|
|
3161
3169
|
|
|
3162
|
-
static PyGetSetDef PrivateModule_getsetters[] = {
|
|
3163
|
-
{"PrivateWrapProxy", (getter)PrivateModule_get_PrivateWrapProxy, NULL, NULL, NULL},
|
|
3164
|
-
{"PrivateAttrType", (getter)PrivateModule_get_PrivateAttrType, NULL, NULL, NULL},
|
|
3165
|
-
{"PrivateAttrBase", (getter)PrivateModule_get_PrivateAttrBase, NULL, NULL, NULL},
|
|
3166
|
-
{NULL}
|
|
3167
|
-
};
|
|
3168
|
-
|
|
3169
3170
|
static const char* prepare_and_postprocess_doc = R"(function for custom metaclass to create private attributes class.
|
|
3170
3171
|
|
|
3171
3172
|
def prepare(name: str, bases: tuple, attrs: dict, **kwds) -> tempobject:
|
|
@@ -3205,7 +3206,6 @@ def ensure_metaclass(metaclass: type) -> None:
|
|
|
3205
3206
|
)";
|
|
3206
3207
|
|
|
3207
3208
|
static PyMethodDef PrivateModule_methods[] = {
|
|
3208
|
-
{"__dir__", (PyCFunction)PrivateModule_dir, METH_NOARGS, NULL},
|
|
3209
3209
|
{"prepare", (PyCFunction)prepare_for_PrivateAttr, METH_VARARGS | METH_KEYWORDS | METH_STATIC, prepare_and_postprocess_doc},
|
|
3210
3210
|
{"postprocess", (PyCFunction)postprocess_for_PrivateAttr, METH_VARARGS | METH_STATIC, prepare_and_postprocess_doc},
|
|
3211
3211
|
{"register_metaclass", (PyCFunction)register_metaclass, METH_O | METH_STATIC, prepare_and_postprocess_doc},
|
|
@@ -3214,6 +3214,53 @@ static PyMethodDef PrivateModule_methods[] = {
|
|
|
3214
3214
|
{NULL} // Sentinel
|
|
3215
3215
|
};
|
|
3216
3216
|
|
|
3217
|
+
static PyObject*
|
|
3218
|
+
PrivateModule_get_prepare(PyObject* /*self*/, void* /*closure*/) noexcept
|
|
3219
|
+
{
|
|
3220
|
+
return PyCFunction_NewEx(&PrivateModule_methods[0], NULL, NULL);
|
|
3221
|
+
}
|
|
3222
|
+
|
|
3223
|
+
static PyObject*
|
|
3224
|
+
PrivateModule_get_postprocess(PyObject* /*self*/, void* /*closure*/) noexcept
|
|
3225
|
+
{
|
|
3226
|
+
return PyCFunction_NewEx(&PrivateModule_methods[1], NULL, NULL);
|
|
3227
|
+
}
|
|
3228
|
+
|
|
3229
|
+
static PyObject*
|
|
3230
|
+
PrivateModule_get_register_metaclass(PyObject* /*self*/, void* /*closure*/) noexcept
|
|
3231
|
+
{
|
|
3232
|
+
return PyCFunction_NewEx(&PrivateModule_methods[2], NULL, NULL);
|
|
3233
|
+
}
|
|
3234
|
+
|
|
3235
|
+
static PyObject*
|
|
3236
|
+
PrivateModule_get_ensure_type(PyObject* /*self*/, void* /*closure*/) noexcept
|
|
3237
|
+
{
|
|
3238
|
+
return PyCFunction_NewEx(&PrivateModule_methods[3], NULL, NULL);
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
static PyObject*
|
|
3242
|
+
PrivateModule_get_ensure_metaclass(PyObject* /*self*/, void* /*closure*/) noexcept
|
|
3243
|
+
{
|
|
3244
|
+
return PyCFunction_NewEx(&PrivateModule_methods[4], NULL, NULL);
|
|
3245
|
+
}
|
|
3246
|
+
|
|
3247
|
+
static PyGetSetDef PrivateModule_getsetters[] = {
|
|
3248
|
+
{"PrivateWrapProxy", (getter)PrivateModule_get_PrivateWrapProxy, NULL, NULL, NULL},
|
|
3249
|
+
{"PrivateAttrType", (getter)PrivateModule_get_PrivateAttrType, NULL, NULL, NULL},
|
|
3250
|
+
{"PrivateAttrBase", (getter)PrivateModule_get_PrivateAttrBase, NULL, NULL, NULL},
|
|
3251
|
+
{"prepare", (getter)PrivateModule_get_prepare, NULL, NULL, NULL},
|
|
3252
|
+
{"postprocess", (getter)PrivateModule_get_postprocess, NULL, NULL, NULL},
|
|
3253
|
+
{"register_metaclass", (getter)PrivateModule_get_register_metaclass, NULL, NULL, NULL},
|
|
3254
|
+
{"ensure_type", (getter)PrivateModule_get_ensure_type, NULL, NULL, NULL},
|
|
3255
|
+
{"ensure_metaclass", (getter)PrivateModule_get_ensure_metaclass, NULL, NULL, NULL},
|
|
3256
|
+
{NULL}
|
|
3257
|
+
};
|
|
3258
|
+
|
|
3259
|
+
static PyMethodDef PrivateModule_methods_def[] = {
|
|
3260
|
+
{"__dir__", (PyCFunction)PrivateModule_dir, METH_NOARGS, NULL},
|
|
3261
|
+
{NULL} // Sentinel
|
|
3262
|
+
};
|
|
3263
|
+
|
|
3217
3264
|
static PyTypeObject PrivateModuleType = {
|
|
3218
3265
|
PyVarObject_HEAD_INIT(NULL, 0)
|
|
3219
3266
|
"private_attribute_module", //tp_name
|
|
@@ -3242,7 +3289,7 @@ static PyTypeObject PrivateModuleType = {
|
|
|
3242
3289
|
0, //tp_weaklistoffset
|
|
3243
3290
|
0, //tp_iter
|
|
3244
3291
|
0, //tp_iternext
|
|
3245
|
-
|
|
3292
|
+
PrivateModule_methods_def, //tp_methods
|
|
3246
3293
|
0, //tp_members
|
|
3247
3294
|
PrivateModule_getsetters, //tp_getset
|
|
3248
3295
|
&PyModule_Type, //tp_base
|
|
@@ -3314,14 +3361,14 @@ PyInit_private_attribute(void) noexcept
|
|
|
3314
3361
|
* ensure_type
|
|
3315
3362
|
* ensure_metaclass
|
|
3316
3363
|
*/
|
|
3317
|
-
PyList_Append(all,
|
|
3318
|
-
PyList_Append(all,
|
|
3319
|
-
PyList_Append(all,
|
|
3320
|
-
PyList_Append(all,
|
|
3321
|
-
PyList_Append(all,
|
|
3322
|
-
PyList_Append(all,
|
|
3323
|
-
PyList_Append(all,
|
|
3324
|
-
PyList_Append(all,
|
|
3364
|
+
PyList_Append(all, PyUnicode_InternFromString("PrivateWrapProxy"));
|
|
3365
|
+
PyList_Append(all, PyUnicode_InternFromString("PrivateAttrType"));
|
|
3366
|
+
PyList_Append(all, PyUnicode_InternFromString("PrivateAttrBase"));
|
|
3367
|
+
PyList_Append(all, PyUnicode_InternFromString("prepare"));
|
|
3368
|
+
PyList_Append(all, PyUnicode_InternFromString("postprocess"));
|
|
3369
|
+
PyList_Append(all, PyUnicode_InternFromString("register_metaclass"));
|
|
3370
|
+
PyList_Append(all, PyUnicode_InternFromString("ensure_type"));
|
|
3371
|
+
PyList_Append(all, PyUnicode_InternFromString("ensure_metaclass"));
|
|
3325
3372
|
Py_SET_TYPE(m, &PrivateModuleType);
|
|
3326
3373
|
return m;
|
|
3327
3374
|
}
|
{private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10/private_attribute_cpp.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: private_attribute_cpp
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.10
|
|
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.
|
|
21
|
+
version='1.4.10',
|
|
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
|
+
)
|
|
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-1.4.8 → private_attribute_cpp-1.4.10}/tests/test_class_private_attrs.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{private_attribute_cpp-1.4.8 → private_attribute_cpp-1.4.10}/tests/test_private_inheritance.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|