Skip to content

Commit 2532ac6

Browse files
bluetechpradyunsg
authored andcommitted
Patch out import chardet from pygments
1 parent 3c07331 commit 2532ac6

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

src/pip/_vendor/pygments/lexer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ def _preprocess_lexer_input(self, text):
207207
text, _ = guess_decode(text)
208208
elif self.encoding == 'chardet':
209209
try:
210-
import chardet
210+
# pip vendoring note: this code is not reachable by pip,
211+
# removed import of chardet to make it clear.
212+
raise ImportError('chardet is not vendored by pip')
211213
except ImportError as e:
212214
raise ImportError('To enable chardet encoding guessing, '
213215
'please install the chardet library '

tools/vendoring/patches/pygments.patch

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ This patch mainly handles tweaking imports into a form that can be transformed
22
to import from the vendored namespace.
33

44
diff --git a/src/pip/_vendor/pygments/cmdline.py b/src/pip/_vendor/pygments/cmdline.py
5-
index d9a0fdc8b..db6de0cd3 100644
5+
index 435231e6..b75a9d7f 100644
66
--- a/src/pip/_vendor/pygments/cmdline.py
77
+++ b/src/pip/_vendor/pygments/cmdline.py
8-
@@ -410,11 +410,11 @@ def is_only_option(opt):
8+
@@ -469,11 +469,11 @@ def main_inner(parser, argns):
99
outfile = UnclosingTextIOWrapper(outfile, encoding=fmter.encoding)
1010
fmter.encoding = None
1111
try:
@@ -17,26 +17,41 @@ index d9a0fdc8b..db6de0cd3 100644
1717
- outfile = colorama.initialise.wrap_stream(
1818
+ outfile = colorama_initialise.wrap_stream(
1919
outfile, convert=None, strip=None, autoreset=False, wrap=True)
20-
20+
2121
# When using the LaTeX formatter and the option `escapeinside` is
2222
diff --git a/src/pip/_vendor/pygments/__main__.py b/src/pip/_vendor/pygments/__main__.py
23-
index c6e2517df..76255b525 100644
23+
index 5eb2c747..04997f49 100644
2424
--- a/src/pip/_vendor/pygments/__main__.py
2525
+++ b/src/pip/_vendor/pygments/__main__.py
2626
@@ -9,9 +9,9 @@
2727
"""
28-
28+
2929
import sys
3030
-import pygments.cmdline
3131
+from pygments.cmdline import main
32-
32+
3333
try:
3434
- sys.exit(pygments.cmdline.main(sys.argv))
3535
+ sys.exit(main(sys.argv))
3636
except KeyboardInterrupt:
3737
sys.exit(1)
38+
diff --git a/src/pip/_vendor/pygments/lexer.py b/src/pip/_vendor/pygments/lexer.py
39+
index eb5403e7..837ada12 100644
40+
--- a/src/pip/_vendor/pygments/lexer.py
41+
+++ b/src/pip/_vendor/pygments/lexer.py
42+
@@ -207,7 +207,9 @@ class Lexer(metaclass=LexerMeta):
43+
text, _ = guess_decode(text)
44+
elif self.encoding == 'chardet':
45+
try:
46+
- import chardet
47+
+ # pip vendoring note: this code is not reachable by pip,
48+
+ # removed import of chardet to make it clear.
49+
+ raise ImportError('chardet is not vendored by pip')
50+
except ImportError as e:
51+
raise ImportError('To enable chardet encoding guessing, '
52+
'please install the chardet library '
3853
diff --git a/src/pip/_vendor/pygments/sphinxext.py b/src/pip/_vendor/pygments/sphinxext.py
39-
index 3ea2e36e1..23c19504c 100644
54+
index f935688f..e2986361 100644
4055
--- a/src/pip/_vendor/pygments/sphinxext.py
4156
+++ b/src/pip/_vendor/pygments/sphinxext.py
4257
@@ -91,7 +91,7 @@ class PygmentsDoc(Directive):

0 commit comments

Comments
 (0)