Author: Philip Jenvey <pjen...@underboss.org> Branch: py3k Changeset: r61481:38799d78b6dc Date: 2013-02-19 14:10 -0800 http://bitbucket.org/pypy/pypy/changeset/38799d78b6dc/
Log: merge default diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py --- a/pypy/interpreter/baseobjspace.py +++ b/pypy/interpreter/baseobjspace.py @@ -1519,10 +1519,11 @@ ) return fd - def warn(self, msg, w_warningcls): - self.appexec([self.wrap(msg), w_warningcls], """(msg, warningcls): + def warn(self, w_msg, w_warningcls, stacklevel=2): + self.appexec([w_msg, w_warningcls, self.wrap(stacklevel)], + """(msg, warningcls, stacklevel): import _warnings - _warnings.warn(msg, warningcls, stacklevel=2) + _warnings.warn(msg, warningcls, stacklevel=stacklevel) """) diff --git a/pypy/module/cpyext/import_.py b/pypy/module/cpyext/import_.py --- a/pypy/module/cpyext/import_.py +++ b/pypy/module/cpyext/import_.py @@ -46,8 +46,9 @@ @cpython_api([CONST_STRING], PyObject) def PyImport_ImportModuleNoBlock(space, name): - space.warn('PyImport_ImportModuleNoBlock() is not non-blocking', - space.w_RuntimeWarning) + space.warn( + space.wrap('PyImport_ImportModuleNoBlock() is not non-blocking'), + space.w_RuntimeWarning) return PyImport_Import(space, space.wrap(rffi.charp2str(name))) @cpython_api([PyObject], PyObject) diff --git a/pypy/module/exceptions/interp_exceptions.py b/pypy/module/exceptions/interp_exceptions.py --- a/pypy/module/exceptions/interp_exceptions.py +++ b/pypy/module/exceptions/interp_exceptions.py @@ -215,8 +215,8 @@ if self.w_message is None: raise OperationError(space.w_AttributeError, space.wrap("message was deleted")) - space.warn("BaseException.message has been deprecated as of Python 2.6", - space.w_DeprecationWarning) + msg = "BaseException.message has been deprecated as of Python 2.6" + space.warn(space.wrap(msg), space.w_DeprecationWarning) return self.w_message def descr_message_set(self, space, w_new): diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py --- a/pypy/module/imp/importing.py +++ b/pypy/module/imp/importing.py @@ -167,9 +167,9 @@ "Parent module '%s' not loaded, " "cannot perform relative import" % ctxt_package)) else: - space.warn("Parent module '%s' not found " - "while handling absolute import" % ctxt_package, - space.w_RuntimeWarning) + msg = ("Parent module '%s' not found while handling absolute " + "import" % ctxt_package) + space.warn(space.wrap(msg), space.w_RuntimeWarning) rel_modulename = ctxt_package[:dot_position] rel_level = rel_modulename.count('.') + 1 @@ -510,9 +510,9 @@ if modtype in (PY_SOURCE, PY_COMPILED): return FindInfo(PKG_DIRECTORY, filepart, None) else: - msg = "Not importing directory " +\ - "'%s' missing __init__.py" % (filepart,) - space.warn(msg, space.w_ImportWarning) + msg = ("Not importing directory '%s' missing __init__.py" % + (filepart,)) + space.warn(space.wrap(msg), space.w_ImportWarning) modtype, suffix, filemode = find_modtype(space, filepart) try: if modtype in (PY_SOURCE, PY_COMPILED, C_EXTENSION): diff --git a/pypy/module/struct/formatiterator.py b/pypy/module/struct/formatiterator.py --- a/pypy/module/struct/formatiterator.py +++ b/pypy/module/struct/formatiterator.py @@ -83,11 +83,10 @@ def _maybe_float(self, w_obj): space = self.space if space.is_true(space.isinstance(w_obj, space.w_float)): - space.warn("struct: integer argument expected, got float", - space.w_DeprecationWarning) + msg = "struct: integer argument expected, got float" else: - space.warn("integer argument expected, got non-integer", - space.w_DeprecationWarning) + msg = "integer argument expected, got non-integer" + space.warn(space.wrap(msg), space.w_DeprecationWarning) return space.int(w_obj) # wrapped float -> wrapped int or long else: diff --git a/pypy/objspace/std/objecttype.py b/pypy/objspace/std/objecttype.py --- a/pypy/objspace/std/objecttype.py +++ b/pypy/objspace/std/objecttype.py @@ -123,11 +123,8 @@ msg = "format_spec must be a string" raise OperationError(space.w_TypeError, space.wrap(msg)) if space.len_w(w_format_spec) > 0: - space.warn( - ("object.__format__ with a non-empty format string is " - "deprecated"), - space.w_PendingDeprecationWarning - ) + msg = "object.__format__ with a non-empty format string is deprecated" + space.warn(space.wrap(msg), space.w_PendingDeprecationWarning) return space.format(w_as_str, w_format_spec) def descr___subclasshook__(space, __args__): diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py --- a/pypy/objspace/std/typeobject.py +++ b/pypy/objspace/std/typeobject.py @@ -293,8 +293,9 @@ msg = "can't set attributes on type object '%s'" raise operationerrfmt(space.w_TypeError, msg, w_self.name) if name == "__del__" and name not in w_self.dict_w: - msg = "a __del__ method added to an existing type will not be called" - space.warn(msg, space.w_RuntimeWarning) + msg = ("a __del__ method added to an existing type will not be " + "called") + space.warn(space.wrap(msg), space.w_RuntimeWarning) if space.config.objspace.std.withtypeversion: version_tag = w_self.version_tag() if version_tag is not None: diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py --- a/rpython/rlib/rsocket.py +++ b/rpython/rlib/rsocket.py @@ -497,8 +497,15 @@ def __del__(self): fd = self.fd if fd != _c.INVALID_SOCKET: - self.fd = _c.INVALID_SOCKET - _c.socketclose(fd) + try: + self._dealloc_warn() + finally: + self.fd = _c.INVALID_SOCKET + _c.socketclose(fd) + + def _dealloc_warn(self): + """Called when implicitly closed via the deconstructor""" + pass if hasattr(_c, 'fcntl'): def _setblocking(self, block): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit