[pypy-commit] pypy unicode-utf8-py3: merge py3.5 into branch
mattip
pypy.commits at gmail.com
Tue Nov 13 03:19:51 EST 2018
Author: Matti Picus <matti.picus at gmail.com>
Branch: unicode-utf8-py3
Changeset: r95304:e41d802a74a7
Date: 2018-11-12 16:23 -0800
http://bitbucket.org/pypy/pypy/changeset/e41d802a74a7/
Log: merge py3.5 into branch
diff --git a/pypy/module/_io/test/test_bufferedio.py b/pypy/module/_io/test/test_bufferedio.py
--- a/pypy/module/_io/test/test_bufferedio.py
+++ b/pypy/module/_io/test/test_bufferedio.py
@@ -169,12 +169,12 @@
#
exc = raises(TypeError, readinto, u"hello")
msg = str(exc.value)
- print(msg)
+ # print(msg)
assert " read-write b" in msg and msg.endswith(", not str")
#
exc = raises(TypeError, readinto, memoryview(b"hello"))
msg = str(exc.value)
- print(msg)
+ # print(msg)
assert " read-write b" in msg and msg.endswith(", not memoryview")
#
f.close()
diff --git a/pypy/module/_io/test/test_bytesio.py b/pypy/module/_io/test/test_bytesio.py
--- a/pypy/module/_io/test/test_bytesio.py
+++ b/pypy/module/_io/test/test_bytesio.py
@@ -111,12 +111,12 @@
#
exc = raises(TypeError, readinto, u"hello")
msg = str(exc.value)
- print(msg)
+ # print(msg)
assert " read-write b" in msg and msg.endswith(", not str")
#
exc = raises(TypeError, readinto, memoryview(b"hello"))
msg = str(exc.value)
- print(msg)
+ # print(msg)
assert " read-write b" in msg and msg.endswith(", not memoryview")
#
b.close()
diff --git a/pypy/module/_io/test/test_fileio.py b/pypy/module/_io/test/test_fileio.py
--- a/pypy/module/_io/test/test_fileio.py
+++ b/pypy/module/_io/test/test_fileio.py
@@ -164,12 +164,12 @@
#
exc = raises(TypeError, f.readinto, u"hello")
msg = str(exc.value)
- print(msg)
+ # print(msg)
assert " read-write b" in msg and msg.endswith(", not str")
#
exc = raises(TypeError, f.readinto, memoryview(b"hello"))
msg = str(exc.value)
- print(msg)
+ # print(msg)
assert " read-write b" in msg and msg.endswith(", not memoryview")
#
f.close()
diff --git a/pypy/module/cpyext/unicodeobject.py b/pypy/module/cpyext/unicodeobject.py
--- a/pypy/module/cpyext/unicodeobject.py
+++ b/pypy/module/cpyext/unicodeobject.py
@@ -495,12 +495,16 @@
in the unicode() built-in function. The codec to be used is looked up
using the Python codec registry. Return NULL if an exception was raised by
the codec."""
- if not encoding:
- # This tracks CPython 2.7, in CPython 3.4 'utf-8' is hardcoded instead
+ return _pyunicode_decode(space, rffi.charpsize2str(s, size),
+ encoding, errors)
+
+def _pyunicode_decode(space, s, encoding, errors):
+ if encoding:
+ w_encoding = space.newtext(rffi.charp2str(encoding))
+ else:
+ # python 3.4 changed to this from defaultencoding
w_encoding = space.newtext('utf-8')
- else:
- w_encoding = space.newtext(rffi.charp2str(encoding))
- w_str = space.newbytes(rffi.charpsize2str(s, size))
+ w_str = space.newbytes(s)
if errors:
w_errors = space.newtext(rffi.charp2str(errors))
else:
@@ -535,28 +539,12 @@
All other objects, including Unicode objects, cause a TypeError to be
set."""
- if not encoding:
- raise oefmt(space.w_TypeError, "decoding Unicode is not supported")
- w_encoding = space.newtext(rffi.charp2str(encoding))
- if errors:
- w_errors = space.newtext(rffi.charp2str(errors))
- else:
- w_errors = None
-
- # - unicode is disallowed
- # - raise TypeError for non-string types
if space.isinstance_w(w_obj, space.w_unicode):
- w_meth = None
- else:
- try:
- w_meth = space.getattr(w_obj, space.newtext('decode'))
- except OperationError as e:
- if not e.match(space, space.w_AttributeError):
- raise
- w_meth = None
- if w_meth is None:
- raise oefmt(space.w_TypeError, "decoding Unicode is not supported")
- return space.call_function(w_meth, w_encoding, w_errors)
+ raise oefmt(space.w_TypeError, "decoding str is not supported")
+ if space.isinstance_w(w_obj, space.w_bytearray): # Python 2.x specific
+ raise oefmt(space.w_TypeError, "decoding bytearray is not supported")
+ s = space.bytes_w(w_obj)
+ return _pyunicode_decode(space, s, encoding, errors)
@cpython_api([PyObject, PyObjectP], rffi.INT_real, error=0)
diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -226,9 +226,9 @@
def test_pickle(self):
import pickle, os
st = self.posix.stat(os.curdir)
- print(type(st).__module__)
+ # print(type(st).__module__)
s = pickle.dumps(st)
- print(repr(s))
+ # print(repr(s))
new = pickle.loads(s)
assert new == st
assert type(new) is type(st)
@@ -572,6 +572,12 @@
res = fp.read()
assert res == '1\n'
+ if sys.platform == "win32":
+ # using startfile in app_startfile creates global state
+ test_popen.dont_track_allocations = True
+ test_popen_with.dont_track_allocations = True
+ test_popen_child_fds.dont_track_allocations = True
+
if hasattr(__import__(os.name), '_getfullpathname'):
def test__getfullpathname(self):
# nt specific
diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py
--- a/pypy/module/sys/initpath.py
+++ b/pypy/module/sys/initpath.py
@@ -236,8 +236,8 @@
#endif
#include <windows.h>
#include <stdio.h>
+#include <stdlib.h>
-RPY_EXPORTED
char *_pypy_init_home(void)
{
HMODULE hModule = 0;
@@ -273,7 +273,6 @@
#include <stdio.h>
#include <stdlib.h>
-RPY_EXPORTED
char *_pypy_init_home(void)
{
Dl_info info;
@@ -291,11 +290,27 @@
}
"""
+_source_code += """
+inline
+void _pypy_init_free(char *p)
+{
+ free(p);
+}
+"""
+
+if we_are_translated():
+ post_include_bits = []
+else:
+ # for tests
+ post_include_bits=['RPY_EXPORTED char *_pypy_init_home(void);',
+ 'RPY_EXPORTED void _pypy_init_free(char*);',
+ ]
+
_eci = ExternalCompilationInfo(separate_module_sources=[_source_code],
- post_include_bits=['RPY_EXPORTED char *_pypy_init_home(void);'])
+ post_include_bits=post_include_bits)
_eci = _eci.merge(rdynload.eci)
pypy_init_home = rffi.llexternal("_pypy_init_home", [], rffi.CCHARP,
_nowrapper=True, compilation_info=_eci)
-pypy_init_free = rffi.llexternal("free", [rffi.CCHARP], lltype.Void,
+pypy_init_free = rffi.llexternal("_pypy_init_free", [rffi.CCHARP], lltype.Void,
_nowrapper=True, compilation_info=_eci)
More information about the pypy-commit
mailing list