Skip to content

Commit f8d10c5

Browse files
hroncokgaborbernat
authored andcommitted
Use tomllib from the standard library on Python 3.11+
Fallback to tomli, which has the same API. Fixes tox-dev#2462
1 parent 3d67ccc commit f8d10c5

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ install_requires =
3939
pluggy>=0.12.0
4040
py>=1.4.17
4141
six>=1.14.0 # required when virtualenv>=20
42-
toml>=0.9.4
42+
tomli;python_version<"3.11"
4343
virtualenv!=20.0.0,!=20.0.1,!=20.0.2,!=20.0.3,!=20.0.4,!=20.0.5,!=20.0.6,!=20.0.7,>=16.0.0
4444
colorama>=0.4.1 ;platform_system=="Windows"
4545
importlib-metadata>=0.12;python_version<"3.8"

src/tox/config/__init__.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020
import pluggy
2121
import py
2222
import six
23-
import toml
23+
24+
if sys.version_info >= (3, 11):
25+
import tomllib
26+
else:
27+
import tomli as tomllib
28+
2429
from packaging import requirements
2530
from packaging.utils import canonicalize_name
2631
from packaging.version import Version
@@ -304,8 +309,8 @@ def parseconfig(args, plugins=()):
304309

305310

306311
def get_py_project_toml(path):
307-
with io.open(str(path), encoding="UTF-8") as file_handler:
308-
config_data = toml.load(file_handler)
312+
with io.open(str(path), mode="rb") as file_handler:
313+
config_data = tomllib.load(file_handler)
309314
return config_data
310315

311316

0 commit comments

Comments
 (0)