Skip to content

bpo-31904: Add encoding support for VxWorks RTOS #12051

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

Merged
merged 6 commits into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Doc/c-api/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Operating System Utilities

Encoding, highest priority to lowest priority:

* ``UTF-8`` on macOS and Android;
* ``UTF-8`` on macOS, Android, and VxWorks;
* ``UTF-8`` on Windows if :c:data:`Py_LegacyWindowsFSEncodingFlag` is zero;
* ``UTF-8`` if the Python UTF-8 mode is enabled;
* ``ASCII`` if the ``LC_CTYPE`` locale is ``"C"``,
Expand Down Expand Up @@ -154,7 +154,7 @@ Operating System Utilities

Encoding, highest priority to lowest priority:

* ``UTF-8`` on macOS and Android;
* ``UTF-8`` on macOS, Android, and VxWorks;
* ``UTF-8`` on Windows if :c:data:`Py_LegacyWindowsFSEncodingFlag` is zero;
* ``UTF-8`` if the Python UTF-8 mode is enabled;
* ``ASCII`` if the ``LC_CTYPE`` locale is ``"C"``,
Expand Down
8 changes: 4 additions & 4 deletions Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,8 @@ system.
Py_ssize_t len, \
const char *errors)

Decode a string from UTF-8 on Android, or from the current locale encoding
on other platforms. The supported
Decode a string from UTF-8 on Android and VxWorks, or from the current
locale encoding on other platforms. The supported
error handlers are ``"strict"`` and ``"surrogateescape"``
(:pep:`383`). The decoder uses ``"strict"`` error handler if
*errors* is ``NULL``. *str* must end with a null character but
Expand Down Expand Up @@ -796,8 +796,8 @@ system.

.. c:function:: PyObject* PyUnicode_EncodeLocale(PyObject *unicode, const char *errors)

Encode a Unicode object to UTF-8 on Android, or to the current locale
encoding on other platforms. The
Encode a Unicode object to UTF-8 on Android and VxWorks, or to the current
locale encoding on other platforms. The
supported error handlers are ``"strict"`` and ``"surrogateescape"``
(:pep:`383`). The encoder uses ``"strict"`` error handler if
*errors* is ``NULL``. Return a :class:`bytes` object. *unicode* cannot
Expand Down
8 changes: 6 additions & 2 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,17 @@ always available.

* In the UTF-8 mode, the encoding is ``utf-8`` on any platform.

* On Mac OS X, the encoding is ``'utf-8'``.
* On macOS, the encoding is ``'utf-8'``.

* On Unix, the encoding is the locale encoding.

* On Windows, the encoding may be ``'utf-8'`` or ``'mbcs'``, depending
on user configuration.

* On Android, the encoding is ``'utf-8'``.

* On VxWorks, the encoding is ``'utf-8'``.

.. versionchanged:: 3.2
:func:`getfilesystemencoding` result cannot be ``None`` anymore.

Expand Down Expand Up @@ -1023,7 +1027,7 @@ always available.
Linux ``'linux'``
Windows ``'win32'``
Windows/Cygwin ``'cygwin'``
Mac OS X ``'darwin'``
macOS ``'darwin'``
================ ===========================

.. versionchanged:: 3.3
Expand Down
4 changes: 2 additions & 2 deletions Include/cpython/coreconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ typedef struct {
* The UTF-8 Mode uses UTF-8/surrogateescape;
* If Python forces the usage of the ASCII encoding (ex: C locale
or POSIX locale on FreeBSD or HP-UX), use ASCII/surrogateescape;
* locale encoding: ANSI code page on Windows, UTF-8 on Android,
LC_CTYPE locale encoding on other platforms;
* locale encoding: ANSI code page on Windows, UTF-8 on Android and
VxWorks, LC_CTYPE locale encoding on other platforms;
* On Windows, "surrogateescape" error handler;
* "surrogateescape" error handler if the LC_CTYPE locale is "C" or "POSIX";
* "surrogateescape" error handler if the LC_CTYPE locale has been coerced
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use UTF-8 as the system encoding on VxWorks.
2 changes: 1 addition & 1 deletion Python/coreconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ get_locale_encoding(char **locale_encoding)
#ifdef MS_WINDOWS
char encoding[20];
PyOS_snprintf(encoding, sizeof(encoding), "cp%d", GetACP());
#elif defined(__ANDROID__)
#elif defined(__ANDROID__) || defined(__VXWORKS__)
const char *encoding = "UTF-8";
#else
const char *encoding = nl_langinfo(CODESET);
Expand Down
6 changes: 3 additions & 3 deletions Python/fileutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,15 +536,15 @@ _Py_DecodeLocaleEx(const char* arg, wchar_t **wstr, size_t *wlen,
int current_locale, _Py_error_handler errors)
{
if (current_locale) {
#ifdef __ANDROID__
#if defined(__ANDROID__) || defined(__VXWORKS__)
return _Py_DecodeUTF8Ex(arg, strlen(arg), wstr, wlen, reason,
errors);
#else
return decode_current_locale(arg, wstr, wlen, reason, errors);
#endif
}

#if defined(__APPLE__) || defined(__ANDROID__)
#if defined(__APPLE__) || defined(__ANDROID__) || defined(__VXWORKS__)
return _Py_DecodeUTF8Ex(arg, strlen(arg), wstr, wlen, reason,
errors);
#else
Expand All @@ -569,7 +569,7 @@ _Py_DecodeLocaleEx(const char* arg, wchar_t **wstr, size_t *wlen,
#endif

return decode_current_locale(arg, wstr, wlen, reason, errors);
#endif /* __APPLE__ or __ANDROID__ */
#endif /* __APPLE__ or __ANDROID__ or __VXWORKS__ */
}


Expand Down