unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] use notmuch_database_open_verbose
@ 2016-03-12 15:17 Patrick Totzke
  2016-03-12 16:26 ` David Bremner
  0 siblings, 1 reply; 5+ messages in thread
From: Patrick Totzke @ 2016-03-12 15:17 UTC (permalink / raw)
  To: notmuch

... instead of the deprecated notmuch_database_open
when opening the database in notmuch.database.Database.open.
This prevents the library to print Xapian exceptions to stderr.
---
 bindings/python/notmuch/database.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py
index f304533..5400338 100644
--- a/bindings/python/notmuch/database.py
+++ b/bindings/python/notmuch/database.py
@@ -86,8 +86,8 @@ class Database(object):
     _get_version.argtypes = [NotmuchDatabaseP]
     _get_version.restype = c_uint
 
-    """notmuch_database_open"""
-    _open = nmlib.notmuch_database_open
+    """notmuch_database_open_verbose"""
+    _open = nmlib.notmuch_database_open_verbose
     _open.argtypes = [c_char_p, c_uint, POINTER(NotmuchDatabaseP)]
     _open.restype = c_uint
 
@@ -201,7 +201,7 @@ class Database(object):
 
         This function is used by __init__() and usually does not need
         to be called directly. It wraps the underlying
-        *notmuch_database_open* function.
+        *notmuch_database_open_verbose* function.
 
         :param status: Open the database in read-only or read-write mode
         :type status:  :attr:`MODE`
-- 
2.7.0

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

* Re: [PATCH] use notmuch_database_open_verbose
  2016-03-12 15:17 [PATCH] use notmuch_database_open_verbose Patrick Totzke
@ 2016-03-12 16:26 ` David Bremner
  2016-03-12 16:33   ` David Bremner
  0 siblings, 1 reply; 5+ messages in thread
From: David Bremner @ 2016-03-12 16:26 UTC (permalink / raw)
  To: Patrick Totzke, notmuch

Patrick Totzke <patricktotzke@gmail.com> writes:

> ... instead of the deprecated notmuch_database_open

Perhaps it should be formally deprecated, but unlike several other
functions, it isn't.

> when opening the database in notmuch.database.Database.open.
> This prevents the library to print Xapian exceptions to stderr.
> ---
>  bindings/python/notmuch/database.py | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py
> index f304533..5400338 100644
> --- a/bindings/python/notmuch/database.py
> +++ b/bindings/python/notmuch/database.py
> @@ -86,8 +86,8 @@ class Database(object):
>      _get_version.argtypes = [NotmuchDatabaseP]
>      _get_version.restype = c_uint
>  
> -    """notmuch_database_open"""
> -    _open = nmlib.notmuch_database_open
> +    """notmuch_database_open_verbose"""
> +    _open = nmlib.notmuch_database_open_verbose
>      _open.argtypes = [c_char_p, c_uint, POINTER(NotmuchDatabaseP)]
>      _open.restype = c_uint

I expect you probably want to add the new binding, rather than replacing
the old one. Otherwise updating the bindings will break all bindings
using scripts.

d

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

* Re: [PATCH] use notmuch_database_open_verbose
  2016-03-12 16:26 ` David Bremner
@ 2016-03-12 16:33   ` David Bremner
  2016-03-13 12:03     ` Patrick Totzke
       [not found]     ` <CAM7JpKmVzZYZ8bpjc5qzWvBedKx4GT-y+EKWS1KQgZJ_LamKNw@mail.gmail.com>
  0 siblings, 2 replies; 5+ messages in thread
From: David Bremner @ 2016-03-12 16:33 UTC (permalink / raw)
  To: Patrick Totzke, notmuch

David Bremner <david@tethera.net> writes:

>> -    """notmuch_database_open"""
>> -    _open = nmlib.notmuch_database_open
>> +    """notmuch_database_open_verbose"""
>> +    _open = nmlib.notmuch_database_open_verbose
>>      _open.argtypes = [c_char_p, c_uint, POINTER(NotmuchDatabaseP)]
>>      _open.restype = c_uint
>
> I expect you probably want to add the new binding, rather than replacing
> the old one. Otherwise updating the bindings will break all bindings
> using scripts.

Oh silly me. That's not actually exposed to the python API, so that's
fine. On the other hand, don't you want to update the argument types and
do something useful (throw an exception?) with the returned message?  As
it stands you lose information.

d

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

* Re: [PATCH] use notmuch_database_open_verbose
  2016-03-12 16:33   ` David Bremner
@ 2016-03-13 12:03     ` Patrick Totzke
       [not found]     ` <CAM7JpKmVzZYZ8bpjc5qzWvBedKx4GT-y+EKWS1KQgZJ_LamKNw@mail.gmail.com>
  1 sibling, 0 replies; 5+ messages in thread
From: Patrick Totzke @ 2016-03-13 12:03 UTC (permalink / raw)
  To: David Bremner; +Cc: notmuch@notmuchmail.org

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

As far as I understand the bindings, the returned message is not needed
because the return
value of `Database._open` (line 212) contains information about the type of
error that occurred.
This is passed on two lines below if the open-call was unsuccessful.

The docstrings for this method are not ideal (the mentioned "status"
parameter is actually called "mode") but in terms of functionality it seems
ok.

On 12 March 2016 at 16:33, David Bremner <david@tethera.net> wrote:

> David Bremner <david@tethera.net> writes:
>
> >> -    """notmuch_database_open"""
> >> -    _open = nmlib.notmuch_database_open
> >> +    """notmuch_database_open_verbose"""
> >> +    _open = nmlib.notmuch_database_open_verbose
> >>      _open.argtypes = [c_char_p, c_uint, POINTER(NotmuchDatabaseP)]
> >>      _open.restype = c_uint
> >
> > I expect you probably want to add the new binding, rather than replacing
> > the old one. Otherwise updating the bindings will break all bindings
> > using scripts.
>
> Oh silly me. That's not actually exposed to the python API, so that's
> fine. On the other hand, don't you want to update the argument types and
> do something useful (throw an exception?) with the returned message?  As
> it stands you lose information.
>
> d
>

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

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

* Re: [PATCH] use notmuch_database_open_verbose
       [not found]     ` <CAM7JpKmVzZYZ8bpjc5qzWvBedKx4GT-y+EKWS1KQgZJ_LamKNw@mail.gmail.com>
@ 2016-03-13 12:37       ` David Bremner
  0 siblings, 0 replies; 5+ messages in thread
From: David Bremner @ 2016-03-13 12:37 UTC (permalink / raw)
  To: patricktotzke; +Cc: notmuch

Patrick Totzke <patricktotzke@gmail.com> writes:

> As far as I understand the bindings, the returned message is not needed
> because the return
> value of `Database._open` (line 212) contains information about the type of
> error that occurred.
> This is passed on two lines below if the open-call was unsuccessful.
>
> The docstrings for this method are not ideal (the mentioned "status"
> parameter is actually called "mode") but in terms of functionality it seems
> ok.

The error_message parameter (potentially) contains additional
information about an error. In any case, you're passing one too few
arguments to n_d_open_verbose, which doesn't seem like a good idea.

d

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

end of thread, other threads:[~2016-03-13 12:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-12 15:17 [PATCH] use notmuch_database_open_verbose Patrick Totzke
2016-03-12 16:26 ` David Bremner
2016-03-12 16:33   ` David Bremner
2016-03-13 12:03     ` Patrick Totzke
     [not found]     ` <CAM7JpKmVzZYZ8bpjc5qzWvBedKx4GT-y+EKWS1KQgZJ_LamKNw@mail.gmail.com>
2016-03-13 12:37       ` David Bremner

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).