unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] python/thread: always return a string in get_subject/authors
@ 2011-05-09  7:06 Anton Khirnov
  2011-05-09 12:10 ` Austin Clements
  2011-05-09 12:20 ` David Bremner
  0 siblings, 2 replies; 9+ messages in thread
From: Anton Khirnov @ 2011-05-09  7:06 UTC (permalink / raw)
  To: notmuch

Now None is returned when those don't exist, which is inconvenient to
deal with.
---
 bindings/python/notmuch/thread.py |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/bindings/python/notmuch/thread.py b/bindings/python/notmuch/thread.py
index eebd6cb..cf26957 100644
--- a/bindings/python/notmuch/thread.py
+++ b/bindings/python/notmuch/thread.py
@@ -281,7 +281,8 @@ class Thread(object):
         """
         if self._thread is None:
             raise NotmuchError(STATUS.NOT_INITIALIZED)
-        return Thread._get_authors(self._thread)
+        ret = Thread._get_authors(self._thread)
+        return ret if ret else ''
 
     def get_subject(self):
         """Returns the Subject of 'thread'
@@ -291,7 +292,8 @@ class Thread(object):
         """
         if self._thread is None:
             raise NotmuchError(STATUS.NOT_INITIALIZED)
-        return Thread._get_subject(self._thread)
+        ret = Thread._get_subject(self._thread)
+        return ret if ret else ''
 
     def get_newest_date(self):
         """Returns time_t of the newest message date
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] python/thread: always return a string in get_subject/authors
  2011-05-09  7:06 [PATCH] python/thread: always return a string in get_subject/authors Anton Khirnov
@ 2011-05-09 12:10 ` Austin Clements
  2011-05-09 12:20 ` David Bremner
  1 sibling, 0 replies; 9+ messages in thread
From: Austin Clements @ 2011-05-09 12:10 UTC (permalink / raw)
  To: Anton Khirnov; +Cc: notmuch

[-- Attachment #1: Type: text/plain, Size: 241 bytes --]

Your commit message is inconsistent with your change; is your intent to
return None or the empty string?  Also, could you modify your commit message
to say what "those" are?
On May 9, 2011 3:06 AM, "Anton Khirnov" <anton@khirnov.net> wrote:

[-- Attachment #2: Type: text/html, Size: 454 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] python/thread: always return a string in get_subject/authors
  2011-05-09  7:06 [PATCH] python/thread: always return a string in get_subject/authors Anton Khirnov
  2011-05-09 12:10 ` Austin Clements
@ 2011-05-09 12:20 ` David Bremner
  2011-05-09 12:57   ` servilio
                     ` (2 more replies)
  1 sibling, 3 replies; 9+ messages in thread
From: David Bremner @ 2011-05-09 12:20 UTC (permalink / raw)
  To: Anton Khirnov, notmuch

On Mon,  9 May 2011 09:06:34 +0200, Anton Khirnov <anton@khirnov.net> wrote:
> Now None is returned when those don't exist, which is inconvenient to
> deal with.

I'm not using the python bindings, but from a philosophical point of
view, this change makes me a bit uncomfortable since it apparently
merges two cases together, and makes an error (no Subject)
indistinguishable from an odd situation (Subject of empty string).
Or am I missing something here?

All the best,

David

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] python/thread: always return a string in get_subject/authors
  2011-05-09 12:20 ` David Bremner
@ 2011-05-09 12:57   ` servilio
  2011-05-09 15:13   ` Anton Khirnov
  2011-05-10  1:00   ` Sebastian Spaeth
  2 siblings, 0 replies; 9+ messages in thread
From: servilio @ 2011-05-09 12:57 UTC (permalink / raw)
  To: David Bremner; +Cc: notmuch

On 9 May 2011 08:20, David Bremner <david@tethera.net> wrote:
> On Mon,  9 May 2011 09:06:34 +0200, Anton Khirnov <anton@khirnov.net> wrote:
>> Now None is returned when those don't exist, which is inconvenient to
>> deal with.
>
> I'm not using the python bindings, but from a philosophical point of
> view, this change makes me a bit uncomfortable since it apparently
> merges two cases together, and makes an error (no Subject)
> indistinguishable from an odd situation (Subject of empty string).
> Or am I missing something here?

I see the the same issue.

Servilio

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] python/thread: always return a string in get_subject/authors
  2011-05-09 12:20 ` David Bremner
  2011-05-09 12:57   ` servilio
@ 2011-05-09 15:13   ` Anton Khirnov
  2011-05-09 15:23     ` Jesse Rosenthal
  2011-05-10  1:00   ` Sebastian Spaeth
  2 siblings, 1 reply; 9+ messages in thread
From: Anton Khirnov @ 2011-05-09 15:13 UTC (permalink / raw)
  To: David Bremner, notmuch

On Mon, 09 May 2011 09:20:41 -0300, David Bremner <david@tethera.net> wrote:
> On Mon,  9 May 2011 09:06:34 +0200, Anton Khirnov <anton@khirnov.net> wrote:
> > Now None is returned when those don't exist, which is inconvenient to
> > deal with.
> 
> I'm not using the python bindings, but from a philosophical point of
> view, this change makes me a bit uncomfortable since it apparently
> merges two cases together, and makes an error (no Subject)
> indistinguishable from an odd situation (Subject of empty string).
> Or am I missing something here?

The question is whether this is really a problem.

For a single message, it might make sense to distinguish between 'no
header' and 'empty header'.

But those aren't message headers, those are thread properties. And I'd
argue that a thread always has authors and a subject (possibly empty).

--
Anton Khirnov

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] python/thread: always return a string in get_subject/authors
  2011-05-09 15:13   ` Anton Khirnov
@ 2011-05-09 15:23     ` Jesse Rosenthal
  2011-05-09 15:26       ` Jesse Rosenthal
  0 siblings, 1 reply; 9+ messages in thread
From: Jesse Rosenthal @ 2011-05-09 15:23 UTC (permalink / raw)
  To: Anton Khirnov, David Bremner, notmuch

On Mon, 09 May 2011 17:13:10 +0200, Anton Khirnov <anton@khirnov.net> wrote:
> But those aren't message headers, those are thread properties. And I'd
> argue that a thread always has authors and a subject (possibly empty).

The RFC says yes on the author, no on the subject. The only things
guaranteed are "From:" and originating timestamp. So I'm not sure why
subject should be guaranteed a string result and not, say, "Cc." 

My sense is that Python users are prety good with testing against None,
especially since (not "") == (not []) == (not None) == True. This change
seems like it would end up producing more inconsistencies with the way
you deal with headers, by producing special cases.

--Jesse

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] python/thread: always return a string in get_subject/authors
  2011-05-09 15:23     ` Jesse Rosenthal
@ 2011-05-09 15:26       ` Jesse Rosenthal
  0 siblings, 0 replies; 9+ messages in thread
From: Jesse Rosenthal @ 2011-05-09 15:26 UTC (permalink / raw)
  To: Anton Khirnov, David Bremner, notmuch


On Mon, 09 May 2011 11:23:16 -0400, Jesse Rosenthal <jrosenthal@jhu.edu> wrote:
> The RFC says yes on the author, no on the subject. The only things
> guaranteed are "From:" and originating timestamp. So I'm not sure why
> subject should be guaranteed a string result and not, say, "Cc." 

Apologies -- I realize now you were talking about threads and not
messages, so I can't defer to RFCs. I still agree with the others, and
about how python users would deal with it. But I see your point better
now. Sorry to clutter.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] python/thread: always return a string in get_subject/authors
  2011-05-09 12:20 ` David Bremner
  2011-05-09 12:57   ` servilio
  2011-05-09 15:13   ` Anton Khirnov
@ 2011-05-10  1:00   ` Sebastian Spaeth
  2011-05-10  1:18     ` Daniel Kahn Gillmor
  2 siblings, 1 reply; 9+ messages in thread
From: Sebastian Spaeth @ 2011-05-10  1:00 UTC (permalink / raw)
  To: David Bremner, Anton Khirnov, notmuch

[-- Attachment #1: Type: text/plain, Size: 1114 bytes --]

On Mon, 09 May 2011 09:20:41 -0300, David Bremner <david@tethera.net> wrote:
> On Mon,  9 May 2011 09:06:34 +0200, Anton Khirnov <anton@khirnov.net> wrote:
> > Now None is returned when those don't exist, which is inconvenient to
> > deal with.
> 
> I'm not using the python bindings, but from a philosophical point of
> view, this change makes me a bit uncomfortable since it apparently
> merges two cases together, and makes an error (no Subject)
> indistinguishable from an odd situation (Subject of empty string).
> Or am I missing something here?

Hi there,

This change makes me a bit uncomfortable too. 3 Reasons:

- I believe users should be able to distinguish the case when someone
  uses an empty subject, and when someone doesn't specify a subject at
  all.

- People have been writing code and breaking backwards compatability for
  such a small gain doesn't really seem worth it.

- Testing-wise this is easy. Just test for "if subject:" on the returned
  value and you'll get both cases (empty and non-existing).

But if people really want it, I won't object.

Sebastian

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] python/thread: always return a string in get_subject/authors
  2011-05-10  1:00   ` Sebastian Spaeth
@ 2011-05-10  1:18     ` Daniel Kahn Gillmor
  0 siblings, 0 replies; 9+ messages in thread
From: Daniel Kahn Gillmor @ 2011-05-10  1:18 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 1189 bytes --]

On 05/09/2011 09:00 PM, Sebastian Spaeth wrote:
> On Mon, 09 May 2011 09:20:41 -0300, David Bremner <david@tethera.net> wrote:
>> On Mon,  9 May 2011 09:06:34 +0200, Anton Khirnov <anton@khirnov.net> wrote:
>>> Now None is returned when those don't exist, which is inconvenient to
>>> deal with.
>>
>> I'm not using the python bindings, but from a philosophical point of
>> view, this change makes me a bit uncomfortable since it apparently
>> merges two cases together, and makes an error (no Subject)
>> indistinguishable from an odd situation (Subject of empty string).
>> Or am I missing something here?
> 
> This change makes me a bit uncomfortable too. 3 Reasons:
> 
> - I believe users should be able to distinguish the case when someone
>   uses an empty subject, and when someone doesn't specify a subject at
>   all.

I'm going to "me too!" this sentiment as well.  Please do *not* conflate
no-subject with subject-is-empty-string.

If we leave them distinct, the caller is free to conflate them if they
want.  But if we conflate the two states first, there's no way for the
caller to differentiate between the two if they want to.

Thanks,

	--dkg


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 1030 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-05-10  1:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-09  7:06 [PATCH] python/thread: always return a string in get_subject/authors Anton Khirnov
2011-05-09 12:10 ` Austin Clements
2011-05-09 12:20 ` David Bremner
2011-05-09 12:57   ` servilio
2011-05-09 15:13   ` Anton Khirnov
2011-05-09 15:23     ` Jesse Rosenthal
2011-05-09 15:26       ` Jesse Rosenthal
2011-05-10  1:00   ` Sebastian Spaeth
2011-05-10  1:18     ` Daniel Kahn Gillmor

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).