Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8448

Re: those darn exceptions

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '(except': 0.05; 'typing': 0.05; 'raised': 0.07; 'raises': 0.07; 'exceptions': 0.09; 'stable.': 0.09; 'api': 0.11; 'am,': 0.13; 'wrote:': 0.15; '*any*': 0.16; 'experiment.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hypothetical': 0.16; 'interface?': 0.16; 'nameerror': 0.16; 'rerun': 0.16; 'somehow,': 0.16; 'subject:those': 0.16; 'whom?': 0.16; 'written': 0.17; 'received:209.85.210.174': 0.19; 'received:mail- iy0-f174.google.com': 0.19; 'simpler': 0.19; 'starts': 0.19; "haven't": 0.21; 'java': 0.21; 'file,': 0.22; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'code.': 0.22; 'calls.': 0.23; 'ensuring': 0.23; 'incorrect': 0.23; 'replacing': 0.23; 'stops': 0.23; 'tool,': 0.23; 'code': 0.24; 'there.': 0.25; 'expect': 0.25; 'function': 0.26; 'work.': 0.28; 'beyond': 0.28; 'message- id:@mail.gmail.com': 0.28; 'right,': 0.28; '(even': 0.29; 'answered': 0.29; 'lists': 0.29; 'code,': 0.29; 'object': 0.30; 'fact': 0.30; 'can.': 0.30; 'sun,': 0.30; "they'll": 0.30; 'tool.': 0.30; 'useless': 0.30; 'least': 0.31; "won't": 0.32; 'chris': 0.32; 'list': 0.33; 'me?': 0.33; 'it.': 0.33; 'asking': 0.33; 'source': 0.33; 'to:addr:python-list': 0.34; "can't": 0.34; 'then.': 0.35; "isn't": 0.35; 'probably': 0.35; 'supposed': 0.35; '(for': 0.36; 'idea': 0.36; 'limitation': 0.37; 'anything': 0.37; 'listed': 0.37; 'passed': 0.37; 'received:google.com': 0.37; 'but': 0.37; 'received:209.85': 0.38; 'issue': 0.38; 'could': 0.38; 'think': 0.38; 'subject:: ': 0.38; 'considered': 0.38; 'should': 0.39; 'unless': 0.39; 'run': 0.39; 'difficult': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'might': 0.40; 'skip:z 10': 0.40; 'sense': 0.40; "i'd": 0.40; 'where': 0.40; 'would': 0.40; 'agreed': 0.40; 'more': 0.60; 'questions,': 0.61; 'believe': 0.66; '26,': 0.67; 'jun': 0.67; 'hey,': 0.74; 'serious': 0.78; '"most': 0.84; '12:28': 0.84; 'conclusion.': 0.84; 'ignorant': 0.84; 'namely': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=4ou6T2lAUjgw7rEM6fr39ZBsXbOz1V7fp3+W8eOcNfc=; b=d462OnteqcrclC/XJl6gCOXC0/iysP8bTYhiP3hEBIH1hi44yunhbGzwgAZCVvYsza sTKiNBGFYugJpkwRppRre6OpKC6UqazbG53/WklzAApRH/rnlT3WWavZry1NYwA1CKqB 9fnRg91ZNc3Df1NX1hSbw2pqQYxFbvs7aSoDA=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=QyrmPw8kraGOJ5nfEb06229LKANpEaoS9lij4SI6Gxk8uPfmXErY1H9HO/rcygT/sF dK87Ticxn0Y+2X2dJcX39CILohIXZwySaWe38mTMjjJzqs5VViBQGbvRc+g+b+UlcQZS b9OFm3Ss7HR9/KWTTFq7e3Bpw7TpaBd2K3Ujs=
MIME-Version 1.0
In-Reply-To <4e05f0a7$0$29979$c3e8da3$5496439d@news.astraweb.com>
References <itot0b022i@news4.newsguy.com> <96gb36Fc65U1@mid.individual.net> <iu00uh2dhg@news3.newsguy.com> <96itucFadiU1@mid.individual.net> <iu2kif0coj@news4.newsguy.com> <87d3i2oiyo.fsf@benfinney.id.au> <mailman.401.1308974152.1164.python-list@python.org> <4e05f0a7$0$29979$c3e8da3$5496439d@news.astraweb.com>
Date Sun, 26 Jun 2011 01:52:34 +1000
Subject Re: those darn exceptions
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.406.1309017159.1164.python-list@python.org> (permalink)
Lines 69
NNTP-Posting-Host 82.94.164.166
X-Trace 1309017159 news.xs4all.nl 4368 [::ffff:82.94.164.166]:32784
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:8448

Show key headers only | View raw


On Sun, Jun 26, 2011 at 12:28 AM,  <steve+comp.lang.python@pearwood.info> wrote:
> Chris Angelico wrote:
>
>> Sure it can. And KeyboardInterrupt could be raised at any time, too.
>> But this is a TOOL, not a deity. If Function X is known to call
>> Function Y and built-in method Z,
>
> Known by whom? You? Me? The author of X, Y or Z? Everybody? The tool?
>
> How is the tool supposed to know which functions are called? What if it
> doesn't have access to the source code of Y? It might only be available via
> a .pyc file, or it might be written in C, or Fortran, or Java (for Jython),
> or C# (for IronPython).

The idea I was toying with was that it would have the source to X, so
it knows that it calls Y. Unfortunately duck typing makes that
difficult for anything where an object is passed in, but it's at least
possible with simpler calls.

> Who is responsible for ensuring that every time the implementation of *any*
> of X, Y and Z change, the list of exceptions is updated? What do you think
> the chances are that this list will remain accurate after a few years of
> maintenance?

The tool would be run on a snapshot of code. If you update the code,
you rerun it.

> Is this list of exceptions part of the API of function X? Should X be held
> responsible if Z stops raising (say) AttributeError and starts raising
> NameError instead?
>
> Should the *implementation* of X, namely the fact that it calls Y and Z, now
> considered part of the public interface?

Again, not an issue if you don't expect it to be stable. You just look
at how the code functions _now_.

> These are serious questions, not nit-picks. Unless they can be answered
> satisfactorily, this hypothetical tool *cannot exist*. It simply won't
> work. I believe that you might as well be asking for a deity, because the
> tool will need supernatural powers beyond the abilities of ordinary code.

Yep. And because of duck typing, the information isn't really there. I
think you're right that it's impossible.

> And I haven't even raised the spectre of replacing functions (even builtins)
> at runtime, or the use of eval/exec, or any number of other tricks.

Right, but this tool would simply be useless then.

>> and also raises FooException, then
>> X's list of "most likely exceptions" would be FooException +
>> Y.__exceptions__ + Z.__exceptions__.
>
> Even if you somehow, magically, know that X calls Y and Z, you can't draw
> that conclusion. Lists of exceptions don't add like that. Consider:

Again, that would be a limitation of the tool. I'd prefer that it
listed more exceptions than less.

> All this will do is lull people into a false sense of security as they come
> to rely on incorrect and out-of-date information. They'll still be in as
> ignorant a position re exceptions as they are now, only they won't know it.

Yep. Agreed (except for the out-of-date qualifier), and that probably
means this won't be of much use. But hey, it was an interesting
thought experiment.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

those darn exceptions Chris Torek <nospam@torek.net> - 2011-06-21 01:43 +0000
  Re: those darn exceptions Chris Angelico <rosuav@gmail.com> - 2011-06-21 13:19 +1000
    Re: those darn exceptions Chris Torek <nospam@torek.net> - 2011-06-21 04:40 +0000
  Re: those darn exceptions Ben Finney <ben+python@benfinney.id.au> - 2011-06-21 14:04 +1000
  Re: those darn exceptions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-21 09:49 +0000
    Re: those darn exceptions Chris Torek <nospam@torek.net> - 2011-06-21 21:51 +0000
      Re: those darn exceptions John Nagle <nagle@animats.com> - 2011-06-27 11:52 -0700
  Re: those darn exceptions Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-06-23 20:16 +1200
    Re: those darn exceptions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-23 18:40 +1000
    Re: those darn exceptions Chris Torek <nospam@torek.net> - 2011-06-23 18:33 +0000
      Re: those darn exceptions Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-06-24 19:50 +1200
        Re: those darn exceptions Chris Torek <nospam@torek.net> - 2011-06-24 18:21 +0000
          Re: those darn exceptions Ben Finney <ben+python@benfinney.id.au> - 2011-06-25 10:25 +1000
            Re: those darn exceptions Chris Angelico <rosuav@gmail.com> - 2011-06-25 13:55 +1000
              Re: those darn exceptions steve+comp.lang.python@pearwood.info - 2011-06-26 00:28 +1000
                Re: those darn exceptions Chris Angelico <rosuav@gmail.com> - 2011-06-26 01:52 +1000

csiph-web