2424# Value 2 no longer used
2525_MODE_WRITE = 3
2626
27+ _sentinel = object ()
28+
2729
2830class BZ2File (_compression .BaseStream ):
2931
@@ -36,7 +38,7 @@ class BZ2File(_compression.BaseStream):
3638 returned as bytes, and data to be written should be given as bytes.
3739 """
3840
39- def __init__ (self , filename , mode = "r" , buffering = None , compresslevel = 9 ):
41+ def __init__ (self , filename , mode = "r" , buffering = _sentinel , compresslevel = 9 ):
4042 """Open a bzip2-compressed file.
4143
4244 If filename is a str, bytes, or PathLike object, it gives the
@@ -47,7 +49,7 @@ def __init__(self, filename, mode="r", buffering=None, compresslevel=9):
4749 'x' for creating exclusively, or 'a' for appending. These can
4850 equivalently be given as 'rb', 'wb', 'xb', and 'ab'.
4951
50- buffering is ignored. Its use is deprecated.
52+ buffering is ignored since Python 3.0 . Its use is deprecated.
5153
5254 If mode is 'w', 'x' or 'a', compresslevel can be a number between 1
5355 and 9 specifying the level of compression: 1 produces the least
@@ -63,9 +65,11 @@ def __init__(self, filename, mode="r", buffering=None, compresslevel=9):
6365 self ._closefp = False
6466 self ._mode = _MODE_CLOSED
6567
66- if buffering is not None :
67- warnings .warn ("Use of 'buffering' argument is deprecated" ,
68- DeprecationWarning )
68+ if buffering is not _sentinel :
69+ warnings .warn ("Use of 'buffering' argument is deprecated and ignored"
70+ "since Python 3.0." ,
71+ DeprecationWarning ,
72+ stacklevel = 2 )
6973
7074 if not (1 <= compresslevel <= 9 ):
7175 raise ValueError ("compresslevel must be between 1 and 9" )
0 commit comments