-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
src: check if --icu-data-dir= points to valid dir #13053
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
Conversation
IMHO it should fail, like any other bad argument. Fallback might be unexpected by user (or even not available). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add case for NODE_ICU_DATA
via env?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
No, it doesn't support that. It will already be initialized with fallback data. (It may try again to load other data, but it's not really in a great state, cache wise, at that point.) The failure from You could think of Edit: Actually, there is a Please note also, that calling |
Worth adding a:
to the commit. |
@srl295 bool InitializeICUDirectory(const std::string& path) {
+ UErrorCode status = U_ZERO_ERROR;
- if (path.empty()) {
- UErrorCode status = U_ZERO_ERROR;
// install the 'small' data.
udata_setCommonData(&SMALL_ICUDATA_ENTRY_POINT, &status);
- return (status == U_ZERO_ERROR);
- } else {
+ if (!path.empty()) {
u_setDataDirectory(path.c_str());
}
+ u_init(&status);
+ return (status == U_ZERO_ERROR);
} P.S. there is a type in the first line of http://icu-project.org/apiref/icu4c/udata_8h.html#a406559067e309c05fb90b2d532f11835 (I would do the SVN+Trac dance, but... I'm lazy 😞) |
Maybe also
|
Updated with suggestions, CI: https://ci.nodejs.org/job/node-test-pull-request/8114/ I turned it from an abort into an |
test/parallel/test-icu-data-dir.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows fails probably since argv[0] === node.exe
or even absolute path.
Fixed test, new CI: https://ci.nodejs.org/job/node-test-pull-request/8119/ |
Call uc_init() after u_setDataDirectory() to find out if the data directory is actually valid. This commit removes parallel/test-intl-no-icu-data, added in commit 46345b9 ("src: make --icu-data-dir= switch testable"). It no longer works now that an invalid --icu-data-dir= argument is rejected. Coverage is now provided by parallel/test-icu-data-dir. Fixes: nodejs#13043 Refs: nodejs/node-gyp#1199 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Steven R Loomis <[email protected]>
Thanks for the reviews, landed in 46e773c and tagged as semver-major. |
If
|
Thanks! |
Call uc_init() after u_setDataDirectory() to find out if the data
directory is actually valid.
This commit removes parallel/test-intl-no-icu-data, added in commit
46345b9 ("src: make --icu-data-dir= switch testable"). It no longer
works now that an invalid --icu-data-dir= argument is rejected.
Coverage is now provided by abort/test-abort-icu-data-dir.
Note that a bad path is now a fatal error, not a silent error. I could make node print a warning and fall back to the builtin i18n data (if
#ifdef NODE_HAVE_SMALL_ICU
) but I don't know if ICU supports initializing twice. It seems to works for me locally with the patch below, /cc @srl295.