Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
85fa4a6b
Commit
85fa4a6b
authored
Apr 05, 2019
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
When reading config files, require them to be encoded with UTF-8. Fixes #1702.
parent
393809a0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
29 deletions
+11
-29
setuptools/dist.py
setuptools/dist.py
+2
-7
setuptools/tests/test_config.py
setuptools/tests/test_config.py
+9
-22
No files found.
setuptools/dist.py
View file @
85fa4a6b
...
...
@@ -35,7 +35,6 @@ from setuptools.depends import Require
from
setuptools
import
windows_support
from
setuptools.monkey
import
get_unpatched
from
setuptools.config
import
parse_configuration
from
.unicode_utils
import
detect_encoding
import
pkg_resources
__import__
(
'setuptools.extern.packaging.specifiers'
)
...
...
@@ -587,13 +586,9 @@ class Distribution(_Distribution):
parser
=
ConfigParser
()
for
filename
in
filenames
:
with
io
.
open
(
filename
,
'rb'
)
as
fp
:
encoding
=
detect_encoding
(
fp
)
with
io
.
open
(
filename
,
encoding
=
'utf-8'
)
as
reader
:
if
DEBUG
:
self
.
announce
(
" reading %s [%s]"
%
(
filename
,
encoding
or
'locale'
)
)
reader
=
io
.
TextIOWrapper
(
fp
,
encoding
=
encoding
)
self
.
announce
(
" reading {filename}"
.
format
(
**
locals
()))
(
parser
.
read_file
if
six
.
PY3
else
parser
.
readfp
)(
reader
)
for
section
in
parser
.
sections
():
options
=
parser
.
options
(
section
)
...
...
setuptools/tests/test_config.py
View file @
85fa4a6b
...
...
@@ -9,7 +9,6 @@ from mock import patch
from
setuptools.dist
import
Distribution
,
_Distribution
from
setuptools.config
import
ConfigHandler
,
read_configuration
from
setuptools.extern.six.moves
import
configparser
from
setuptools.tests
import
is_ascii
from
.
import
py2_only
,
py3_only
from
.textwrap
import
DALS
...
...
@@ -446,10 +445,6 @@ class TestMetadata:
with
get_dist
(
tmpdir
):
pass
skip_if_not_ascii
=
pytest
.
mark
.
skipif
(
not
is_ascii
,
reason
=
'Test not supported with this locale'
)
@
skip_if_not_ascii
def
test_non_ascii_1
(
self
,
tmpdir
):
fake_env
(
tmpdir
,
...
...
@@ -457,16 +452,6 @@ class TestMetadata:
'description = éàïôñ
\
n
'
,
encoding
=
'utf-8'
)
with
pytest
.
raises
(
UnicodeDecodeError
):
with
get_dist
(
tmpdir
):
pass
def
test_non_ascii_2
(
self
,
tmpdir
):
fake_env
(
tmpdir
,
'# -*- coding: invalid
\
n
'
)
with
pytest
.
raises
(
LookupError
):
with
get_dist
(
tmpdir
):
pass
...
...
@@ -479,7 +464,6 @@ class TestMetadata:
with
get_dist
(
tmpdir
):
pass
@
skip_if_not_ascii
def
test_non_ascii_4
(
self
,
tmpdir
):
fake_env
(
tmpdir
,
...
...
@@ -491,8 +475,10 @@ class TestMetadata:
with
get_dist
(
tmpdir
)
as
dist
:
assert
dist
.
metadata
.
description
==
'éàïôñ'
@
skip_if_not_ascii
def
test_non_ascii_5
(
self
,
tmpdir
):
def
test_not_utf8
(
self
,
tmpdir
):
"""
Config files encoded not in UTF-8 will fail
"""
fake_env
(
tmpdir
,
'# vim: set fileencoding=iso-8859-15 :
\
n
'
...
...
@@ -500,8 +486,9 @@ class TestMetadata:
'description = éàïôñ
\
n
'
,
encoding
=
'iso-8859-15'
)
with
get_dist
(
tmpdir
)
as
dist
:
assert
dist
.
metadata
.
description
==
'éàïôñ'
with
pytest
.
raises
(
UnicodeDecodeError
):
with
get_dist
(
tmpdir
):
pass
class
TestOptions
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment