Yury Selivanov added the comment:

Oh, choosing a good error message is hard :(

I've a few comments.  Sorry, this thread is growing rather rapidly, but please 
help me to pick one of them:


> From the point of view of the error message, the reason I changed my 
> suggestion was because I liked your idea of optimising it for the "only using 
> await" case and trusting that the folks delving into the lower level plumbing 
> of calling methods manually can figure it out. [...]

We either have to use a sub-optimal error message tailored for 'await' 
expression users, or we can choose a longer error message.  I'm not very fond 
of this option, but maybe it's because I can't come up with something long and 
concise at the same time.  Maybe something along the lines of: "cannot resume 
terminated coroutine (was it awaited on before?)"


> That is, "Cannot resume terminated coroutine" is always accurate, but relies 
> on the reader knowing that "await" both resumes a coroutine and waits for it 
> to terminate.

Not sure I like the "terminated" word here.  The coroutine was either awaited 
before, which means that the coroutine object is now exhausted, or it was 
manually closed at some point.  To me "terminated" is closer to the latter.


> "Coroutine was previously awaited on" may be wrong about how the coroutine 
> was originally terminated, but at least hints that the error may be related 
> to awaiting the coroutine.

Agree.


> "Cannot resume previously awaited coroutine" would be inaccurate under the 
> same circumstances.

Thinking about "resume"...  If a user sees this message pointing to an "await" 
expression, it might confuse them, since "await coro" does not just resume 
"coro".  It inits and consumes "coro" until it raises a StopIteration.


"Cannot await previously awaited coroutine" would only be entirely accurate for 
"double await" errors, but doesn't rely on the reader making any assumptions at 
all in that case.

Agree.  But I don't like that we have two "await" words in one short message.


> (The bulk of the problem here is that my brain is happy to accept "awaited" 
> as a novel adjective modifying "coroutine", but balks at "awaited" as a verb 
> or "awaited on" as a verb phrase. I'm extrapolating from that to guess that 
> other folks would find the verb form similarly jarring)

I trust your brain here, you're a native speaker ;)  If you think that "Cannot 
await previously awaited coroutine" is the best option here, let's stick to it.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25887>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to