Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions Lib/configparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,18 @@
between keys and values are surrounded by spaces.
"""

from collections.abc import MutableMapping
# Do not import dataclasses; overhead is unacceptable (gh-117703)

from collections.abc import Iterable, MutableMapping
from collections import ChainMap as _ChainMap
import contextlib
from dataclasses import dataclass, field
import functools
import io
import itertools
import os
import re
import sys
from typing import Iterable
import types

__all__ = ("NoSectionError", "DuplicateOptionError", "DuplicateSectionError",
"NoOptionError", "InterpolationError", "InterpolationDepthError",
Expand Down Expand Up @@ -538,19 +539,21 @@ def _interpolate_some(self, parser, option, accum, rest, section, map,
"found: %r" % (rest,))


@dataclass
class _ReadState:
elements_added : set[str] = field(default_factory=set)
elements_added : set[str]
cursect : dict[str, str] | None = None
sectname : str | None = None
optname : str | None = None
lineno : int = 0
indent_level : int = 0
errors : list[ParsingError] = field(default_factory=list)
errors : list[ParsingError]

def __init__(self):
self.elements_added = set()
self.errors = list()


@dataclass
class _Prefixes:
class _Prefixes(types.SimpleNamespace):
full : Iterable[str]
inline : Iterable[str]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Largely restored import time performance of configparser by avoiding
dataclasses.