python / python/cpython

configparser no longer accept space as a delimiter

オープン
#156,353 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

3.10 3.11 release-blocker stdlib type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug report

Bug description:

Between python 3.14.4 and 3.14.5, python stopped recognising a space as a delimiter.

import configparser
cp=configparser.ConfigParser(delimiters=(' ', '='))
cp.read_string('[all]\nfoo bar=baz')
cp.options('all')

Test using docker on 3.14.4:

$ docker run -it --rm python:3.14.4
Python 3.14.4 (main, May  8 2026, 22:38:20) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import configparser; cp=configparser.ConfigParser(delimiters=(' ', '=')); cp.read_string('[all]\nfoo bar=baz'); cp.options('all')
['foo']

Same test on 3.14.5:

$ docker run -it --rm python:3.14.5
Python 3.14.5 (main, May 20 2026, 02:52:14) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import configparser; cp=configparser.ConfigParser(delimiters=(' ', '=')); cp.read_string('[all]\nfoo bar=baz'); cp.options('all')
['foo bar']

Between 3.13.13 and 3.13.14, the same issue appears.

I dug into Lib/configparser.py and its history a bit and I suspect this might be related to https://github.com/python/cpython/pull/146399, although I did not dig deep enough to be sure this test is valid and has the proper input:

Python 3.14.7 (main, Aug  5 2026, 10:29:49) [Clang 21.0.0 (clang-2100.1.1.101)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> delimiters = (' ', '=')
>>> d = "|".join(re.escape(d) for d in delimiters)
>>> _OPT_NV_TMPL_PRE = r"""
...         (?P<option>.*?)
...         \s*(?:                             # any number of space/tab,
...         (?P<vi>{delim})\s*                 # optionally followed by
...                                            # any of allowed
...                                            # delimiters, followed by any
...                                            # space/tab
...         (?P<value>.*))?$                   # everything up to eol
...         """
>>> _OPT_NV_TMPL_POST = r"""
...         (?P<option>                        # very permissive!
...             (?:(?!{delim})\S)*             # non-delimiter non-whitespace
...             (?:\s+(?:(?!{delim})\S)+)*)    # optionally more words
...         \s*(?:                             # any number of space/tab,
...         (?P<vi>{delim})\s*                 # optionally followed by
...                                            # any of the allowed
...                                            # delimiters, followed by any
...                                            # space/tab
...         (?P<value>.*))?$                   # everything up to eol
...         """
>>> _optcre_pre = re.compile(_OPT_NV_TMPL_PRE.format(delim=d), re.VERBOSE)
>>> _optcre_post = re.compile(_OPT_NV_TMPL_POST.format(delim=d), re.VERBOSE)
>>> _optcre_pre.search('foo bar').groups()
('foo', ' ', 'bar')
>>> _optcre_post.search('foo bar').groups()
('foo bar', None, None)
CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs
  • gh-156382
  • gh-156557
  • gh-156558
  • gh-156559
  • gh-156560
  • gh-156561
  • gh-156562

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Lib/configparser.py から始め、報告書にある Python 3.13.13/3.13.14 または 3.14.4/3.14.5 の例で区切り文字の挙動を再現します。PR 146399 を含むパーサー正規表現の履歴を調査し、リンクされている PR を比較します。スペース区切り文字が以前に文書化されたとおりに解析され、回帰テストのカバレッジでその挙動が検証されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
backend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。