<div dir="ltr">so are we worried that __fspath__ will exist and be callable, but  might raise an AttributeError somewhere inside itself? if so isn't it broken anyway, so should it be ignored?<div><br></div><div>and I know it's asking poermission rather than forgiveness, but what's wrong with:</div><div><br></div><div>if hasattr(path, "__fspath__"):</div><div>    path = path.__fspath__()<br><div><br></div><div>if you really want to check for the existence of the attribute first?</div><div><br></div><div>or even:</div><div><br></div><div>path = path.__fspath__ if hasattr(path, "__fspath__") else path</div><div><br></div><div><br></div><div>(OK, really a Pythonic style question now....)</div><div><br></div><div>-CHB</div><div><br></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 13, 2016 at 12:54 PM, Brett Cannon <span dir="ltr"><<a href="mailto:brett@python.org" target="_blank">brett@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><br><div class="gmail_quote"><span class=""><div dir="ltr">On Wed, 13 Apr 2016 at 12:39 Fred Drake <<a href="mailto:fred@fdrake.net" target="_blank">fred@fdrake.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Apr 13, 2016 at 3:24 PM, Chris Angelico <<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>> wrote:<br>
> Is that the intention, or should the exception catching be narrower? I<br>
> know it's clunky to write it in Python, but AIUI it's less so in C:<br>
><br>
> try:<br>
>     callme = path.__fspath__<br>
> except AttributeError:<br>
>     pass<br>
> else:<br>
>     path = callme()<br>
<br>
+1 for this variant; I really don't like masking errors inside the<br>
__fspath__ implementation.<br></blockquote><div><br></div></span><div>Don't read too much into the code in that gist. I just did them quickly to get the point across of the proposals in terms of str/bytes, not what will be proposed in any final patch. </div></div></div>
<br>_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/chris.barker%40noaa.gov" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/chris.barker%40noaa.gov</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div>