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
9150b6b7
Commit
9150b6b7
authored
Jan 28, 2019
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefer native strings on Python 2 when reading config files. Fixes #1653.
parent
f7447817
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletion
+21
-1
setuptools/dist.py
setuptools/dist.py
+21
-1
No files found.
setuptools/dist.py
View file @
9150b6b7
...
...
@@ -603,7 +603,7 @@ class Distribution(_Distribution):
for
opt
in
options
:
if
opt
!=
'__name__'
and
opt
not
in
ignore_options
:
val
=
parser
.
get
(
section
,
opt
)
val
=
self
.
_try_str
(
parser
.
get
(
section
,
opt
)
)
opt
=
opt
.
replace
(
'-'
,
'_'
)
opt_dict
[
opt
]
=
(
filename
,
val
)
...
...
@@ -627,6 +627,26 @@ class Distribution(_Distribution):
except
ValueError
as
msg
:
raise
DistutilsOptionError
(
msg
)
@
staticmethod
def
_try_str
(
val
):
"""
On Python 2, much of distutils relies on string values being of
type 'str' (bytes) and not unicode text. If the value can be safely
encoded to bytes using the default encoding, prefer that.
Why the default encoding? Because that value can be implicitly
decoded back to text if needed.
Ref #1653
"""
if
six
.
PY3
:
return
val
try
:
return
val
.
encode
()
except
UnicodeEncodeError
:
pass
return
val
def
_set_command_options
(
self
,
command_obj
,
option_dict
=
None
):
"""
Set the options for 'command_obj' from 'option_dict'. Basically
...
...
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