private-attribute-cpp 2.0.5__tar.gz → 2.0.6__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.0.5/private_attribute_cpp.egg-info → private_attribute_cpp-2.0.6}/PKG-INFO +1 -1
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/private_attribute.cpp +65 -36
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6/private_attribute_cpp.egg-info}/PKG-INFO +1 -1
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/setup.py +1 -1
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/LICENSE +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/MANIFEST.in +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/README.md +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/picosha2.h +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/private_attribute.pyi +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/private_attribute_cpp.egg-info/SOURCES.txt +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/private_attribute_cpp.egg-info/dependency_links.txt +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/private_attribute_cpp.egg-info/not-zip-safe +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/private_attribute_cpp.egg-info/top_level.txt +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/setup.cfg +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/tests/test_class_private_attrs.py +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/tests/test_private_abc.py +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/tests/test_private_attrs.py +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/tests/test_private_func.py +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/tests/test_private_inheritance.py +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/tests/test_private_method.py +0 -0
- {private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/tests/test_private_wrap.py +0 -0
{private_attribute_cpp-2.0.5/private_attribute_cpp.egg-info → private_attribute_cpp-2.0.6}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: private_attribute_cpp
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.6
|
|
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
|
|
@@ -488,14 +488,14 @@ id_getattr(const std::string& attr_name, PyObject* obj, PyObject* typ) noexcept
|
|
|
488
488
|
result_typ = Py_TYPE(result);
|
|
489
489
|
if (!result_typ) return NULL;
|
|
490
490
|
}
|
|
491
|
-
bool has_get = false;
|
|
492
491
|
bool has_set = false;
|
|
492
|
+
descrgetfunc get = NULL;
|
|
493
493
|
if (result_typ) {
|
|
494
|
-
|
|
494
|
+
get = result_typ->tp_descr_get;
|
|
495
495
|
has_set = result_typ->tp_descr_set != NULL;
|
|
496
496
|
}
|
|
497
|
-
if (
|
|
498
|
-
PyObject* final_result =
|
|
497
|
+
if (get && has_set) {
|
|
498
|
+
PyObject* final_result = get(result, obj, typ);
|
|
499
499
|
ensure_tp((PyTypeObject*)typ);
|
|
500
500
|
ensure_subclass_tp((PyTypeObject*)typ);
|
|
501
501
|
return final_result;
|
|
@@ -512,9 +512,10 @@ id_getattr(const std::string& attr_name, PyObject* obj, PyObject* typ) noexcept
|
|
|
512
512
|
// if obj is a type, call result.__get__(None, obj)
|
|
513
513
|
if (PyType_Check(obj)) {
|
|
514
514
|
PyTypeObject* obj_type = Py_TYPE(python_obj);
|
|
515
|
-
|
|
515
|
+
auto funcptr = obj_type->tp_descr_get;
|
|
516
|
+
if (funcptr != NULL) {
|
|
516
517
|
lock.unlock();
|
|
517
|
-
return
|
|
518
|
+
return funcptr(python_obj, Py_None, obj);
|
|
518
519
|
}
|
|
519
520
|
}
|
|
520
521
|
Py_XINCREF(python_obj);
|
|
@@ -522,8 +523,8 @@ id_getattr(const std::string& attr_name, PyObject* obj, PyObject* typ) noexcept
|
|
|
522
523
|
}
|
|
523
524
|
}
|
|
524
525
|
|
|
525
|
-
if (
|
|
526
|
-
PyObject* final_result =
|
|
526
|
+
if (get) {
|
|
527
|
+
PyObject* final_result = get(result, obj, typ);
|
|
527
528
|
ensure_tp((PyTypeObject*)typ);
|
|
528
529
|
ensure_subclass_tp((PyTypeObject*)typ);
|
|
529
530
|
return final_result;
|
|
@@ -554,8 +555,9 @@ type_getattr(PyObject* typ, const std::string& attr_name) noexcept
|
|
|
554
555
|
}
|
|
555
556
|
if (result) {
|
|
556
557
|
PyTypeObject* type = Py_TYPE(result);
|
|
557
|
-
|
|
558
|
-
|
|
558
|
+
auto funcptr = type->tp_descr_get;
|
|
559
|
+
if (funcptr) {
|
|
560
|
+
PyObject* final_result = funcptr(result, Py_None, (PyObject*)type);
|
|
559
561
|
ensure_tp((PyTypeObject*)type);
|
|
560
562
|
ensure_subclass_tp((PyTypeObject*)type);
|
|
561
563
|
return final_result;
|
|
@@ -621,8 +623,9 @@ id_setattr(const std::string& attr_name, PyObject* obj, PyObject* typ, PyObject*
|
|
|
621
623
|
}
|
|
622
624
|
if (result) {
|
|
623
625
|
PyTypeObject* type = Py_TYPE(result);
|
|
624
|
-
|
|
625
|
-
|
|
626
|
+
auto funcptr = type->tp_descr_set;
|
|
627
|
+
if (funcptr) {
|
|
628
|
+
if (funcptr(result, obj, value) < 0) {
|
|
626
629
|
return -1;
|
|
627
630
|
}
|
|
628
631
|
return 0;
|
|
@@ -751,8 +754,9 @@ id_delattr(const std::string& attr_name, PyObject* obj, PyObject* typ) noexcept
|
|
|
751
754
|
}
|
|
752
755
|
if (result) {
|
|
753
756
|
PyTypeObject* type = Py_TYPE(result);
|
|
754
|
-
|
|
755
|
-
|
|
757
|
+
auto funcptr = type->tp_descr_set;
|
|
758
|
+
if (funcptr) {
|
|
759
|
+
if (funcptr(result, result, NULL) < 0) {
|
|
756
760
|
return -1;
|
|
757
761
|
}
|
|
758
762
|
return 0;
|
|
@@ -920,12 +924,12 @@ static PyObject*
|
|
|
920
924
|
PrivateWrap_qualname(PyObject* obj, void* /*closure*/) noexcept
|
|
921
925
|
{
|
|
922
926
|
if (!obj) {
|
|
923
|
-
return PyUnicode_InternFromString("_PrivateWrap");
|
|
927
|
+
return PyUnicode_InternFromString("private_attribute._PrivateWrap");
|
|
924
928
|
}
|
|
925
929
|
PyObject* qualname = PyObject_GetAttrString(((PrivateWrapObject*)obj)->result, "__qualname__");
|
|
926
930
|
if (!qualname) {
|
|
927
931
|
PyErr_Clear();
|
|
928
|
-
return PyUnicode_InternFromString("_PrivateWrap");
|
|
932
|
+
return PyUnicode_InternFromString("private_attribute._PrivateWrap");
|
|
929
933
|
}
|
|
930
934
|
return qualname;
|
|
931
935
|
}
|
|
@@ -1012,8 +1016,9 @@ static PyObject*
|
|
|
1012
1016
|
PrivateWrap_descrget(PyObject* obj, PyObject* name, PyObject* cls) noexcept
|
|
1013
1017
|
{
|
|
1014
1018
|
PyObject* result = ((PrivateWrapObject*)obj)->result;
|
|
1015
|
-
|
|
1016
|
-
|
|
1019
|
+
auto funcptr = Py_TYPE(result)->tp_descr_get;
|
|
1020
|
+
if (funcptr) {
|
|
1021
|
+
return funcptr(result, name, cls);
|
|
1017
1022
|
} else {
|
|
1018
1023
|
Py_INCREF(result);
|
|
1019
1024
|
return result;
|
|
@@ -1024,8 +1029,9 @@ static int
|
|
|
1024
1029
|
PrivateWrap_descrset(PyObject* obj, PyObject* name, PyObject* value) noexcept
|
|
1025
1030
|
{
|
|
1026
1031
|
PyObject* result = ((PrivateWrapObject*)obj)->result;
|
|
1027
|
-
|
|
1028
|
-
|
|
1032
|
+
auto funcptr = Py_TYPE(result)->tp_descr_set;
|
|
1033
|
+
if (funcptr) {
|
|
1034
|
+
return funcptr(result, name, value);
|
|
1029
1035
|
} else {
|
|
1030
1036
|
PyErr_SetString(PyExc_AttributeError, "attribute is not settable");
|
|
1031
1037
|
return -1;
|
|
@@ -3391,6 +3397,11 @@ register_finalize(PyObject* cls) noexcept
|
|
|
3391
3397
|
PrivateAttrType_finalize(cls);
|
|
3392
3398
|
}
|
|
3393
3399
|
|
|
3400
|
+
#define METACLASS_WEAKREF_CALLBACK_REMOVE_ITEM(name) do {\
|
|
3401
|
+
if (::AllData::all_type_##name.find(id) != ::AllData::all_type_##name.end()) {\
|
|
3402
|
+
::AllData::all_type_##name.erase(id);\
|
|
3403
|
+
}\
|
|
3404
|
+
} while (0)
|
|
3394
3405
|
|
|
3395
3406
|
static PyObject*
|
|
3396
3407
|
metaclass_weakref_callback(PyObject* self, PyObject* /*weakref*/) noexcept
|
|
@@ -3408,6 +3419,11 @@ metaclass_weakref_callback(PyObject* self, PyObject* /*weakref*/) noexcept
|
|
|
3408
3419
|
Py_DECREF(it->second);
|
|
3409
3420
|
::AllData::all_register_type_weak_ref.erase(it);
|
|
3410
3421
|
}
|
|
3422
|
+
METACLASS_WEAKREF_CALLBACK_REMOVE_ITEM(getattro);
|
|
3423
|
+
METACLASS_WEAKREF_CALLBACK_REMOVE_ITEM(setattro);
|
|
3424
|
+
METACLASS_WEAKREF_CALLBACK_REMOVE_ITEM(traverse);
|
|
3425
|
+
METACLASS_WEAKREF_CALLBACK_REMOVE_ITEM(clear);
|
|
3426
|
+
METACLASS_WEAKREF_CALLBACK_REMOVE_ITEM(finalize);
|
|
3411
3427
|
|
|
3412
3428
|
Py_RETURN_NONE;
|
|
3413
3429
|
}
|
|
@@ -3664,6 +3680,19 @@ PrivateModule_get_PrivateAttrBase(PyObject* /*self*/, void* /*closure*/) noexcep
|
|
|
3664
3680
|
return PrivateAttrBase;
|
|
3665
3681
|
}
|
|
3666
3682
|
|
|
3683
|
+
static int
|
|
3684
|
+
PyList_AppendString(PyObject* list, const char* str)
|
|
3685
|
+
{
|
|
3686
|
+
PyObject* obj = PyUnicode_InternFromString(str);
|
|
3687
|
+
if (!obj) return -1;
|
|
3688
|
+
if (PyList_Append(list, obj) < 0) {
|
|
3689
|
+
Py_DECREF(obj);
|
|
3690
|
+
return -1;
|
|
3691
|
+
}
|
|
3692
|
+
Py_DECREF(obj);
|
|
3693
|
+
return 0;
|
|
3694
|
+
}
|
|
3695
|
+
|
|
3667
3696
|
static PyObject*
|
|
3668
3697
|
PrivateModule_dir(PyObject* self, PyObject* /*args*/) noexcept
|
|
3669
3698
|
{
|
|
@@ -3674,14 +3703,14 @@ PrivateModule_dir(PyObject* self, PyObject* /*args*/) noexcept
|
|
|
3674
3703
|
Py_DECREF(parent_dir);
|
|
3675
3704
|
return NULL;
|
|
3676
3705
|
}
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3706
|
+
PyList_AppendString(attr_list, "PrivateWrapProxy");
|
|
3707
|
+
PyList_AppendString(attr_list, "PrivateAttrType");
|
|
3708
|
+
PyList_AppendString(attr_list, "PrivateAttrBase");
|
|
3709
|
+
PyList_AppendString(attr_list, "prepare");
|
|
3710
|
+
PyList_AppendString(attr_list, "postprocess");
|
|
3711
|
+
PyList_AppendString(attr_list, "register_metaclass");
|
|
3712
|
+
PyList_AppendString(attr_list, "ensure_type");
|
|
3713
|
+
PyList_AppendString(attr_list, "ensure_metaclass");
|
|
3685
3714
|
PyObject* result = PySequence_Concat(parent_dir, attr_list);
|
|
3686
3715
|
Py_DECREF(parent_dir);
|
|
3687
3716
|
Py_DECREF(attr_list);
|
|
@@ -3942,14 +3971,14 @@ PyInit_private_attribute(void) noexcept
|
|
|
3942
3971
|
* ensure_type
|
|
3943
3972
|
* ensure_metaclass
|
|
3944
3973
|
*/
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3974
|
+
PyList_AppendString(all, "PrivateWrapProxy");
|
|
3975
|
+
PyList_AppendString(all, "PrivateAttrType");
|
|
3976
|
+
PyList_AppendString(all, "PrivateAttrBase");
|
|
3977
|
+
PyList_AppendString(all, "prepare");
|
|
3978
|
+
PyList_AppendString(all, "postprocess");
|
|
3979
|
+
PyList_AppendString(all, "register_metaclass");
|
|
3980
|
+
PyList_AppendString(all, "ensure_type");
|
|
3981
|
+
PyList_AppendString(all, "ensure_metaclass");
|
|
3953
3982
|
Py_SET_TYPE(m, &PrivateModuleType);
|
|
3954
3983
|
|
|
3955
3984
|
// Eagerly create PrivateAttrBase so that CPython's subtype_traverse /
|
{private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6/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: 2.0.
|
|
3
|
+
Version: 2.0.6
|
|
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='2.0.
|
|
21
|
+
version='2.0.6',
|
|
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
|
|
File without changes
|
|
File without changes
|
{private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/tests/test_class_private_attrs.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{private_attribute_cpp-2.0.5 → private_attribute_cpp-2.0.6}/tests/test_private_inheritance.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|