Force Qt validator to use C locale. #6241
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR for #6082: Cannot interactively edit axes limits using Qt5 backend
I found that this was a locale issue: I am on a French locale, where the decimal separator is ",".
On Qt4 (http://doc.qt.io/qt-4.8/qdoublevalidator.html),
On Qt5 (http://doc.qt.io/qt-5/qdoublevalidator.html), the second provision has been removed.
Thus, on the French locale, "1.23" is considered an invalid input and rejected by QDoubleValidator. In fact, I can input instead "1,23", but this causes an exception later when Python tries to convert this to a float. (To reproduce this, set the locale appropriately and edit the axes parameters of a default plot.)
Given that matplotlib is not really localized anyways (except for
axes.formatter.use_locale
), this patch sets the validator's locale to C in all cases. Note that despite what the Qt docs indicate, this does not seem to prevent input of localized ("1,23") values, which still lead to an exception.