Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
0f6845ce
Commit
0f6845ce
authored
Jun 22, 2019
by
Neil
Committed by
Toby Boyd
Jun 21, 2019
Browse files
Fix help print error when stdout/stderr not use utf-8 encoding (#7079)
parent
f21337b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
official/utils/flags/_conventions.py
official/utils/flags/_conventions.py
+12
-4
No files found.
official/utils/flags/_conventions.py
View file @
0f6845ce
...
...
@@ -18,6 +18,7 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
sys
import
codecs
import
functools
...
...
@@ -34,12 +35,19 @@ _help_wrap = functools.partial(flags.text_wrap, length=80, indent="",
# Pretty formatting causes issues when utf-8 is not installed on a system.
try
:
codecs
.
lookup
(
"utf-8"
)
def
_stdout_utf8
():
try
:
codecs
.
lookup
(
"utf-8"
)
except
LookupError
:
return
False
return
sys
.
stdout
.
encoding
==
"UTF-8"
if
_stdout_utf8
():
help_wrap
=
_help_wrap
e
xcept
LookupError
:
e
lse
:
def
help_wrap
(
text
,
*
args
,
**
kwargs
):
return
_help_wrap
(
text
,
*
args
,
**
kwargs
).
replace
(
"
\ufeff
"
,
""
)
return
_help_wrap
(
text
,
*
args
,
**
kwargs
).
replace
(
u
"
\ufeff
"
,
u
""
)
# Replace None with h to also allow -h
...
...
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