[PATCH] python: deprecated add_message calls index_file correctly and returns result

classic Classic list List threaded Threaded
10 messages Options
Gaute Hope Gaute Hope
Reply | Threaded
Open this post in threaded view
|

[PATCH] python: deprecated add_message calls index_file correctly and returns result

The deprecated Database.add_message now calls the new index_file with
correct number of arguments (without an extra `self`), and returns the
tuple from index_file - as it used to do before.
---
 bindings/python/notmuch/database.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py
index a2c025eb..6199f58b 100644
--- a/bindings/python/notmuch/database.py
+++ b/bindings/python/notmuch/database.py
@@ -471,7 +471,7 @@ class Database(object):
     def add_message(self, filename, sync_maildir_flags=False):
         """Deprecated alias for :meth:`index_file`
         """
-        self.index_file(self, filename, sync_maildir_flags=sync_maildir_flags)
+        return self.index_file(filename, sync_maildir_flags=sync_maildir_flags)
 
     _remove_message = nmlib.notmuch_database_remove_message
     _remove_message.argtypes = [NotmuchDatabaseP, c_char_p]
--
2.14.1

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] python: deprecated add_message calls index_file correctly and returns result

On Mon, Aug 28 2017, Gaute Hope wrote:

> The deprecated Database.add_message now calls the new index_file with
> correct number of arguments (without an extra `self`), and returns the
> tuple from index_file - as it used to do before.

Instead of this change, should we just dump the whole function...

... although this looks good what message are we giving by committing
changes to deprecated functions (unless this is not deprecated enough ;)

Tomi


> ---
>  bindings/python/notmuch/database.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py
> index a2c025eb..6199f58b 100644
> --- a/bindings/python/notmuch/database.py
> +++ b/bindings/python/notmuch/database.py
> @@ -471,7 +471,7 @@ class Database(object):
>      def add_message(self, filename, sync_maildir_flags=False):
>          """Deprecated alias for :meth:`index_file`
>          """
> -        self.index_file(self, filename, sync_maildir_flags=sync_maildir_flags)
> +        return self.index_file(filename, sync_maildir_flags=sync_maildir_flags)
>  
>      _remove_message = nmlib.notmuch_database_remove_message
>      _remove_message.argtypes = [NotmuchDatabaseP, c_char_p]
> --
> 2.14.1
>
> _______________________________________________
> notmuch mailing list
> [hidden email]
> https://notmuchmail.org/mailman/listinfo/notmuch
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Gaute Hope Gaute Hope
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] python: deprecated add_message calls index_file correctly and returns result

Tomi Ollila writes on august 30, 2017 0:00:

> On Mon, Aug 28 2017, Gaute Hope wrote:
>
>> The deprecated Database.add_message now calls the new index_file with
>> correct number of arguments (without an extra `self`), and returns the
>> tuple from index_file - as it used to do before.
>
> Instead of this change, should we just dump the whole function...
>
> ... although this looks good what message are we giving by committing
> changes to deprecated functions (unless this is not deprecated enough ;)

Ok.. would that not be an argument against keeping any deprecated
functions? Then n_d_add_message should perhaps be removed as well.

It would be a good idea to use `warnings` and `DeprecationWarning` here.

This deprecation-function wrapper is flawed though: the function
signature is changed from the original, and it does not correctly call
the new function. It is not valid python code.

Original change: id:[hidden email]

Regards, Gaute

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] python: deprecated add_message calls index_file correctly and returns result

On Wed, Aug 30 2017, Gaute Hope wrote:

> Tomi Ollila writes on august 30, 2017 0:00:
>> On Mon, Aug 28 2017, Gaute Hope wrote:
>>
>>> The deprecated Database.add_message now calls the new index_file with
>>> correct number of arguments (without an extra `self`), and returns the
>>> tuple from index_file - as it used to do before.
>>
>> Instead of this change, should we just dump the whole function...
>>
>> ... although this looks good what message are we giving by committing
>> changes to deprecated functions (unless this is not deprecated enough ;)
>
> Ok.. would that not be an argument against keeping any deprecated
> functions? Then n_d_add_message should perhaps be removed as well.
>
> It would be a good idea to use `warnings` and `DeprecationWarning` here.
>
> This deprecation-function wrapper is flawed though: the function
> signature is changed from the original, and it does not correctly call
> the new function. It is not valid python code.
>
> Original change: id:[hidden email]

Thanks for that information. Perhaps it is just simplest and least
effort taking action to apply that change of yours
id:[hidden email]
(and it makes some users happier for the time being)

Tomi

>
> Regards, Gaute
>
> _______________________________________________
> notmuch mailing list
> [hidden email]
> https://notmuchmail.org/mailman/listinfo/notmuch
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Gaute Hope Gaute Hope
Reply | Threaded
Open this post in threaded view
|

[PATCH v2] python: deprecated add_message calls index_file correctly and returns result

In reply to this post by Gaute Hope
The deprecated Database.add_message now calls the new index_file with
correct number of arguments (without an extra `self`), and returns the
tuple from index_file - as it used to do before.

This change also adds a DeprecationWarning to the function.
---
 bindings/python/notmuch/database.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py
index a2c025eb..1279804a 100644
--- a/bindings/python/notmuch/database.py
+++ b/bindings/python/notmuch/database.py
@@ -19,6 +19,7 @@ Copyright 2010 Sebastian Spaeth <[hidden email]>
 
 import os
 import codecs
+import warnings
 from ctypes import c_char_p, c_void_p, c_uint, byref, POINTER
 from .compat import SafeConfigParser
 from .globals import (
@@ -471,7 +472,10 @@ class Database(object):
     def add_message(self, filename, sync_maildir_flags=False):
         """Deprecated alias for :meth:`index_file`
         """
-        self.index_file(self, filename, sync_maildir_flags=sync_maildir_flags)
+        warnings.warn(
+                "This function is deprecated and will be removed in the future, use index_file.", DeprecationWarning)
+
+        return self.index_file(filename, sync_maildir_flags=sync_maildir_flags)
 
     _remove_message = nmlib.notmuch_database_remove_message
     _remove_message.argtypes = [NotmuchDatabaseP, c_char_p]
--
2.14.1

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Daniel Kahn Gillmor Daniel Kahn Gillmor
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2] python: deprecated add_message calls index_file correctly and returns result

On Wed 2017-08-30 10:16:33 +0200, Gaute Hope wrote:
> The deprecated Database.add_message now calls the new index_file with
> correct number of arguments (without an extra `self`), and returns the
> tuple from index_file - as it used to do before.
>
> This change also adds a DeprecationWarning to the function.

lgtm.  thanks for fixing my bugs, Gaute.

       --dkg
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2] python: deprecated add_message calls index_file correctly and returns result

In reply to this post by Gaute Hope
Gaute Hope <[hidden email]> writes:

> The deprecated Database.add_message now calls the new index_file with
> correct number of arguments (without an extra `self`), and returns the
> tuple from index_file - as it used to do before.
>
> This change also adds a DeprecationWarning to the function.

Pushed to master, thanks

d
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Dylan Baker Dylan Baker
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2] python: deprecated add_message calls index_file correctly and returns result

The broken commit is in 0.25.1, but this patch isn't correct? It's going to
break alot if that's the case.

Dylan

Quoting David Bremner (2017-09-12 11:28:17)

> Gaute Hope <[hidden email]> writes:
>
> > The deprecated Database.add_message now calls the new index_file with
> > correct number of arguments (without an extra `self`), and returns the
> > tuple from index_file - as it used to do before.
> >
> > This change also adds a DeprecationWarning to the function.
>
> Pushed to master, thanks
>
> d
> _______________________________________________
> notmuch mailing list
> [hidden email]
> https://notmuchmail.org/mailman/listinfo/notmuch

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch

signature.asc (499 bytes) Download Attachment
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2] python: deprecated add_message calls index_file correctly and returns result

Dylan Baker <[hidden email]> writes:

> The broken commit is in 0.25.1, but this patch isn't correct? It's going to
> break alot if that's the case.
>
> Dylan

I don't believe b10ce6bc2 is in 0.25.1; it's in master, and 0.25.1 is
merged into master, so maybe that's the source of confusion.

%-% git log --oneline  0.24..0.25.1 bindings/python        
0fa257cb version: bump to 0.25.1
7a4c60e4 version: bump to 0.25
b8ccfe34 version: bump to 0.25~rc1
87bdfbc9 Fix orthography
694e443d version: bump version to 0.25~rc0
1ec63446 Merge branch 'release'
4fb08341 version: bump to 0.24.2
d877240f Merge branch 'release'
d9ec7e34 version: bump to 0.24.1
a35040ee python: bump SOVERSION to 5
3721bd45 lib: replace deprecated n_q_count_threads with status returning version
5ce8e0b1 lib: replace deprecated n_q_count_messages with status returning version
86cbd215 lib: replace deprecated n_q_search_messages with status returning version
1e982de5 lib: replace n_query_search_threads with status returning version
c0c56455 Merge branch 'release'
a39a1ee1 bindings/python: add bindings for notmuch_database_get_revision
4e872c64 Merge branch 'release'
91524d5d Merge tag '0.24_rc0'
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Dylan Baker Dylan Baker
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v2] python: deprecated add_message calls index_file correctly and returns result

Quoting David Bremner (2017-09-12 16:29:16)

> Dylan Baker <[hidden email]> writes:
>
> > The broken commit is in 0.25.1, but this patch isn't correct? It's going to
> > break alot if that's the case.
> >
> > Dylan
>
> I don't believe b10ce6bc2 is in 0.25.1; it's in master, and 0.25.1 is
> merged into master, so maybe that's the source of confusion.
>
> %-% git log --oneline  0.24..0.25.1 bindings/python        
> 0fa257cb version: bump to 0.25.1
> 7a4c60e4 version: bump to 0.25
> b8ccfe34 version: bump to 0.25~rc1
> 87bdfbc9 Fix orthography
> 694e443d version: bump version to 0.25~rc0
> 1ec63446 Merge branch 'release'
> 4fb08341 version: bump to 0.24.2
> d877240f Merge branch 'release'
> d9ec7e34 version: bump to 0.24.1
> a35040ee python: bump SOVERSION to 5
> 3721bd45 lib: replace deprecated n_q_count_threads with status returning version
> 5ce8e0b1 lib: replace deprecated n_q_count_messages with status returning version
> 86cbd215 lib: replace deprecated n_q_search_messages with status returning version
> 1e982de5 lib: replace n_query_search_threads with status returning version
> c0c56455 Merge branch 'release'
> a39a1ee1 bindings/python: add bindings for notmuch_database_get_revision
> 4e872c64 Merge branch 'release'
> 91524d5d Merge tag '0.24_rc0'
Okay, that doesn't look like it's in there. Thanks for clarifying!

Dylan

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch

signature.asc (499 bytes) Download Attachment