<div dir="ltr"><br><br><div class="gmail_quote">On Fri Feb 20 2015 at 10:27:35 AM Stefan Richthofer <<a href="mailto:Stefan.Richthofer@gmx.de">Stefan.Richthofer@gmx.de</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:Verdana;font-size:12.0px"><div>
<div>Honestly, the right solution would be to have a function or macro that generates the TypeError messages</div>
<div>from X, Y, Z arguments. (Until now I actually believed this would be already the case)</div>
<div>- type errors would be of uniform style</div>
<div>- if for some reoson the format should be changed, this can be done in one central place</div>
<div>- if someone would want to parse the error message this would be feasible</div>
<div>I suppose it should be straight forward to find error message creations in the source by searching for "TypeError" or something.</div>
<div>Maybe this kind of cleanup could be done along with the implementation of PEP 484?</div></div></div></div></blockquote><div><br></div><div>Actually PEP 473 covers standardizing error messages by introducing keyword-only arguments which would lead to a standardized message being generated. From the C side there can be a function provided to make it easy to get the same result as constructing the exception with the keyword-only argument.</div><div><br></div><div>-Brett</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:Verdana;font-size:12.0px"><div>
<div> </div>
<div>-Stefan</div>
<div>
<div name="quote" style="margin:10px 5px 5px 10px;padding:10px 0 10px 10px;border-left:2px solid #c3d9e5;word-wrap:break-word">
<div style="margin:0 0 10px 0"><b>Gesendet:</b> Freitag, 20. Februar 2015 um 15:05 Uhr<br>
<b>Von:</b> "Brett Cannon" <<a href="mailto:brett@python.org" target="_blank">brett@python.org</a>><br>
<b>An:</b> "Serhiy Storchaka" <<a href="mailto:storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>>, <a href="mailto:python-dev@python.org" target="_blank">python-dev@python.org</a><br>
<b>Betreff:</b> Re: [Python-Dev] TypeError messages</div>
<div name="quoted-content"></div></div></div></div></div></div><div><div style="font-family:Verdana;font-size:12.0px"><div><div><div name="quote" style="margin:10px 5px 5px 10px;padding:10px 0 10px 10px;border-left:2px solid #c3d9e5;word-wrap:break-word"><div name="quoted-content">
<div>
<div class="gmail_quote">On Thu Feb 19 2015 at 5:52:07 PM Serhiy Storchaka <<a href="http://storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>> wrote:
<blockquote class="gmail_quote" style="margin:0 0 0 0.8ex;border-left:1.0px rgb(204,204,204) solid;padding-left:1.0ex">Different patterns for TypeError messages are used in the stdlib:<br>
<br>
expected X, Y found<br>
expected X, found Y<br>
expected X, but Y found<br>
expected X instance, Y found<br>
X expected, not Y<br>
expect X, not Y<br>
need X, Y found<br>
X is required, not Y<br>
Z must be X, not Y<br>
Z should be X, not Y<br>
<br>
and more.<br>
<br>
What the pattern is most preferable?</blockquote>
<div> </div>
<div>My preference is for "expected X, but found Y".</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 0.8ex;border-left:1.0px rgb(204,204,204) solid;padding-left:1.0ex"><br>
Some messages use the article before X or Y. Should the article be used<br>
or omitted?<br>
<br>
Some messages (only in C) truncate actual type name (%.50s, %.80s,<br>
%.200s, %.500s). Should type name be truncated at all and for how limit?</blockquote>
<div> </div>
<div>I assume this is over some worry of string size blowing out memory allocation or something? If someone can show that's an actual worry then fine, otherwise I say don't truncate.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 0.8ex;border-left:1.0px rgb(204,204,204) solid;padding-left:1.0ex">Type names newer truncated in TypeError messages raised in Python code.<br>
<br>
Some messages enclose actual type name with single quotes ('%s',<br>
'%.200s'). Should type name be quoted? It is uncommon if type name<br>
contains spaces.</blockquote>
<div> </div>
<div> I agree that type names don't need to be quoted.</div>
</div>
</div></div></div></div></div></div></div><div><div style="font-family:Verdana;font-size:12.0px"><div><div><div name="quote" style="margin:10px 5px 5px 10px;padding:10px 0 10px 10px;border-left:2px solid #c3d9e5;word-wrap:break-word"><div name="quoted-content">
_______________________________________________ Python-Dev mailing list <a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a> <a href="https://mail.python.org/mailman/listinfo/python-dev" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a> Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/stefan.richthofer%40gmx.de" target="_blank">https://mail.python.org/mailman/options/python-dev/stefan.richthofer%40gmx.de</a></div>
</div>
</div>
</div></div></div>
______________________________<u></u>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" target="_blank">https://mail.python.org/<u></u>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/brett%40python.org" target="_blank">https://mail.python.org/<u></u>mailman/options/python-dev/<u></u>brett%40python.org</a><br>
</blockquote></div></div>