Author: Matti Picus <[email protected]>
Branch: py3.5
Changeset: r95302:2a37ce3c7d2f
Date: 2018-11-12 09:22 -0800
http://bitbucket.org/pypy/pypy/changeset/2a37ce3c7d2f/
Log: merge default into py3.5
diff --git a/pypy/module/cpyext/test/test_unicodeobject.py
b/pypy/module/cpyext/test/test_unicodeobject.py
--- a/pypy/module/cpyext/test/test_unicodeobject.py
+++ b/pypy/module/cpyext/test/test_unicodeobject.py
@@ -684,6 +684,8 @@
with raises_w(space, TypeError):
PyUnicode_FromEncodedObject(
space, space.wrap(u_text), null_charp, None)
+ assert space.unicode_w(PyUnicode_FromEncodedObject(
+ space, space.wrap(s_text), null_charp, None)) == u_text
rffi.free_charp(b_text)
def test_mbcs(self, space):
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
@@ -486,10 +486,14 @@
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."""
+ return _pyunicode_decode(space, rffi.charpsize2str(s, size),
+ encoding, errors)
+
+def _pyunicode_decode(space, s, encoding, errors):
if not encoding:
# This tracks CPython 2.7, in CPython 3.4 'utf-8' is hardcoded instead
encoding = PyUnicode_GetDefaultEncoding(space)
- w_str = space.newbytes(rffi.charpsize2str(s, size))
+ w_str = space.newbytes(s)
w_encoding = space.newtext(rffi.charp2str(encoding))
if errors:
w_errors = space.newtext(rffi.charp2str(errors))
@@ -525,28 +529,12 @@
All other objects, including Unicode objects, cause a TypeError to be
set."""
- if not encoding:
+ if space.isinstance_w(w_obj, space.w_unicode):
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)
+ 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.bufferstr_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
@@ -227,9 +227,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)
@@ -573,6 +573,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)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit