@@ -70,7 +70,7 @@ def __init__(
7070
7171 super ().__init__ ()
7272
73- self .mode , self ._readable , self ._writable = parse_mode (mode )
73+ self ._mode , self ._readable , self ._writable = parse_mode (mode )
7474
7575 # create strategy
7676 if block_read_strategy is None :
@@ -83,7 +83,7 @@ def __init__(
8383 # get fileobj
8484 if isinstance (filename , (str , bytes , os .PathLike )):
8585 # pylint: disable=consider-using-with, unspecified-encoding
86- self .fileobj = cast (BinaryIO , open (filename , self .mode + "b" ))
86+ self .fileobj = cast (BinaryIO , open (filename , self ._mode + "b" ))
8787 self ._close_fileobj = True
8888 elif hasattr (filename , "read" ): # weak check but better than nothing
8989 self .fileobj = filename
@@ -99,18 +99,18 @@ def __init__(
9999 raise ValueError ("filename is not writable" )
100100
101101 # init
102- if self .mode [0 ] in "wx" :
102+ if self ._mode [0 ] in "wx" :
103103 self .fileobj .truncate (0 )
104104 if self ._readable :
105105 self ._init_parse ()
106- if self .mode [0 ] == "r" and not self ._fileobjs :
106+ if self ._mode [0 ] == "r" and not self ._fileobjs :
107107 raise XZError ("file: no streams" )
108108
109109 self .check = check if check != - 1 else DEFAULT_CHECK
110110 self .preset = preset
111111 self .filters = filters
112112
113- self ._close_check_empty = self .mode [0 ] != "r"
113+ self ._close_check_empty = self ._mode [0 ] != "r"
114114
115115 @property
116116 def _last_stream (self ) -> Optional [XZStream ]:
@@ -122,6 +122,10 @@ def _last_stream(self) -> Optional[XZStream]:
122122 preset : _LZMAPresetType = proxy_property ("preset" , "_last_stream" )
123123 filters : _LZMAFiltersType = proxy_property ("filters" , "_last_stream" )
124124
125+ @property
126+ def mode (self ) -> str :
127+ return self ._mode
128+
125129 def readable (self ) -> bool :
126130 return self ._readable
127131
0 commit comments