summaryrefslogtreecommitdiff
path: root/tickets/b6df8a5d7d3d4b7e8c2ddf8c95cfc33d/Maildir/new/1455999000.M301296P17339Q104.exolobe1
blob: a2ead322de10cba295af971e9c762eaef73aac2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
Return-Path: <obnam-dev-bounces@obnam.org>
X-Original-To: distix@pieni.net
Delivered-To: distix@pieni.net
Received: from bagpuss.pepperfish.net (bagpuss.pepperfish.net [148.251.8.16])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by pieni.net (Postfix) with ESMTPS id C58A02D9DB
	for <distix@pieni.net>; Sun, 11 Oct 2015 10:40:13 +0200 (CEST)
Received: from platypus.pepperfish.net (unknown [10.112.100.20])
	by bagpuss.pepperfish.net (Postfix) with ESMTP id 4C787256;
	Sun, 11 Oct 2015 09:40:13 +0100 (BST)
Received: from ip6-localhost ([::1] helo=platypus.pepperfish.net)
	by platypus.pepperfish.net with esmtp (Exim 4.80 #2 (Debian))
	id 1ZlCAv-0005VY-6u; Sun, 11 Oct 2015 09:40:13 +0100
Received: from inmail0 ([10.112.100.10] helo=mx0.pepperfish.net)
 by platypus.pepperfish.net with esmtp (Exim 4.80 #2 (Debian))
 id 1ZlCAt-0005VE-6f
 for <obnam-dev@obnam.org>; Sun, 11 Oct 2015 09:40:11 +0100
Received: from pieni.net ([95.142.166.37] ident=postfix)
 by mx0.pepperfish.net with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256)
 (Exim 4.80) (envelope-from <liw@liw.fi>) id 1ZlCAr-0005tD-7J
 for obnam-dev@obnam.org; Sun, 11 Oct 2015 09:40:11 +0100
Received: from exolobe1.liw.fi (82-181-8-107.bb.dnainternet.fi [82.181.8.107])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by pieni.net (Postfix) with ESMTPSA id 4C1642D9C1;
 Sun, 11 Oct 2015 10:40:03 +0200 (CEST)
Received: from exolobe1.liw.fi (localhost [127.0.0.1])
 by exolobe1.liw.fi (Postfix) with ESMTPS id 95D314084D;
 Sun, 11 Oct 2015 11:40:02 +0300 (EEST)
Date: Sun, 11 Oct 2015 11:40:01 +0300
From: Lars Wirzenius <liw@liw.fi>
To: Lars Kruse <lists@sumpfralle.de>
Message-ID: <20151011084001.GN2384@exolobe1.liw.fi>
References: <1441948936-12526-1-git-send-email-mathstuf@gmail.com>
 <1443159474-27126-1-git-send-email-mathstuf@gmail.com>
 <1443159474-27126-2-git-send-email-mathstuf@gmail.com>
 <20150925131218.50af1dcd@erker.lan>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20150925131218.50af1dcd@erker.lan>
User-Agent: Mutt/1.5.23 (2014-03-12)
X-Spam-Score: -3.4
X-Spam-Score-int: -33
X-Spam-Bar: ---
X-Scanned-By: pepperfish.net, Sun, 11 Oct 2015 09:40:11 +0100
X-Spam-Report: Content analysis details: (-3.4 points)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 PPF_USER_AGENT_MUTT    User-Agent: contains Mutt (Mutt isn't a spam
 tool) -0.5 PPF_USER_AGENT         User-Agent: exists
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-ACL-Warn: message may be spam
X-Scan-Signature: 78c34a7242bc3b0cdb4980a2406d4978
Cc: obnam-dev@obnam.org
Subject: Re: [PATCH v4 1/4] encryption: refactor _gpg_pipe to use _gpg
X-BeenThere: obnam-dev@obnam.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Obnam development discussions <obnam-dev-obnam.org>
List-Unsubscribe: <http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/obnam-dev-obnam.org>,
 <mailto:obnam-dev-request@obnam.org?subject=unsubscribe>
List-Archive: <http://listmaster.pepperfish.net/pipermail/obnam-dev-obnam.org>
List-Post: <mailto:obnam-dev@obnam.org>
List-Help: <mailto:obnam-dev-request@obnam.org?subject=help>
List-Subscribe: <http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/obnam-dev-obnam.org>,
 <mailto:obnam-dev-request@obnam.org?subject=subscribe>
Sender: obnam-dev-bounces@obnam.org
Errors-To: obnam-dev-bounces@obnam.org

On Fri, Sep 25, 2015 at 01:12:18PM +0200, Lars Kruse wrote:
> Hi Ben,
> 
> I appreciate the configurable gpg keyring directory without using
> GNUPGHOME as introduced by your patch!
> 
> Even though I do not really feel entitled to comment on your patch,
> I feel the urge to ask a question.
> 
> The following lines contain a catch-all except expression:
> 
> +    try:
> +        out = _gpg(args + ['--passphrase-fd', str(keypipe[0])], stdin=data)
> +    except: # pragma: no cover
> +        ...
> 
> As far as I understand the code of "_gpg", I would expect only OSError
> exceptions. Wouldn't it be sufficient to catch only this one?
> (catching things like NameError can be very confusing)

Catching every type of exception with a bare "except:" is, in fact,
usually a mistake. It means that if there is a NameError or, in
extreme cases, a SyntaxError (in dynamically loaded code), it gets
caught. However, in a few special cases, it's still OK, and in this
case it's OK. The special case in this instance is this pattern:

    try:
        do_something()
    except:
        do_cleanup_that_must_always_be_done()
        raise

The last line is important. It re-raises the original exception as if
there was ny try/except. The cleanup gets done anyway, and in Ben's
code it closes a file descriptior, and that needs to be done
regardless of what the error was. Otherwise, if upper layers of the
code catch the exception and continues running the program, the file
descriptor leaks and if this happens often enough, it results in the
process not being able to open new files.

So I'm OK with this part of the code. (Haven't looked in detail the
rest, yet.)

An example of a bare "except:" that I don't approve of:

    try:
        do_some_input_output(foo)
    except:
        sys.stdout.write("Write error!!!!!!!\n"
        sys.exit(1)

In this case, the error message can be entirely wrong about the reason
of the error. If the variable foo doesn't exist, or has the wrong
type, or the function has the wrong number of arguments, or any other
such reason, the exception thrown is not because there was a write
error. The user will be confused. Worse, the programmer trying to
debug this will be confused.

I now fully expect people to start pointing out places in my own code
where I've done that. That'd be good.

-- 
Schrödinger's backup hypothesis: the condition of any backup is
undefined until a restore is attempted. -- andrewsh

_______________________________________________
obnam-dev mailing list
obnam-dev@obnam.org
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/obnam-dev-obnam.org