Skip to content

Commit 9ce9970

Browse files
committed
Avoid a potential import of fcntl
1 parent 92c3d1f commit 9ce9970

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

bpython/config.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# The MIT License
22
#
33
# Copyright (c) 2009-2015 the bpython authors.
4-
# Copyright (c) 2015-2020 Sebastian Ramacher
4+
# Copyright (c) 2015-2022 Sebastian Ramacher
55
#
66
# Permission is hereby granted, free of charge, to any person obtaining a copy
77
# of this software and associated documentation files (the "Software"), to deal
@@ -35,9 +35,13 @@
3535
from xdg import BaseDirectory
3636

3737
from .autocomplete import AutocompleteModes
38-
from .curtsiesfrontend.parse import CNAMES
3938

4039
default_completion = AutocompleteModes.SIMPLE
40+
# All supported letters for colors for themes
41+
#
42+
# Instead of importing it from .curtsiesfrontend.parse, we define them here to
43+
# avoid a potential import of fcntl on Windows.
44+
COLOR_LETTERS = tuple("krgybmcwd")
4145

4246

4347
class UnknownColorCode(Exception):
@@ -381,7 +385,7 @@ def load_theme(
381385
colors[k] = theme.get("syntax", k)
382386
else:
383387
colors[k] = theme.get("interface", k)
384-
if colors[k].lower() not in CNAMES:
388+
if colors[k].lower() not in COLOR_LETTERS:
385389
raise UnknownColorCode(k, colors[k])
386390

387391
# Check against default theme to see if all values are defined

bpython/curtsiesfrontend/parse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
)
99
from functools import partial
1010

11+
from ..config import COLOR_LETTERS
1112
from ..lazyre import LazyReCompile
1213

1314

1415
COLORS = CURTSIES_COLORS + ("default",)
15-
CNAMES = dict(zip("krgybmcwd", COLORS))
16+
CNAMES = dict(zip(COLOR_LETTERS, COLORS))
1617
# hack for finding the "inverse"
1718
INVERSE_COLORS = {
1819
CURTSIES_COLORS[idx]: CURTSIES_COLORS[

0 commit comments

Comments
 (0)