-
Notifications
You must be signed in to change notification settings - Fork 74k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix syntax error in single_image_random_dot_stereograms caused by locale #22044
Fix syntax error in single_image_random_dot_stereograms caused by locale #22044
Conversation
This fix tries to address the issue raised in 21164 where the single_image_random_dot_stereograms in different locale (like de_DE) caused syntax error in python like: ``` File "<string>", line 28 def single_image_random_dot_stereograms(depth_values, hidden_surface_removal=True, convergence_dots_size=8, dots_per_inch=72, eye_separation=2,5, mu=0,333299994, normalize=True, normalize_max=-100, normalize_min=100, border_level=0, number_colors=256, output_image_shape=[1024, 768, 1], output_data_window=[1022, 757], name=None): ^ SyntaxError: invalid syntax ``` The issue was that the float to string conversion in python_op_gen_internal.cc triggered snprintf (in `FloatToBuffer`) which is local dependent and generates something like `eye_separatiion=2,5` in DE locale. This fix replaced the float to string conversion with locale-independent ``` std::ostringstream s; s.imbue(std::locale::classic()); ``` This fix fixes 21164. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Nice. |
Can you fix the import order (see linter log: https://source.cloud.google.com/results/invocations/ff5695b9-ca62-4de2-8c9a-b3b8d2f7a69c/targets/%2F%2Ftensorflow%2Ftools%2Fci_build:gen_ci_clang_format_out/log) |
Wait, your last commit already ran clang-format? Is that stale? |
Is this a difference between clang-format versions? I'm afraid of those... |
to conform to `Experimental clang-format Check` Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Thanks @martinwicke for the review. The PR has been updated to address the issue in The clang-format might be different over versions. I am wondering if there is some information about platform, clang-format version, and the command line in |
Tried several different versions of clang-format, it looks like clang-format installed through
will be moved and sorted in I remember placing |
We are using 3.9 with -style=google in |
PiperOrigin-RevId: 212314097
This fix tries to address the issue raised in #21164 where the single_image_random_dot_stereograms in different locale (like de_DE) caused syntax error in python like:
The issue was that the float to string conversion in
python_op_gen_internal.cc
triggered snprintf (inFloatToBuffer
) which is local dependent and generates something likeeye_separatiion=2,5
in DE locale.This fix replaced the float to string conversion with locale-independent
This fix fixes #21164.
Signed-off-by: Yong Tang yong.tang.github@outlook.com