23
23
_USE_POSIX = True
24
24
25
25
26
- O_CREX = os .O_CREAT | os .O_EXCL
26
+ _O_CREX = os .O_CREAT | os .O_EXCL
27
27
28
28
# FreeBSD (and perhaps other BSDs) limit names to 14 characters.
29
29
_SHM_SAFE_NAME_LENGTH = 14
@@ -73,7 +73,7 @@ def __init__(self, name=None, create=False, size=0):
73
73
if not size >= 0 :
74
74
raise ValueError ("'size' must be a positive integer" )
75
75
if create :
76
- self ._flags = O_CREX | os .O_RDWR
76
+ self ._flags = _O_CREX | os .O_RDWR
77
77
if name is None and not self ._flags & os .O_EXCL :
78
78
raise ValueError ("'name' can only be None if create=True" )
79
79
@@ -228,7 +228,7 @@ def unlink(self):
228
228
_posixshmem .shm_unlink (self .name )
229
229
230
230
231
- encoding = "utf8"
231
+ _encoding = "utf8"
232
232
233
233
class ShareableList :
234
234
"""Pattern for a mutable list-like object shareable via a shared
@@ -251,7 +251,7 @@ class ShareableList:
251
251
_alignment = 8
252
252
_back_transforms_mapping = {
253
253
0 : lambda value : value , # int, float, bool
254
- 1 : lambda value : value .rstrip (b'\x00 ' ).decode (encoding ), # str
254
+ 1 : lambda value : value .rstrip (b'\x00 ' ).decode (_encoding ), # str
255
255
2 : lambda value : value .rstrip (b'\x00 ' ), # bytes
256
256
3 : lambda _value : None , # None
257
257
}
@@ -305,7 +305,7 @@ def __init__(self, sequence=None, *, name=None):
305
305
self .shm = SharedMemory (name , create = True , size = requested_size )
306
306
307
307
if sequence is not None :
308
- _enc = encoding
308
+ _enc = _encoding
309
309
struct .pack_into (
310
310
"q" + self ._format_size_metainfo ,
311
311
self .shm .buf ,
@@ -352,7 +352,7 @@ def _get_packing_format(self, position):
352
352
self ._offset_packing_formats + position * 8
353
353
)[0 ]
354
354
fmt = v .rstrip (b'\x00 ' )
355
- fmt_as_str = fmt .decode (encoding )
355
+ fmt_as_str = fmt .decode (_encoding )
356
356
357
357
return fmt_as_str
358
358
@@ -384,7 +384,7 @@ def _set_packing_format_and_transform(self, position, fmt_as_str, value):
384
384
"8s" ,
385
385
self .shm .buf ,
386
386
self ._offset_packing_formats + position * 8 ,
387
- fmt_as_str .encode (encoding )
387
+ fmt_as_str .encode (_encoding )
388
388
)
389
389
390
390
transform_code = self ._extract_recreation_code (value )
@@ -437,7 +437,7 @@ def __setitem__(self, position, value):
437
437
new_format ,
438
438
value
439
439
)
440
- value = value .encode (encoding ) if isinstance (value , str ) else value
440
+ value = value .encode (_encoding ) if isinstance (value , str ) else value
441
441
struct .pack_into (new_format , self .shm .buf , offset , value )
442
442
443
443
def __reduce__ (self ):
0 commit comments