Skip to content

Commit 67f534d

Browse files
committed
Merge branch 'develop'
2 parents c04fe2c + 6064ef4 commit 67f534d

File tree

6 files changed

+26
-2
lines changed

6 files changed

+26
-2
lines changed

AUTHORS.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Hugo Lopes Tavares <[email protected]>
9999
Hynek Schlawack <[email protected]>
100100
Ian Bicking <[email protected]>
101101
Ian Cordasco <[email protected]>
102+
102103
Ian Wienand <[email protected]>
103104
Igor Sobreira <[email protected]>
104105
Ilya Baryshev <[email protected]>
@@ -261,6 +262,7 @@ Thomas Smith <[email protected]>
261262
Tim Harder <[email protected]>
262263
tim smith <[email protected]>
263264
Tomer Chachamu <[email protected]>
265+
Tony Zhaocheng Tan <[email protected]>
264266
Toshio Kuratomi <[email protected]>
265267
Travis Swicegood <[email protected]>
266268
Valentin Haenel <[email protected]>

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
**8.1.1 (2016-03-17)**
2+
3+
* Fix regression with non-ascii requirement files on Python 2 and add support
4+
for encoding headers in requirement files (:issue:`3548`, :pull:`3547`).
5+
6+
17
**8.1.0 (2016-03-05)**
28

39
* Implement PEP 513, which adds support for the manylinux1 platform tag,

pip/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
from __future__ import absolute_import
33

4+
import locale
45
import logging
56
import os
67
import optparse
@@ -30,7 +31,7 @@
3031
cmdoptions = pip.cmdoptions
3132

3233
# The version as used in the setup.py and the docs conf.py
33-
__version__ = "8.1.0"
34+
__version__ = "8.1.1"
3435

3536

3637
logger = logging.getLogger(__name__)
@@ -209,6 +210,9 @@ def main(args=None):
209210
sys.stderr.write(os.linesep)
210211
sys.exit(1)
211212

213+
# Needed for locale.getpreferredencoding(False) to work
214+
# in pip.utils.encoding.auto_decode
215+
locale.setlocale(locale.LC_ALL, '')
212216
command = commands_dict[cmd_name](isolated=check_isolated(cmd_args))
213217
return command.main(cmd_args)
214218

pip/cmdoptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def find_links():
247247
default=[],
248248
metavar='url',
249249
help="If a url or path to an html file, then parse for links to "
250-
"archives. If a local path or file:// url that's a directory,"
250+
"archives. If a local path or file:// url that's a directory, "
251251
"then look for archives in the directory listing.")
252252

253253

pip/utils/encoding.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import codecs
22
import locale
3+
import re
34

45

56
BOMS = [
@@ -12,6 +13,8 @@
1213
(codecs.BOM_UTF32_LE, 'utf32-le'),
1314
]
1415

16+
ENCODING_RE = re.compile(b'coding[:=]\s*([-\w.]+)')
17+
1518

1619
def auto_decode(data):
1720
"""Check a bytes string for a BOM to correctly detect the encoding
@@ -20,4 +23,9 @@ def auto_decode(data):
2023
for bom, encoding in BOMS:
2124
if data.startswith(bom):
2225
return data[len(bom):].decode(encoding)
26+
# Lets check the first two lines as in PEP263
27+
for line in data.split(b'\n')[:2]:
28+
if line[0:1] == b'#' and ENCODING_RE.search(line):
29+
encoding = ENCODING_RE.search(line).groups()[0].decode('ascii')
30+
return data.decode(encoding)
2331
return data.decode(locale.getpreferredencoding(False))

tests/unit/test_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,3 +464,7 @@ def test_auto_decode_utf16_le(self):
464464

465465
def test_auto_decode_no_bom(self):
466466
assert auto_decode(b'foobar') == u'foobar'
467+
468+
def test_auto_decode_pep263_headers(self):
469+
latin1_req = u'# coding=latin1\n# Pas trop de café'
470+
assert auto_decode(latin1_req.encode('latin1')) == latin1_req

0 commit comments

Comments
 (0)