private-attribute-cpp 1.4.3__tar.gz → 1.4.4__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.3/private_attribute_cpp.egg-info → private_attribute_cpp-1.4.4}/PKG-INFO +1 -1
- {private_attribute_cpp-1.4.3 → private_attribute_cpp-1.4.4}/private_attribute.cpp +34 -4
- {private_attribute_cpp-1.4.3 → private_attribute_cpp-1.4.4}/private_attribute.pyi +9 -9
- {private_attribute_cpp-1.4.3 → private_attribute_cpp-1.4.4/private_attribute_cpp.egg-info}/PKG-INFO +1 -1
- {private_attribute_cpp-1.4.3 → private_attribute_cpp-1.4.4}/setup.py +1 -1
- {private_attribute_cpp-1.4.3 → private_attribute_cpp-1.4.4}/LICENSE +0 -0
- {private_attribute_cpp-1.4.3 → private_attribute_cpp-1.4.4}/MANIFEST.in +0 -0
- {private_attribute_cpp-1.4.3 → private_attribute_cpp-1.4.4}/README.md +0 -0
- {private_attribute_cpp-1.4.3 → private_attribute_cpp-1.4.4}/picosha2.h +0 -0
- {private_attribute_cpp-1.4.3 → private_attribute_cpp-1.4.4}/private_attribute_cpp.egg-info/SOURCES.txt +0 -0
- {private_attribute_cpp-1.4.3 → private_attribute_cpp-1.4.4}/private_attribute_cpp.egg-info/dependency_links.txt +0 -0
- {private_attribute_cpp-1.4.3 → private_attribute_cpp-1.4.4}/private_attribute_cpp.egg-info/not-zip-safe +0 -0
- {private_attribute_cpp-1.4.3 → private_attribute_cpp-1.4.4}/private_attribute_cpp.egg-info/top_level.txt +0 -0
- {private_attribute_cpp-1.4.3 → private_attribute_cpp-1.4.4}/setup.cfg +0 -0
{private_attribute_cpp-1.4.3/private_attribute_cpp.egg-info → private_attribute_cpp-1.4.4}/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.4
|
|
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
|
|
@@ -231,7 +231,7 @@ generate_private_attr_name(uintptr_t obj_id, const std::string& attr_name)
|
|
|
231
231
|
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ";
|
|
232
232
|
|
|
233
233
|
std::uniform_int_distribution<long long> dist(0, printable_chars.size() - 1);
|
|
234
|
-
|
|
234
|
+
|
|
235
235
|
auto generate_random_ascii = [&](int length) {
|
|
236
236
|
std::string result;
|
|
237
237
|
for(int i = 0; i < length; i++) {
|
|
@@ -2440,7 +2440,13 @@ PrivateAttrType_postprocess(PyObject* new_type, PrivateAttrCreationData& data)
|
|
|
2440
2440
|
analyse_all_code(original_value, ::AllData::type_allowed_code_map[type_id], set);
|
|
2441
2441
|
}
|
|
2442
2442
|
}
|
|
2443
|
-
|
|
2443
|
+
|
|
2444
|
+
// Python >= 3.13, delete the attr "__static_attributes__"
|
|
2445
|
+
#if PY_VERSION_HEX >= 0x030D0000
|
|
2446
|
+
PyDict_DelItemString(type_instance->tp_dict, "__static_attributes__");
|
|
2447
|
+
PyErr_Clear();
|
|
2448
|
+
#endif
|
|
2449
|
+
|
|
2444
2450
|
return true;
|
|
2445
2451
|
}
|
|
2446
2452
|
|
|
@@ -3206,7 +3212,7 @@ static PyMethodDef PrivateModule_methods[] = {
|
|
|
3206
3212
|
static PyTypeObject PrivateModuleType = {
|
|
3207
3213
|
PyVarObject_HEAD_INIT(NULL, 0)
|
|
3208
3214
|
"private_attribute_module", //tp_name
|
|
3209
|
-
PyModule_Type.tp_basicsize + 8, //tp_basicsize size of module object + 8 bytes for
|
|
3215
|
+
PyModule_Type.tp_basicsize + 8, //tp_basicsize size of module object + 8 bytes for basicsize to avoid changing attribute '__class__'
|
|
3210
3216
|
0, //tp_itemsize
|
|
3211
3217
|
0, //tp_dealloc
|
|
3212
3218
|
0, //tp_print
|
|
@@ -3279,14 +3285,38 @@ PyInit_private_attribute(void)
|
|
|
3279
3285
|
PyType_Ready(&PrivateTempType) < 0) {
|
|
3280
3286
|
return NULL;
|
|
3281
3287
|
}
|
|
3282
|
-
|
|
3288
|
+
PyObject* all = PyList_New(0);
|
|
3289
|
+
if (!all) {
|
|
3290
|
+
return NULL;
|
|
3291
|
+
}
|
|
3283
3292
|
PyObject* m = PyModule_Create(&def);
|
|
3284
3293
|
if (!m) {
|
|
3294
|
+
Py_DECREF(all);
|
|
3285
3295
|
return NULL;
|
|
3286
3296
|
}
|
|
3287
3297
|
#ifdef Py_GIL_DISABLED
|
|
3288
3298
|
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
|
|
3289
3299
|
#endif
|
|
3300
|
+
|
|
3301
|
+
PyModule_AddObject(m, "__all__", all);
|
|
3302
|
+
/* all contains:
|
|
3303
|
+
* PrivateWrapProxy
|
|
3304
|
+
* PrivateAttrType
|
|
3305
|
+
* PrivateAttrBase
|
|
3306
|
+
* prepare
|
|
3307
|
+
* postprocess
|
|
3308
|
+
* register_metaclass
|
|
3309
|
+
* ensure_type
|
|
3310
|
+
* ensure_metaclass
|
|
3311
|
+
*/
|
|
3312
|
+
PyList_Append(all, PyUnicode_FromString("PrivateWrapProxy"));
|
|
3313
|
+
PyList_Append(all, PyUnicode_FromString("PrivateAttrType"));
|
|
3314
|
+
PyList_Append(all, PyUnicode_FromString("PrivateAttrBase"));
|
|
3315
|
+
PyList_Append(all, PyUnicode_FromString("prepare"));
|
|
3316
|
+
PyList_Append(all, PyUnicode_FromString("postprocess"));
|
|
3317
|
+
PyList_Append(all, PyUnicode_FromString("register_metaclass"));
|
|
3318
|
+
PyList_Append(all, PyUnicode_FromString("ensure_type"));
|
|
3319
|
+
PyList_Append(all, PyUnicode_FromString("ensure_metaclass"));
|
|
3290
3320
|
Py_SET_TYPE(m, &PrivateModuleType);
|
|
3291
3321
|
return m;
|
|
3292
3322
|
}
|
|
@@ -19,14 +19,14 @@ from typing import Any, TypeVar, Callable, TypedDict, Sequence, Generic
|
|
|
19
19
|
from types import FunctionType
|
|
20
20
|
|
|
21
21
|
# define the dict that must have a key "__private_attrs__" and value must be the sequence of strings
|
|
22
|
-
class
|
|
22
|
+
class _PrivateAttrDict(TypedDict):
|
|
23
23
|
__private_attrs__: Sequence[str]
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
_T = TypeVar('T')
|
|
26
26
|
|
|
27
|
-
class _PrivateWrap(Generic[
|
|
27
|
+
class _PrivateWrap(Generic[_T]):
|
|
28
28
|
@property
|
|
29
|
-
def result(self) ->
|
|
29
|
+
def result(self) -> _T:
|
|
30
30
|
"the final result of decorating"
|
|
31
31
|
...
|
|
32
32
|
|
|
@@ -38,7 +38,7 @@ class _PrivateWrap(Generic[T]):
|
|
|
38
38
|
def __getattr__(self, name: str) -> Any:
|
|
39
39
|
return getattr(self.result, name)
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
_TVar = TypeVar('TVar')
|
|
42
42
|
|
|
43
43
|
class PrivateWrapProxy:
|
|
44
44
|
"""
|
|
@@ -70,13 +70,13 @@ class PrivateWrapProxy:
|
|
|
70
70
|
def my_method(self): ...
|
|
71
71
|
```
|
|
72
72
|
"""
|
|
73
|
-
def __init__(self, decorator: Callable[[
|
|
74
|
-
def __call__(self, func:
|
|
73
|
+
def __init__(self, decorator: Callable[[_TVar], _T], orig: _PrivateWrap[Any]|None = None, /) -> None: ...
|
|
74
|
+
def __call__(self, func: _TVar, /) -> _PrivateWrap[_T]: ...
|
|
75
75
|
|
|
76
76
|
class PrivateAttrType(type):
|
|
77
77
|
"metaclass for private attributes"
|
|
78
78
|
def __new__(cls, name: str, bases: tuple,
|
|
79
|
-
attrs:
|
|
79
|
+
attrs: _PrivateAttrDict, /,
|
|
80
80
|
private_func: Callable[[int, str], str]|None = None) -> PrivateAttrType: ...
|
|
81
81
|
|
|
82
82
|
class PrivateAttrBase(metaclass=PrivateAttrType):
|
|
@@ -95,7 +95,7 @@ class _PrivateTemp:
|
|
|
95
95
|
@property
|
|
96
96
|
def kwds(self) -> dict[str, Any]: ...
|
|
97
97
|
|
|
98
|
-
def prepare(name: str, bases: tuple, attrs:
|
|
98
|
+
def prepare(name: str, bases: tuple, attrs: _PrivateAttrDict, /, **kwds) -> _PrivateTemp:
|
|
99
99
|
"""
|
|
100
100
|
function for custom metaclass to create private attributes class.
|
|
101
101
|
|
{private_attribute_cpp-1.4.3 → private_attribute_cpp-1.4.4/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.4
|
|
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
|
|
@@ -19,7 +19,7 @@ readme = open('README.md').read()
|
|
|
19
19
|
|
|
20
20
|
setup(
|
|
21
21
|
name='private_attribute_cpp',
|
|
22
|
-
version='1.4.
|
|
22
|
+
version='1.4.4',
|
|
23
23
|
author="HuangHaoHua",
|
|
24
24
|
author_email="13140752715@example.com",
|
|
25
25
|
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
|