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
f5cd7f42
Commit
f5cd7f42
authored
Nov 21, 2013
by
philip_thiem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made a more sophisticated encoding heuristic that runs at module load.
parent
52197867
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
1 deletion
+28
-1
setuptools/svn_utils.py
setuptools/svn_utils.py
+28
-1
No files found.
setuptools/svn_utils.py
View file @
f5cd7f42
...
@@ -5,6 +5,7 @@ from distutils import log
...
@@ -5,6 +5,7 @@ from distutils import log
import
xml.dom.pulldom
import
xml.dom.pulldom
import
shlex
import
shlex
import
locale
import
locale
import
codecs
import
unicodedata
import
unicodedata
import
warnings
import
warnings
from
setuptools.compat
import
unicode
,
bytes
from
setuptools.compat
import
unicode
,
bytes
...
@@ -72,6 +73,32 @@ def joinpath(prefix, *suffix):
...
@@ -72,6 +73,32 @@ def joinpath(prefix, *suffix):
return
os
.
path
.
join
(
*
suffix
)
return
os
.
path
.
join
(
*
suffix
)
return
os
.
path
.
join
(
prefix
,
*
suffix
)
return
os
.
path
.
join
(
prefix
,
*
suffix
)
def
determine_console_encoding
():
try
:
#try for the preferred encoding
encoding
=
locale
.
getpreferredencoding
()
#see if the locale.getdefaultlocale returns null
#some versions of python\platforms return US-ASCII
#when it cannot determine an encoding
if
not
encoding
or
encoding
==
"US-ASCII"
:
encoding
=
locale
.
getdefaultlocale
()[
1
]
if
encoding
:
codecs
.
lookup
(
encoding
)
# make sure a lookup error is not made
except
locale
.
Error
,
LookupError
:
encoding
=
None
#olders pythons defaulted to this
if
not
encoding
:
return
"US-ASCII"
elif
encoding
.
startswith
(
"mac-"
)
and
os
.
platform
==
"darwin"
:
return
"utf-8"
else
:
return
encoding
_console_encoding
=
determine_console_encoding
()
def
decode_as_string
(
text
,
encoding
=
None
):
def
decode_as_string
(
text
,
encoding
=
None
):
"""
"""
...
@@ -87,7 +114,7 @@ def decode_as_string(text, encoding=None):
...
@@ -87,7 +114,7 @@ def decode_as_string(text, encoding=None):
#text should be a byte string
#text should be a byte string
if
encoding
is
None
:
if
encoding
is
None
:
encoding
=
locale
.
getpreferredencoding
()
encoding
=
_console_encoding
if
not
isinstance
(
text
,
unicode
):
if
not
isinstance
(
text
,
unicode
):
text
=
text
.
decode
(
encoding
)
text
=
text
.
decode
(
encoding
)
...
...
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