|
59 | 59 | instance. It will be used as the handler for option value |
60 | 60 | pre-processing when using getters. RawConfigParser objects don't do |
61 | 61 | any sort of interpolation, whereas ConfigParser uses an instance of |
62 | | - BasicInterpolation. The library also provides a ``zc.buildbot`` |
| 62 | + BasicInterpolation. The library also provides a ``zc.buildout`` |
63 | 63 | inspired ExtendedInterpolation implementation. |
64 | 64 |
|
65 | 65 | When `converters` is given, it should be a dictionary where each key |
|
149 | 149 | import sys |
150 | 150 | import warnings |
151 | 151 |
|
152 | | -__all__ = ["NoSectionError", "DuplicateOptionError", "DuplicateSectionError", |
| 152 | +__all__ = ("NoSectionError", "DuplicateOptionError", "DuplicateSectionError", |
153 | 153 | "NoOptionError", "InterpolationError", "InterpolationDepthError", |
154 | 154 | "InterpolationMissingOptionError", "InterpolationSyntaxError", |
155 | 155 | "ParsingError", "MissingSectionHeaderError", |
156 | | - "ConfigParser", "SafeConfigParser", "RawConfigParser", |
| 156 | + "ConfigParser", "RawConfigParser", |
157 | 157 | "Interpolation", "BasicInterpolation", "ExtendedInterpolation", |
158 | 158 | "LegacyInterpolation", "SectionProxy", "ConverterMapping", |
159 | | - "DEFAULTSECT", "MAX_INTERPOLATION_DEPTH"] |
| 159 | + "DEFAULTSECT", "MAX_INTERPOLATION_DEPTH") |
160 | 160 |
|
161 | 161 | _default_dict = dict |
162 | 162 | DEFAULTSECT = "DEFAULT" |
@@ -298,41 +298,12 @@ def __init__(self, option, section, rawval): |
298 | 298 | class ParsingError(Error): |
299 | 299 | """Raised when a configuration file does not follow legal syntax.""" |
300 | 300 |
|
301 | | - def __init__(self, source=None, filename=None): |
302 | | - # Exactly one of `source'/`filename' arguments has to be given. |
303 | | - # `filename' kept for compatibility. |
304 | | - if filename and source: |
305 | | - raise ValueError("Cannot specify both `filename' and `source'. " |
306 | | - "Use `source'.") |
307 | | - elif not filename and not source: |
308 | | - raise ValueError("Required argument `source' not given.") |
309 | | - elif filename: |
310 | | - source = filename |
311 | | - Error.__init__(self, 'Source contains parsing errors: %r' % source) |
| 301 | + def __init__(self, source): |
| 302 | + super().__init__(f'Source contains parsing errors: {source!r}') |
312 | 303 | self.source = source |
313 | 304 | self.errors = [] |
314 | 305 | self.args = (source, ) |
315 | 306 |
|
316 | | - @property |
317 | | - def filename(self): |
318 | | - """Deprecated, use `source'.""" |
319 | | - warnings.warn( |
320 | | - "The 'filename' attribute will be removed in Python 3.12. " |
321 | | - "Use 'source' instead.", |
322 | | - DeprecationWarning, stacklevel=2 |
323 | | - ) |
324 | | - return self.source |
325 | | - |
326 | | - @filename.setter |
327 | | - def filename(self, value): |
328 | | - """Deprecated, user `source'.""" |
329 | | - warnings.warn( |
330 | | - "The 'filename' attribute will be removed in Python 3.12. " |
331 | | - "Use 'source' instead.", |
332 | | - DeprecationWarning, stacklevel=2 |
333 | | - ) |
334 | | - self.source = value |
335 | | - |
336 | 307 | def append(self, lineno, line): |
337 | 308 | self.errors.append((lineno, line)) |
338 | 309 | self.message += '\n\t[line %2d]: %s' % (lineno, line) |
@@ -769,15 +740,6 @@ def read_dict(self, dictionary, source='<dict>'): |
769 | 740 | elements_added.add((section, key)) |
770 | 741 | self.set(section, key, value) |
771 | 742 |
|
772 | | - def readfp(self, fp, filename=None): |
773 | | - """Deprecated, use read_file instead.""" |
774 | | - warnings.warn( |
775 | | - "This method will be removed in Python 3.12. " |
776 | | - "Use 'parser.read_file()' instead.", |
777 | | - DeprecationWarning, stacklevel=2 |
778 | | - ) |
779 | | - self.read_file(fp, source=filename) |
780 | | - |
781 | 743 | def get(self, section, option, *, raw=False, vars=None, fallback=_UNSET): |
782 | 744 | """Get an option value for a given section. |
783 | 745 |
|
@@ -1240,19 +1202,6 @@ def _read_defaults(self, defaults): |
1240 | 1202 | self._interpolation = hold_interpolation |
1241 | 1203 |
|
1242 | 1204 |
|
1243 | | -class SafeConfigParser(ConfigParser): |
1244 | | - """ConfigParser alias for backwards compatibility purposes.""" |
1245 | | - |
1246 | | - def __init__(self, *args, **kwargs): |
1247 | | - super().__init__(*args, **kwargs) |
1248 | | - warnings.warn( |
1249 | | - "The SafeConfigParser class has been renamed to ConfigParser " |
1250 | | - "in Python 3.2. This alias will be removed in Python 3.12." |
1251 | | - " Use ConfigParser directly instead.", |
1252 | | - DeprecationWarning, stacklevel=2 |
1253 | | - ) |
1254 | | - |
1255 | | - |
1256 | 1205 | class SectionProxy(MutableMapping): |
1257 | 1206 | """A proxy for a single section from a parser.""" |
1258 | 1207 |
|
|
0 commit comments