summaryrefslogtreecommitdiffstats
path: root/Lib/configparser.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-117348: restore import time performance of configparser (#117703)Jason R. Coombs2024-04-141-13/+11
| | | Reduces import time by over 50% (10431µs vs 4350µs on Apple M3 Pro).
* gh-117348: Refactored RawConfigParser._read for similicity and ↵Jason R. Coombs2024-03-291-147/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | comprehensibility (#117372) * Extract method for _read_inner, reducing complexity and indentation by 1. * Extract method for _raise_all and yield ParseErrors from _read_inner. Reduces complexity by 1 and reduces touch points for handling errors in _read_inner. * Prefer iterators to splat expansion and literal indexing. * Extract method for _strip_comments. Reduces complexity by 7. * Model the file lines in a class to encapsulate the comment status and cleaned value. * Encapsulate the read state as a dataclass * Extract _handle_continuation_line and _handle_rest methods. Reduces complexity by 8. * Reindent * At least for now, collect errors in the ReadState * Check for missing section header separately. * Extract methods for _handle_header and _handle_option. Reduces complexity by 6. * Remove unreachable code. Reduces complexity by 4. * Remove unreachable branch * Handle error condition early. Reduces complexity by 1. * Add blurb * Move _raise_all to ParsingError, as its behavior is most closely related to the exception class and not the reader. * Split _strip* into separate methods. * Refactor _strip_full to compute the strip just once and use 'not any' to determine the factor. * Replace use of 'sys.maxsize' with direct computation of the stripped value. * Extract has_comments as a dynamic property. * Implement clean as a cached property. * Model comment prefixes in the RawConfigParser within a prefixes namespace. * Use a regular expression to search for the first match. Avoids mutating variables and tricky logic and over-computing all of the starts when only the first is relevant.
* gh-66449: configparser: Add support for unnamed sections (#117273)Pedro Lacerda2024-03-291-31/+85
| | | Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* gh-116957: configparser: Do post-process values after DuplicateOptionError ↵David Röthlisberger2024-03-191-91/+93
| | | | | | | | | | | (GH-116958) If you catch DuplicateOptionError / DuplicateSectionError when reading a config file (the intention is to skip invalid config files) and then attempt to use the ConfigParser instance, any values it *had* read successfully so far, were stored as a list instead of string! Later `get` calls would raise "AttributeError: 'list' object has no attribute 'find'" from somewhere deep in the interpolation code.
* gh-107625: configparser: Raise error if a missing value is continued (GH-107651)Prince Roshan2024-03-061-0/+16
| | | | | Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* Fix typo in configparser module docstring (#105652)litlighilit2023-06-111-1/+1
| | | "zc.buildbot" -> "zc.buildout"
* gh-105407: Remove unused imports in the stdlib (#105411)Victor Stinner2023-06-061-1/+0
|
* gh-104886: Remove deprecated configparser.LegacyInterpolation (#104887)Hugo van Kemenade2023-05-261-48/+1
| | | | Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-100520: Fix `rst` markup in `configparser` docstrings (#100524)Nikita Sobolev2022-12-261-36/+37
|
* gh-89336: Remove configparser APIs that were deprecated for 3.12 (#92503)Gregory P. Smith2022-06-211-56/+5
| | | | | https://github.com/python/cpython/issue/89336: Remove configparser 3.12 deprecations. Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
* bpo-46607: Add DeprecationWarning for LegacyInterpolation, deprecated in ↵Hugo van Kemenade2022-04-051-0/+9
| | | | docs since 3.2 (GH-30927)
* bpo-41086: Add exception for uninstantiated interpolation (configparser) ↵Brian Faherty2022-02-171-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-21062) * Add exception for uninstantiated interpolation (configparser) The current feedback when users try to pass an uninstantiated interpolation into a ConfigParser is an error message that does not help users solve the problem. This current error of `TypeError: before_set() missing 1 required positional argument: 'value'` does not display until the parser is used, which usually results in the assumption that instantiation of the parser was done correctly. The new exception of InterpolationTypeError, will be raised on the line where the ConfigParser is instantiated. This will result in users see the line that has the error in their backtrace for faster debugging. There have been a number of bugs created in the issue tracker, which could have been addressed by: https://bugs.python.org/issue26831 and https://bugs.python.org/issue26469 * 📜🤖 Added by blurb_it. * Replace custom Error with TypeError Per feedback from @iritkatriel, the custom InterpolationTypeError has been dropped in favour of a TypeError with a custom message, and the unittests have been expanded. * More verbose message Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-45173: Keep configparser deprecations until Python 3.12 (GH-30952)Hugo van Kemenade2022-02-021-1/+44
| | | | | | | * Revert "bpo-45173 Remove configparser deprecations" This reverts commit df2284bc416dcccba1125b12af4499c45baabe4f. * bpo-45173: Note these configparser deprecations will be removed in 3.12
* bpo-45173 Remove configparser deprecations (GH-28292)Hugo van Kemenade2021-09-131-44/+1
| | | | | | | In the configparser module, these have been deprecated since Python 3.2: * the SafeConfigParser class, * the filename property of the ParsingError class, * the readfp method of the ConfigParser class,
* bpo-38741: Definition of multiple ']' in header configparser (GH-17129)jsnklln2021-07-131-1/+1
| | | | Co-authored-by: Jason Killen <jason.killen@windsorcircle.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* bpo-41963: document that ConfigParser strips off comments (GH-26197)Jürgen Gmach2021-05-181-1/+4
| | | | Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Laura Gutierrez Funderburk <58710704+lgfunderburk@users.noreply.github.com>
* bpo-43510: Implement PEP 597 opt-in EncodingWarning. (GH-19481)Inada Naoki2021-03-291-0/+1
| | | | | | | | | | | See [PEP 597](https://www.python.org/dev/peps/pep-0597/). * Add `-X warn_default_encoding` and `PYTHONWARNDEFAULTENCODING`. * Add EncodingWarning * Add io.text_encoding() * open(), TextIOWrapper() emits EncodingWarning when encoding is omitted and warn_default_encoding is enabled. * _pyio.TextIOWrapper() uses UTF-8 as fallback default encoding used when failed to import locale module. (used during building Python) * bz2, configparser, gzip, lzma, pathlib, tempfile modules use io.text_encoding(). * What's new entry
* fix typo in configparser doc (GH-12154)Woko2019-03-041-1/+1
|
* bpo-27351: Fix ConfigParser.read() documentation and docstring (GH-8123)Zackery Spytz2018-09-291-4/+4
| | | Switch "list" with "iterable" to match with the implementation.
* bpo-32108: Don't clear configparser values if key is assigned to itself ↵Cheryl Sabella2018-06-121-1/+2
| | | | (GH-7588)
* bpo-33802: Do not interpolate in ConfigParser while reading defaults (GH-7524)Łukasz Langa2018-06-081-2/+10
| | | This solves a regression in logging config due to changes in BPO-23835.
* bpo-33504: Migrate configparser from OrderedDict to dict. (#6819)John Reese2018-06-051-1/+2
| | | | | | With 3.7+, dictionary are ordered by design. Configparser still uses collections.OrderedDict, which is unnecessary. This updates the module to use the standard dict implementation by default, and changes the docs and tests to match.
* bpo-33251: Prevent ConfigParser.items returning items present in vars. (#6446)Chris Bradbury2018-04-231-1/+2
| | | | | | | | * bpo-33251: ConfigParser.items no longer returns items present in vars. Documentation for `ConfigParser.items()` states: 'Items present in vars no longer appear in the result.' This fix aligns behaviour to that specified in the documentation.
* bpo-31307: Make ConfigParser.read() accept bytes objects (GH-3420)Vincent Michel2017-11-021-1/+1
|
* bpo-23835: Restore legacy defaults= behavior for RawConfigParser (#3191)Łukasz Langa2017-08-241-1/+12
| | | | | | | The fix for bpo-23835 fixed ConfigParser behavior in defaults= handling. Unfortunately, it caused a backwards compatibility regression with RawConfigParser objects which allow for non-string values. This commit restores the legacy behavior for RawConfigParser only.
* bpo-23835: Enforce that configparser defaults are strings (#2558)James Tocknell2017-08-211-3/+2
| | | | * Enforce that configparser defaults are strings * Update test_configparser.py
* bpo-29762: More use "raise from None". (#569)Serhiy Storchaka2017-04-051-1/+1
| | | This hides unwanted implementation details from tracebacks.
* bpo-29623: Make PathLike objects work with ConfigParser.read() (#242)David Ellis2017-03-031-1/+4
|
* Fixes #24142: [configparser] always join multiline values to not leave the ↵Łukasz Langa2016-11-261-1/+1
| | | | parser in an invalid state
* Issue #21159: Improve message in configparser.InterpolationMissingOptionError.Robert Collins2015-08-131-15/+14
|\ | | | | | | Patch from Łukasz Langa.
| * Issue #21159: Improve message in configparser.InterpolationMissingOptionError.Robert Collins2015-08-131-15/+14
| | | | | | | | Patch from Łukasz Langa.
* | Closes #18159: ConfigParser getters not available on SectionProxyŁukasz Langa2014-09-151-42/+128
| |
* | Fix #19546: onfigparser exceptions expose implementation details. Patch by ↵Łukasz Langa2014-09-041-6/+6
|/ | | | Claudiu Popa.
* Issue #20363. Fixed BytesWarning triggerred by test suite.Serhiy Storchaka2014-02-061-2/+2
|\ | | | | | | Patch by Berker Peksag.
| * Issue #20363. Fixed BytesWarning triggerred by test suite.Serhiy Storchaka2014-02-061-2/+2
| | | | | | | | Patch by Berker Peksag.
* | Issue #20315: Removed support for backward compatibility with early 2.x ↵Serhiy Storchaka2014-01-201-17/+0
|\ \ | |/ | | | | | | | | | | versions. Removed backward compatibility alias curses.window.nooutrefresh which should be removed in 2.3.
| * Issue #20315: Removed support for backward compatibility with early 2.x ↵Serhiy Storchaka2014-01-201-17/+0
| | | | | | | | versions.
* | Merged fix for issue #18260 from 3.3Łukasz Langa2013-06-231-2/+2
|\ \ | |/
| * Fixed issue #18260: configparser TypeError on source name specified as bytesŁukasz Langa2013-06-231-2/+2
| |
* | fix character index in ExtendedInterpolation's exception messageŁukasz Langa2013-04-231-1/+1
|\ \ | |/
| * fix character index in ExtendedInterpolation's exception messageŁukasz Langa2013-04-231-1/+1
| |
* | Merged section order preservation fix when using `__setitem__` (issue #16820)Łukasz Langa2013-01-011-2/+2
|\ \ | |/
| * configparser: preserve section order when using `__setitem__` (issue #16820)Łukasz Langa2013-01-011-2/+2
| |
* | Merged `parser['DEFAULT'].__setitem__` fix (issue #16820) from 3.3.Łukasz Langa2012-12-311-1/+4
|\ \ | |/
| * Fixes `__setitem__` on parser['DEFAULT'] reported in issue #16820.Łukasz Langa2012-12-311-1/+4
| |
* | Merged `parser.clean()` fix (issue #16820) from 3.2 through 3.3.Łukasz Langa2012-12-311-0/+13
|\ \ | |/
| * Merged `parser.clean()` fix (issue #16820) from 3.2.Łukasz Langa2012-12-311-0/+13
| |\
| | * Fixes `parser.clean()` reported in issue #16820.Łukasz Langa2012-12-311-0/+13
| | |
* | | Merged fix for #15803 from 3.2 through 3.3Łukasz Langa2012-12-311-4/+3
|\ \ \ | |/ /
| * | Merged fix for #15803 from 3.2Łukasz Langa2012-12-311-4/+3
| |\ \ | | |/