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

Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Remove duplicate section creation code
  • Loading branch information
PalmtopTiger committed Nov 24, 2024
commit ffa2ea900d293c14f040c16c484c8feccba8a934
14 changes: 4 additions & 10 deletions Lib/configparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,13 +1105,7 @@ def _handle_continuation_line(self, st, line, fpname):
def _handle_rest(self, st, line, fpname):
# a section header or option header?
if self._allow_unnamed_section and st.cursect is None:
st.sectname = UNNAMED_SECTION
if st.sectname in self._sections:
st.cursect = self._sections[st.sectname]
else:
st.cursect = self._dict()
self._sections[st.sectname] = st.cursect
self._proxies[st.sectname] = SectionProxy(self, st.sectname)
self._handle_header(st, UNNAMED_SECTION, fpname)

st.indent_level = st.cur_indent_level
# is it a section header?
Expand All @@ -1120,10 +1114,10 @@ def _handle_rest(self, st, line, fpname):
if not mo and st.cursect is None:
raise MissingSectionHeaderError(fpname, st.lineno, line)

self._handle_header(st, mo, fpname) if mo else self._handle_option(st, line, fpname)
self._handle_header(st, mo.group('header'), fpname) if mo else self._handle_option(st, line, fpname)

def _handle_header(self, st, mo, fpname):
st.sectname = mo.group('header')
def _handle_header(self, st, sectname, fpname):
st.sectname = sectname
if st.sectname in self._sections:
if self._strict and st.sectname in st.elements_added:
raise DuplicateSectionError(st.sectname, fpname,
Expand Down