Skip to content

Commit f504766

Browse files
committed
pythongh-89336: Remove configparser 3.12 deprecations.
1 parent ebb37fc commit f504766

File tree

3 files changed

+3
-68
lines changed

3 files changed

+3
-68
lines changed

Doc/library/configparser.rst

-26
Original file line numberDiff line numberDiff line change
@@ -1206,28 +1206,6 @@ ConfigParser Objects
12061206
names is stripped before :meth:`optionxform` is called.
12071207

12081208

1209-
.. method:: readfp(fp, filename=None)
1210-
1211-
.. deprecated:: 3.2
1212-
Use :meth:`read_file` instead.
1213-
1214-
.. versionchanged:: 3.2
1215-
:meth:`readfp` now iterates on *fp* instead of calling ``fp.readline()``.
1216-
1217-
For existing code calling :meth:`readfp` with arguments which don't
1218-
support iteration, the following generator may be used as a wrapper
1219-
around the file-like object::
1220-
1221-
def readline_generator(fp):
1222-
line = fp.readline()
1223-
while line:
1224-
yield line
1225-
line = fp.readline()
1226-
1227-
Instead of ``parser.readfp(fp)`` use
1228-
``parser.read_file(readline_generator(fp))``.
1229-
1230-
12311209
.. data:: MAX_INTERPOLATION_DEPTH
12321210

12331211
The maximum depth for recursive interpolation for :meth:`get` when the *raw*
@@ -1361,10 +1339,6 @@ Exceptions
13611339

13621340
Exception raised when errors occur attempting to parse a file.
13631341

1364-
.. versionchanged:: 3.2
1365-
The ``filename`` attribute and :meth:`__init__` argument were renamed to
1366-
``source`` for consistency.
1367-
13681342

13691343
.. rubric:: Footnotes
13701344

Lib/configparser.py

-42
Original file line numberDiff line numberDiff line change
@@ -312,26 +312,6 @@ def __init__(self, source=None, filename=None):
312312
self.errors = []
313313
self.args = (source, )
314314

315-
@property
316-
def filename(self):
317-
"""Deprecated, use `source'."""
318-
warnings.warn(
319-
"The 'filename' attribute will be removed in Python 3.12. "
320-
"Use 'source' instead.",
321-
DeprecationWarning, stacklevel=2
322-
)
323-
return self.source
324-
325-
@filename.setter
326-
def filename(self, value):
327-
"""Deprecated, user `source'."""
328-
warnings.warn(
329-
"The 'filename' attribute will be removed in Python 3.12. "
330-
"Use 'source' instead.",
331-
DeprecationWarning, stacklevel=2
332-
)
333-
self.source = value
334-
335315
def append(self, lineno, line):
336316
self.errors.append((lineno, line))
337317
self.message += '\n\t[line %2d]: %s' % (lineno, line)
@@ -768,15 +748,6 @@ def read_dict(self, dictionary, source='<dict>'):
768748
elements_added.add((section, key))
769749
self.set(section, key, value)
770750

771-
def readfp(self, fp, filename=None):
772-
"""Deprecated, use read_file instead."""
773-
warnings.warn(
774-
"This method will be removed in Python 3.12. "
775-
"Use 'parser.read_file()' instead.",
776-
DeprecationWarning, stacklevel=2
777-
)
778-
self.read_file(fp, source=filename)
779-
780751
def get(self, section, option, *, raw=False, vars=None, fallback=_UNSET):
781752
"""Get an option value for a given section.
782753
@@ -1239,19 +1210,6 @@ def _read_defaults(self, defaults):
12391210
self._interpolation = hold_interpolation
12401211

12411212

1242-
class SafeConfigParser(ConfigParser):
1243-
"""ConfigParser alias for backwards compatibility purposes."""
1244-
1245-
def __init__(self, *args, **kwargs):
1246-
super().__init__(*args, **kwargs)
1247-
warnings.warn(
1248-
"The SafeConfigParser class has been renamed to ConfigParser "
1249-
"in Python 3.2. This alias will be removed in Python 3.12."
1250-
" Use ConfigParser directly instead.",
1251-
DeprecationWarning, stacklevel=2
1252-
)
1253-
1254-
12551213
class SectionProxy(MutableMapping):
12561214
"""A proxy for a single section from a parser."""
12571215

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The ``configparser`` module APIs deprecated to be removed in 3.12 have been
2+
removed: The ``SafeConfigParser`` class alias, the ``ParsingError.filename``
3+
property, and the ``ConfigParser.readfp`` method have all been removed.

0 commit comments

Comments
 (0)