2323 _USE_POSIX = True
2424
2525
26- O_CREX = os .O_CREAT | os .O_EXCL
26+ _O_CREX = os .O_CREAT | os .O_EXCL
2727
2828# FreeBSD (and perhaps other BSDs) limit names to 14 characters.
2929_SHM_SAFE_NAME_LENGTH = 14
@@ -73,7 +73,7 @@ def __init__(self, name=None, create=False, size=0):
7373 if not size >= 0 :
7474 raise ValueError ("'size' must be a positive integer" )
7575 if create :
76- self ._flags = O_CREX | os .O_RDWR
76+ self ._flags = _O_CREX | os .O_RDWR
7777 if name is None and not self ._flags & os .O_EXCL :
7878 raise ValueError ("'name' can only be None if create=True" )
7979
@@ -228,7 +228,7 @@ def unlink(self):
228228 _posixshmem .shm_unlink (self .name )
229229
230230
231- encoding = "utf8"
231+ _encoding = "utf8"
232232
233233class ShareableList :
234234 """Pattern for a mutable list-like object shareable via a shared
@@ -251,7 +251,7 @@ class ShareableList:
251251 _alignment = 8
252252 _back_transforms_mapping = {
253253 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
255255 2 : lambda value : value .rstrip (b'\x00 ' ), # bytes
256256 3 : lambda _value : None , # None
257257 }
@@ -305,7 +305,7 @@ def __init__(self, sequence=None, *, name=None):
305305 self .shm = SharedMemory (name , create = True , size = requested_size )
306306
307307 if sequence is not None :
308- _enc = encoding
308+ _enc = _encoding
309309 struct .pack_into (
310310 "q" + self ._format_size_metainfo ,
311311 self .shm .buf ,
@@ -352,7 +352,7 @@ def _get_packing_format(self, position):
352352 self ._offset_packing_formats + position * 8
353353 )[0 ]
354354 fmt = v .rstrip (b'\x00 ' )
355- fmt_as_str = fmt .decode (encoding )
355+ fmt_as_str = fmt .decode (_encoding )
356356
357357 return fmt_as_str
358358
@@ -384,7 +384,7 @@ def _set_packing_format_and_transform(self, position, fmt_as_str, value):
384384 "8s" ,
385385 self .shm .buf ,
386386 self ._offset_packing_formats + position * 8 ,
387- fmt_as_str .encode (encoding )
387+ fmt_as_str .encode (_encoding )
388388 )
389389
390390 transform_code = self ._extract_recreation_code (value )
@@ -437,7 +437,7 @@ def __setitem__(self, position, value):
437437 new_format ,
438438 value
439439 )
440- value = value .encode (encoding ) if isinstance (value , str ) else value
440+ value = value .encode (_encoding ) if isinstance (value , str ) else value
441441 struct .pack_into (new_format , self .shm .buf , offset , value )
442442
443443 def __reduce__ (self ):
0 commit comments