mirror of
https://github.com/python/cpython.git
synced 2025-07-13 14:25:18 +00:00
Merge 3.6.
This commit is contained in:
commit
31eaf49ed9
4 changed files with 17 additions and 12 deletions
|
@ -8,7 +8,7 @@ import shutil
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
from test.support import script_helper
|
from test.support import script_helper, is_android
|
||||||
from test.support.script_helper import (spawn_python, kill_python, assert_python_ok,
|
from test.support.script_helper import (spawn_python, kill_python, assert_python_ok,
|
||||||
assert_python_failure)
|
assert_python_failure)
|
||||||
|
|
||||||
|
@ -178,15 +178,16 @@ class CmdLineTest(unittest.TestCase):
|
||||||
if not stdout.startswith(pattern):
|
if not stdout.startswith(pattern):
|
||||||
raise AssertionError("%a doesn't start with %a" % (stdout, pattern))
|
raise AssertionError("%a doesn't start with %a" % (stdout, pattern))
|
||||||
|
|
||||||
@unittest.skipUnless(sys.platform == 'darwin', 'test specific to Mac OS X')
|
@unittest.skipUnless((sys.platform == 'darwin' or
|
||||||
def test_osx_utf8(self):
|
is_android), 'test specific to Mac OS X and Android')
|
||||||
|
def test_osx_android_utf8(self):
|
||||||
def check_output(text):
|
def check_output(text):
|
||||||
decoded = text.decode('utf-8', 'surrogateescape')
|
decoded = text.decode('utf-8', 'surrogateescape')
|
||||||
expected = ascii(decoded).encode('ascii') + b'\n'
|
expected = ascii(decoded).encode('ascii') + b'\n'
|
||||||
|
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
# C locale gives ASCII locale encoding, but Python uses UTF-8
|
# C locale gives ASCII locale encoding, but Python uses UTF-8
|
||||||
# to parse the command line arguments on Mac OS X
|
# to parse the command line arguments on Mac OS X and Android.
|
||||||
env['LC_ALL'] = 'C'
|
env['LC_ALL'] = 'C'
|
||||||
|
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
|
|
|
@ -10,6 +10,10 @@ What's New in Python 3.7.0 alpha 1
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #26919: On Android, operating system data is now always encoded/decoded
|
||||||
|
to/from UTF-8, instead of the locale encoding to avoid inconsistencies with
|
||||||
|
os.fsencode() and os.fsdecode() which are already using UTF-8.
|
||||||
|
|
||||||
- Issue #28147: Fix a memory leak in split-table dictionaries: setattr()
|
- Issue #28147: Fix a memory leak in split-table dictionaries: setattr()
|
||||||
must not convert combined table into split table. Patch written by INADA
|
must not convert combined table into split table. Patch written by INADA
|
||||||
Naoki.
|
Naoki.
|
||||||
|
|
|
@ -5067,10 +5067,10 @@ onError:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#if defined(__APPLE__) || defined(__ANDROID__)
|
||||||
|
|
||||||
/* Simplified UTF-8 decoder using surrogateescape error handler,
|
/* Simplified UTF-8 decoder using surrogateescape error handler,
|
||||||
used to decode the command line arguments on Mac OS X.
|
used to decode the command line arguments on Mac OS X and Android.
|
||||||
|
|
||||||
Return a pointer to a newly allocated wide character string (use
|
Return a pointer to a newly allocated wide character string (use
|
||||||
PyMem_RawFree() to free the memory), or NULL on memory allocation error. */
|
PyMem_RawFree() to free the memory), or NULL on memory allocation error. */
|
||||||
|
@ -5121,7 +5121,7 @@ _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size)
|
||||||
return unicode;
|
return unicode;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __APPLE__ */
|
#endif /* __APPLE__ or __ANDROID__ */
|
||||||
|
|
||||||
/* Primary internal function which creates utf8 encoded bytes objects.
|
/* Primary internal function which creates utf8 encoded bytes objects.
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ extern int winerror_to_errno(int);
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif /* HAVE_FCNTL_H */
|
#endif /* HAVE_FCNTL_H */
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#if defined(__APPLE__) || defined(__ANDROID__)
|
||||||
extern wchar_t* _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size);
|
extern wchar_t* _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ decode_ascii_surrogateescape(const char *arg, size_t *size)
|
||||||
wchar_t*
|
wchar_t*
|
||||||
Py_DecodeLocale(const char* arg, size_t *size)
|
Py_DecodeLocale(const char* arg, size_t *size)
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#if defined(__APPLE__) || defined(__ANDROID__)
|
||||||
wchar_t *wstr;
|
wchar_t *wstr;
|
||||||
wstr = _Py_DecodeUTF8_surrogateescape(arg, strlen(arg));
|
wstr = _Py_DecodeUTF8_surrogateescape(arg, strlen(arg));
|
||||||
if (size != NULL) {
|
if (size != NULL) {
|
||||||
|
@ -406,7 +406,7 @@ oom:
|
||||||
if (size != NULL)
|
if (size != NULL)
|
||||||
*size = (size_t)-1;
|
*size = (size_t)-1;
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif /* __APPLE__ */
|
#endif /* __APPLE__ or __ANDROID__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Encode a wide character string to the locale encoding with the
|
/* Encode a wide character string to the locale encoding with the
|
||||||
|
@ -424,7 +424,7 @@ oom:
|
||||||
char*
|
char*
|
||||||
Py_EncodeLocale(const wchar_t *text, size_t *error_pos)
|
Py_EncodeLocale(const wchar_t *text, size_t *error_pos)
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#if defined(__APPLE__) || defined(__ANDROID__)
|
||||||
Py_ssize_t len;
|
Py_ssize_t len;
|
||||||
PyObject *unicode, *bytes = NULL;
|
PyObject *unicode, *bytes = NULL;
|
||||||
char *cpath;
|
char *cpath;
|
||||||
|
@ -522,7 +522,7 @@ Py_EncodeLocale(const wchar_t *text, size_t *error_pos)
|
||||||
bytes = result;
|
bytes = result;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
#endif /* __APPLE__ */
|
#endif /* __APPLE__ or __ANDROID__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue