[pypy-commit] pypy buffer-interface2: prefer newbytes/newint to wrap
mattip
pypy.commits at gmail.com
Tue Oct 4 15:16:20 EDT 2016
Author: Matti Picus <matti.picus at gmail.com>
Branch: buffer-interface2
Changeset: r87583:26574d11afdb
Date: 2016-10-04 20:38 +0300
http://bitbucket.org/pypy/pypy/changeset/26574d11afdb/
Log: prefer newbytes/newint to wrap
diff --git a/pypy/module/cpyext/pyerrors.py b/pypy/module/cpyext/pyerrors.py
--- a/pypy/module/cpyext/pyerrors.py
+++ b/pypy/module/cpyext/pyerrors.py
@@ -21,7 +21,7 @@
@cpython_api([PyObject, CONST_STRING], lltype.Void)
def PyErr_SetString(space, w_type, message_ptr):
message = rffi.charp2str(message_ptr)
- PyErr_SetObject(space, w_type, space.wrap(message))
+ PyErr_SetObject(space, w_type, space.newbytes(message))
@cpython_api([PyObject], lltype.Void, error=CANNOT_FAIL)
def PyErr_SetNone(space, w_type):
@@ -151,7 +151,7 @@
# XXX Doesn't actually do anything with PyErr_CheckSignals.
if llfilename:
w_filename = rffi.charp2str(llfilename)
- filename = space.wrap(w_filename)
+ filename = space.newbytes(w_filename)
else:
filename = space.w_None
@@ -170,13 +170,13 @@
msg = os.strerror(errno)
if w_value:
w_error = space.call_function(w_type,
- space.wrap(errno),
- space.wrap(msg),
+ space.newint(errno),
+ space.newbytes(msg),
w_value)
else:
w_error = space.call_function(w_type,
- space.wrap(errno),
- space.wrap(msg))
+ space.newint(errno),
+ space.newbytes(msg))
raise OperationError(w_type, w_error)
@cpython_api([], rffi.INT_real, error=-1)
@@ -252,11 +252,11 @@
documentation. There is no C API for warning control."""
if w_category is None:
w_category = space.w_None
- w_message = space.wrap(rffi.charp2str(message_ptr))
- w_stacklevel = space.wrap(rffi.cast(lltype.Signed, stacklevel))
+ w_message = space.newbytes(rffi.charp2str(message_ptr))
+ w_stacklevel = space.newint(rffi.cast(lltype.Signed, stacklevel))
- w_module = PyImport_Import(space, space.wrap("warnings"))
- w_warn = space.getattr(w_module, space.wrap("warn"))
+ w_module = PyImport_Import(space, space.newbytes("warnings"))
+ w_warn = space.getattr(w_module, space.newbytes("warn"))
space.call_function(w_warn, w_message, w_category, w_stacklevel)
return 0
@@ -317,10 +317,10 @@
@cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
def PyTraceBack_Print(space, w_tb, w_file):
- space.call_method(w_file, "write", space.wrap(
+ space.call_method(w_file, "write", space.newbytes(
'Traceback (most recent call last):\n'))
w_traceback = space.call_method(space.builtin, '__import__',
- space.wrap("traceback"))
+ space.newbytes("traceback"))
space.call_method(w_traceback, "print_tb", w_tb, space.w_None, w_file)
return 0
More information about the pypy-commit
mailing list