Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove everything else that was deprecated in 0.2.0 #389

Merged
merged 6 commits into from
Dec 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 5 additions & 24 deletions docs/source/reference-io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ Socket objects
* :meth:`~socket.socket.makefile`: Python's file-like API is
synchronous, so it can't be implemented on top of an async
socket.
* :meth:`~socket.socket.sendall`: Could be supported, but you're
better off using the higher-level
:class:`~trio.SocketStream`, and specifically its
:meth:`~trio.SocketStream.send_all` method, which also does
additional error checking.

In addition, the following methods are similar to the equivalents
in :func:`socket.socket`, but have some trio-specific quirks:
Expand All @@ -375,30 +380,6 @@ Socket objects
left in an unknown state – possibly open, and possibly
closed. The only reasonable thing to do is to close it.

.. method:: sendall(data, flags=0)
:async:

.. deprecated:: 0.2.0
Use :class:`trio.SocketStream` and its ``send_all`` method instead.

Send the data to the socket, blocking until all of it has been
accepted by the operating system.

``flags`` are passed on to ``send``.

.. warning:: If two tasks call this method simultaneously on the
same socket, then their data may end up intermingled on the
wire. This is almost certainly not what you want. Use the
highlevel interface instead (:meth:`trio.SocketStream.send_all`);
it reliably detects this error.

Most low-level operations in trio provide a guarantee: if they raise
:exc:`trio.Cancelled`, this means that they had no effect, so the
system remains in a known state. This is **not true** for
:meth:`sendall`. If this operation raises :exc:`trio.Cancelled` (or
any other exception for that matter), then it may have sent some, all,
or none of the requested data, and there is no way to know which.

.. method:: sendfile

`Not implemented yet! <https://github.com/python-trio/trio/issues/45>`__
Expand Down
2 changes: 2 additions & 0 deletions newsfragments/1.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removed everything that was deprecated in 0.2.0; see the release notes
below for details
60 changes: 0 additions & 60 deletions trio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,66 +63,6 @@
from . import ssl
# Not imported by default: testing

# Stuff that got moved:
_deprecate.enable_attribute_deprecations(__name__)

__deprecated_attributes__ = {
"Task":
_deprecate.DeprecatedAttribute(hazmat.Task, "0.2.0", issue=136),
"current_task":
_deprecate.DeprecatedAttribute(
hazmat.current_task, "0.2.0", issue=136
),
"Result":
_deprecate.DeprecatedAttribute(hazmat.Result, "0.2.0", issue=136),
"Value":
_deprecate.DeprecatedAttribute(hazmat.Value, "0.2.0", issue=136),
"Error":
_deprecate.DeprecatedAttribute(hazmat.Error, "0.2.0", issue=136),
"UnboundedQueue":
_deprecate.DeprecatedAttribute(
hazmat.UnboundedQueue, "0.2.0", issue=136
),
"run_in_worker_thread":
_deprecate.DeprecatedAttribute(
run_sync_in_worker_thread, "0.2.0", issue=68
),
"current_clock":
_deprecate.DeprecatedAttribute(
hazmat.current_clock, "0.2.0", issue=317
),
"current_statistics":
_deprecate.DeprecatedAttribute(
hazmat.current_statistics, "0.2.0", issue=317
),
# STATUS_IGNORED never made it into a release, but I think people were
# using while it was in the dev version, so we might as well provide an
# alias for a little while.
"STATUS_IGNORED":
_deprecate.DeprecatedAttribute(
TASK_STATUS_IGNORED, "0.2.0", issue=353
),
}

_deprecate.enable_attribute_deprecations(hazmat.__name__)

hazmat.__deprecated_attributes__ = {
"yield_briefly":
_deprecate.DeprecatedAttribute(hazmat.checkpoint, "0.2.0", issue=157),
"yield_briefly_no_cancel":
_deprecate.DeprecatedAttribute(
hazmat.cancel_shielded_checkpoint, "0.2.0", issue=157
),
"yield_if_cancelled":
_deprecate.DeprecatedAttribute(
hazmat.checkpoint_if_cancelled, "0.2.0", issue=157
),
"yield_indefinitely":
_deprecate.DeprecatedAttribute(
hazmat.wait_task_rescheduled, "0.2.0", issue=157
),
}

# Having the public path in .__module__ attributes is important for:
# - exception names in printed tracebacks
# - sphinx :show-inheritance:
Expand Down
19 changes: 1 addition & 18 deletions trio/_core/_multierror.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

import attr

from .._deprecate import deprecated

__all__ = ["MultiError", "format_exception"]
__all__ = ["MultiError"]

################################################################
# MultiError
Expand Down Expand Up @@ -349,21 +347,6 @@ def concat_tb(head, tail):
# MultiErrors
################################################################


@deprecated("0.2.0", issue=347, instead="traceback.format_exception")
def format_exception(etype, value, tb, *, limit=None, chain=True):
"""Like :func:`traceback.format_exception`, but with special support for
printing :exc:`MultiError` objects.

This is a pure, stateless function, and thus safe to call from any
thread at any time.

"""
return traceback.format_exception(
etype, value, tb, limit=limit, chain=chain
)


traceback_exception_original_init = traceback.TracebackException.__init__


Expand Down
13 changes: 1 addition & 12 deletions trio/_core/tests/test_multierror.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
from .tutil import slow

from ..._deprecate import TrioDeprecationWarning
from .._multierror import (
MultiError, concat_tb, format_exception as trio_format_exception
)
from .._multierror import MultiError, concat_tb


def raiser1():
Expand Down Expand Up @@ -487,15 +485,6 @@ def raise2_raiser1():
formatted
)

# Deprecation

with pytest.warns(TrioDeprecationWarning) as record:
exc_info = einfo(make_tree())
assert format_exception(*exc_info) == trio_format_exception(*exc_info)

assert 'trio.format_exception is deprecated since Trio 0.2.0; ' \
'use traceback.format_exception instead' in record[0].message.args[0]


def test_logging(caplog):
exc1 = get_exc(raiser1)
Expand Down
10 changes: 9 additions & 1 deletion trio/_highlevel_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ async def send_all(self, data):
raise ClosedStreamError("can't send data after sending EOF")
with self._send_conflict_detector.sync:
with _translate_socket_errors_to_stream_errors():
await self.socket._sendall(data)
with memoryview(data) as data:
if not data:
await _core.checkpoint()
return
total_sent = 0
while total_sent < len(data):
with data[total_sent:] as remaining:
sent = await self.socket.send(remaining)
total_sent += sent

async def wait_send_all_might_not_block(self):
async with self._send_conflict_detector:
Expand Down
28 changes: 3 additions & 25 deletions trio/_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,29 +803,6 @@ async def sendmsg(self, *args):
_core.wait_socket_writable
)

################################################################
# sendall
################################################################

# XX: When we remove sendall(), we should move this code (and its test)
# into SocketStream.send_all().
async def _sendall(self, data, flags=0):
with memoryview(data) as data:
if not data:
await _core.checkpoint()
return
total_sent = 0
while total_sent < len(data):
with data[total_sent:] as remaining:
sent = await self.send(remaining, flags)
total_sent += sent

@deprecated(
"0.2.0", issue=291, instead="the high-level SocketStream interface"
)
async def sendall(self, data, flags=0):
return await self._sendall(data, flags)

################################################################
# sendfile
################################################################
Expand All @@ -835,7 +812,8 @@ async def sendall(self, data, flags=0):
# XX

# Intentionally omitted:
# sendall
# makefile
# setblocking
# settimeout
# setblocking/getblocking
# settimeout/gettimeout
# timeout
33 changes: 0 additions & 33 deletions trio/_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from . import _core
from ._util import aiter_compat
from ._deprecate import deprecated

__all__ = [
"Event",
Expand Down Expand Up @@ -800,7 +799,6 @@ class _QueueStats:
capacity = attr.ib()
tasks_waiting_put = attr.ib()
tasks_waiting_get = attr.ib()
tasks_waiting_join = attr.ib()


# Like queue.Queue, with the notable difference that the capacity argument is
Expand Down Expand Up @@ -841,8 +839,6 @@ def __init__(self, capacity):
self._put_semaphore = Semaphore(capacity, max_value=capacity)
self._get_semaphore = Semaphore(0, max_value=capacity)
self._data = deque()
self._join_lot = _core.ParkingLot()
self._unprocessed = 0

def __repr__(self):
return (
Expand Down Expand Up @@ -879,7 +875,6 @@ def empty(self):

def _put_protected(self, obj):
self._data.append(obj)
self._unprocessed += 1
self._get_semaphore.release()

@_core.enable_ki_protection
Expand Down Expand Up @@ -936,33 +931,6 @@ async def get(self):
await self._get_semaphore.acquire()
return self._get_protected()

@deprecated("0.2.0", issue=321, instead=None)
@_core.enable_ki_protection
def task_done(self):
"""Decrement the count of unfinished work.

Each :class:`Queue` object keeps a count of unfinished work, which
starts at zero and is incremented after each successful
:meth:`put`. This method decrements it again. When the count reaches
zero, any tasks blocked in :meth:`join` are woken.

"""
self._unprocessed -= 1
if self._unprocessed == 0:
self._join_lot.unpark_all()

@deprecated("0.2.0", issue=321, instead=None)
async def join(self):
"""Block until the count of unfinished work reaches zero.

See :meth:`task_done` for details.

"""
if self._unprocessed == 0:
await _core.checkpoint()
else:
await self._join_lot.park()

@aiter_compat
def __aiter__(self):
return self
Expand All @@ -988,5 +956,4 @@ def statistics(self):
capacity=self.capacity,
tasks_waiting_put=self._put_semaphore.statistics().tasks_waiting,
tasks_waiting_get=self._get_semaphore.statistics().tasks_waiting,
tasks_waiting_join=self._join_lot.statistics().tasks_waiting
)
13 changes: 0 additions & 13 deletions trio/_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@

from . import _core
from ._sync import CapacityLimiter
from ._deprecate import deprecated

__all__ = [
"current_await_in_trio_thread",
"current_run_in_trio_thread",
"run_sync_in_worker_thread",
"current_default_worker_thread_limiter",
"BlockingTrioPortal",
Expand Down Expand Up @@ -123,16 +120,6 @@ def run_sync(self, fn, *args):
return self._do_it(self._run_sync_cb, fn, *args)


@deprecated("0.2.0", issue=68, instead=BlockingTrioPortal.run_sync)
def current_run_in_trio_thread():
return BlockingTrioPortal().run_sync


@deprecated("0.2.0", issue=68, instead=BlockingTrioPortal.run)
def current_await_in_trio_thread():
return BlockingTrioPortal().run


################################################################

# XX at some point it probably makes sense to implement some sort of thread
Expand Down
1 change: 0 additions & 1 deletion trio/_toplevel_core_reexports.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"ResourceBusyError",
"MultiError",
"run",
"format_exception",
"open_nursery",
"open_cancel_scope",
"current_effective_deadline",
Expand Down
17 changes: 0 additions & 17 deletions trio/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,6 @@

################################################################

from .. import _deprecate

_deprecate.enable_attribute_deprecations(__name__)

__deprecated_attributes__ = {
"assert_yields":
_deprecate.DeprecatedAttribute(assert_checkpoints, "0.2.0", issue=157),
"assert_no_yields":
_deprecate.DeprecatedAttribute(
assert_no_checkpoints, "0.2.0", issue=157
),
}

del _deprecate

################################################################

from .._util import fixup_module_metadata
fixup_module_metadata(__name__, globals())
del fixup_module_metadata
Loading