A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20120503/36cd9bf4/attachment.html below:

<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    On 05/03/2012 10:07 PM, Benjamin Peterson wrote:<br>
    <blockquote
cite="mid:CAPZV6o_t5dahdxpVybRh2ca0ts76oioZf+Y_vh65g0KwsFRUaA@mail.gmail.com"
      type="cite">
      <blockquote type="cite">
        <pre wrap="">+ Â  Â if (times &amp;&amp; ns) {
+ Â  Â  Â  Â PyErr_Format(PyExc_RuntimeError,
</pre>
      </blockquote>
      <pre wrap="">Why not a ValueError or TypeError?</pre>
    </blockquote>
    <br>
    Well it's certainly not a TypeError.  The 3.2 documentation defines
    TypeError as:<br>
    <blockquote>Raised when an operation or function is applied to an
      object of inappropriate type. The associated value is a string
      giving details about the type mismatch.<br>
    </blockquote>
    If someone called os.utime with both times and ns, and the values of
    each would have been legal if they'd been passed in in isolation,
    what would be the type mismatch?<br>
    <br>
    <br>
    ValueError seems like a stretch.  The 3.2 documentation defines
    ValueError as<br>
    <blockquote>Raised when a built-in operation or function receives an
      argument that has the right type but an inappropriate value, and
      the situation is not described by a more precise exception such as
      IndexError.<br>
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    </blockquote>
    To me this describes a specific class of errors where a single value
    is invalid in isolation, like an overly-long string for a path on
    Windows, or a negative integer for some integer value that must
    always be 0 or greater.  The error with utime is a different sort of
    error; you are passing in two presumably legal values, but the
    function requires that you pass in at most one.<br>
    <br>
    The only way I can see ValueError as being the right choice is from
    the awkward perspective of "if you passed in times, then the only
    valid value for ns is None" (or vice-versa).<br>
    <br>
    Are there existing APIs that use ValueError for just this sort of
    situation?  I dimly recall there being something like this but I
    can't recall it.<br>
    <br>
    Is using RuntimeError some sort of Pythonic faux pas?<br>
    <br>
    <br>
    <blockquote
cite="mid:CAPZV6o_t5dahdxpVybRh2ca0ts76oioZf+Y_vh65g0KwsFRUaA@mail.gmail.com"
      type="cite">
      <blockquote type="cite">
        <pre wrap="">+ Â  Â if (times &amp;&amp; (times != Py_None)) {
</pre>
      </blockquote>
      <pre wrap="">Conditions in parenthesis like this is not style.</pre>
    </blockquote>
    <br>
    Can you point me to where this is described in PEP 7?  I can't find
    it.<br>
    <br>
    <br>
    <blockquote
cite="mid:CAPZV6o_t5dahdxpVybRh2ca0ts76oioZf+Y_vh65g0KwsFRUaA@mail.gmail.com"
      type="cite">
      <blockquote type="cite">
        <pre wrap="">+ Â  Â  Â  Â return (_PyTime_ObjectToTimespec(PyTuple_GET_ITEM(times, 0),
+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â &amp;(ua-&gt;atime_s), &amp;(ua-&gt;atime_ns)) != -1)
+ Â  Â  Â  Â  Â  Â &amp;&amp; (_PyTime_ObjectToTimespec(PyTuple_GET_ITEM(times, 1),
</pre>
      </blockquote>
      <pre wrap="">Put &amp;&amp; on previous line like Python.</pre>
    </blockquote>
    <br>
    Okay.<br>
    <br>
    Since I have questions regarding two of your three suggested
    changes, I'll hold off on making any changes until the dust settles
    a little.<br>
    <br>
    <br>
    Finally, I appreciate the feedback, but... why post it to
    python-dev?  You could have sent me private email, or posted to the
    issue (#14127), the latter of which would have enabled using rich
    chocolaty Rietveld.  I've seen a bunch of comments on checkins
    posted here and it all leaves me scratching my head.<br>
    <br>
    <br>
    <i>/arry</i><br>
  </body>
</html>

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4