{"record":{"id":"95d66586bc7bfd5c","repo":"oracle/graal","slug":"unsupported-locale-s","errorCode":null,"errorMessage":"unsupported locale: %s","messagePattern":"unsupported locale: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/flavor/python/PythonLocaleData.java","lineNumber":93,"sourceCode":"\n    private final CodePointSet wordChars;\n    private final CodePointSet nonWordChars;\n    private final byte[] caseFolding;\n\n    public static PythonLocaleData getLocaleData(String locale) {\n        if (locale.equals(\"C\")) {\n            return createCachedLocaleData(false, Charset.forName(\"US-ASCII\"));\n        } else {\n            int dot = locale.indexOf('.');\n            if (dot == -1) {\n                throw new IllegalArgumentException(\"malformed locale: \" + locale);\n            }\n            String language = locale.substring(0, dot);\n            String encoding = locale.substring(dot + 1);\n            try {\n                return createCachedLocaleData(language.startsWith(\"tr_\"), Charset.forName(encoding));\n            } catch (UnsupportedCharsetException | IllegalCharsetNameException e) {\n                throw new IllegalArgumentException(\"unsupported locale: \" + locale);\n            }\n        }\n    }\n\n    public CodePointSet getWordCharacters() {\n        return wordChars;\n    }\n\n    public CodePointSet getNonWordCharacters() {\n        return nonWordChars;\n    }\n\n    public void caseFoldUnfold(CodePointSetAccumulator charClass, CodePointSetAccumulator copy) {\n        charClass.copyTo(copy);\n        int iFolding = 0;\n        for (Range r : copy) {\n            iFolding = caseFoldingBinarySearch(iFolding, r.lo);\n            while (iFolding < caseFoldingSize() && caseFoldingFrom(iFolding) >= r.lo && caseFoldingFrom(iFolding) <= r.hi) {","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/flavor/python/PythonLocaleData.java#L75-L111","documentation":"Thrown by PythonLocaleData.getLocaleData when the encoding part of the locale string does not name a charset known to the JVM. After splitting on '.', Charset.forName(encoding) throws UnsupportedCharsetException or IllegalCharsetNameException, which the method converts into IllegalArgumentException('unsupported locale: ...').","triggerScenarios":"Calling getLocaleData with a locale whose suffix after '.' is not a valid/installed charset, e.g. 'en_US.US-ASCII-TYPO', 'xx.BOGUS', 'tr_TR.905' (bare codes the JVM does not resolve), or an encoding not present in the JVM's charset providers.","commonSituations":"Guest Python code reading LC_ALL/LC_CTYPE from a Unix environment and forwarding values whose encoding aliases the JVM does not know (e.g. 'ANSI_X3.4-1968', 'cp1254', numeric codes); containers with unusual locale settings; JVMs where extended charset support (jdk.charsets) is not on the module path.","solutions":["Use a canonical, widely-supported encoding in the locale string, ideally '.UTF-8'","Map environment encoding aliases to canonical Java charset names at the call site (e.g. 'cp1254' -> 'windows-1254', 'ANSI_X3.4-1968' -> 'US-ASCII')","Fall back to 'C' when the encoding cannot be resolved and locale-specific behavior is optional","If a legitimate charset is missing, run the JVM with full charset support (include jdk.charsets) "],"exampleFix":"// before\nPythonLocaleData.getLocaleData(\"tr_TR.cp1254\"); // unknown name\n\n// after\nPythonLocaleData.getLocaleData(\"tr_TR.windows-1254\");","handlingStrategy":"validation","validationCode":"boolean isSupportedLocale(String locale) {\n    if (locale.equals(\"C\")) return true;\n    int dot = locale.indexOf('.');\n    if (dot <= 0) return false;\n    try {\n        java.nio.charset.Charset.forName(locale.substring(dot + 1));\n        return true;\n    } catch (java.nio.charset.UnsupportedCharsetException | java.nio.charset.IllegalCharsetNameException e) {\n        return false;\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve the charset with Charset.forName yourself before requesting locale data, and map aliases to canonical names","Default to 'C' or '.UTF-8' when the environment encoding is unknown to the JVM"],"tags":["regex","python-flavor","locale","charset","environment"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}