After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 737643 - Port invest-applet to Python 3
Port invest-applet to Python 3
Status: RESOLVED FIXED
Product: gnome-applets
Classification: Other
Component: invest-applet
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-applets Maintainers
gnome-applets Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-09-30 06:09 UTC by Dmitry Shachnev
Modified: 2014-10-13 17:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
invest-applet: Port to Python 3 (9.75 KB, patch)
2014-09-30 06:09 UTC, Dmitry Shachnev
needs-work Details | Review
configure.ac: Require Python 3 (630 bytes, patch)
2014-09-30 06:09 UTC, Dmitry Shachnev
reviewed Details | Review
invest-applet: Remove unused code (3.68 KB, patch)
2014-09-30 06:10 UTC, Dmitry Shachnev
reviewed Details | Review
invest-applet: Remove unused shebang (583 bytes, patch)
2014-09-30 10:33 UTC, Dmitry Shachnev
reviewed Details | Review
invest-applet: Port to Python 3 (10.15 KB, patch)
2014-09-30 14:48 UTC, Dmitry Shachnev
none Details | Review
configure.ac: Require Python 3 (727 bytes, patch)
2014-09-30 14:57 UTC, Dmitry Shachnev
none Details | Review
[PATCH 1/4] invest-applet: Remove unused imports (5.48 KB, patch)
2014-10-13 15:56 UTC, Dmitry Shachnev
committed Details | Review
[PATCH 2/4] invest-applet: Remove unused code (4.12 KB, patch)
2014-10-13 15:57 UTC, Dmitry Shachnev
committed Details | Review
[PATCH 3/4] invest-applet: Fix some undefined variables in quotes.py (1.04 KB, patch)
2014-10-13 15:57 UTC, Dmitry Shachnev
committed Details | Review
[PATCH 4/4] invest-applet: Port to Python 3 (7.28 KB, patch)
2014-10-13 15:59 UTC, Dmitry Shachnev
committed Details | Review

Description Dmitry Shachnev 2014-09-30 06:09:12 UTC
Created attachment 287419 [details] [review]
invest-applet: Port to Python 3

Here is the set of patches to port invest-applet to Python 3. I also fixed some minor unrelated issues with the code while trying to make it work.
Comment 1 Dmitry Shachnev 2014-09-30 06:09:52 UTC
Created attachment 287420 [details] [review]
configure.ac: Require Python 3
Comment 2 Dmitry Shachnev 2014-09-30 06:10:34 UTC
Created attachment 287421 [details] [review]
invest-applet: Remove unused code
Comment 3 Alberts Muktupāvels 2014-09-30 10:12:20 UTC
Review of attachment 287419 [details] [review]:

I did not test it yet.

::: invest-applet/invest/chart.py
@@ +1,1 @@
 #!/usr/bin/python

Why you did not change here?

::: invest-applet/invest/invest-applet.py
@@ +1,1 @@
+#!/usr/bin/env python3

Should not it be /usr/bin/python3?

https://git.gnome.org/browse/gnome-applets/commit/invest-applet/invest/invest-applet.py?id=b3aa1382c80f0ccc62a6ffe98577f95a2c2aea31

::: invest-applet/invest/invest-chart
@@ +1,1 @@
+#!/usr/bin/env python3

Same thing.

::: invest-applet/invest/test.py
@@ +1,1 @@
+#!/usr/bin/env python3

Same thing.
Comment 4 Alberts Muktupāvels 2014-09-30 10:15:26 UTC
Review of attachment 287420 [details] [review]:

ok.
Comment 5 Alberts Muktupāvels 2014-09-30 10:17:14 UTC
Review of attachment 287421 [details] [review]:

ok.
Comment 6 Dmitry Shachnev 2014-09-30 10:33:54 UTC
Created attachment 287435 [details] [review]
invest-applet: Remove unused shebang

"/usr/bin/env python" is usually used to not hardcode the interpreter path, as people may have a custom interpreter in /usr/local/bin or virtualenv, which they want to use.

chart.py does not need shebang at all, because it is not executable file. I added a patch to remove it.
Comment 7 Alberts Muktupāvels 2014-09-30 10:38:48 UTC
(In reply to comment #6)
> "/usr/bin/env python" is usually used to not hardcode the interpreter path, as
> people may have a custom interpreter in /usr/local/bin or virtualenv, which
> they want to use.

Please use recommended/preferred way. Both debian and fedora suggests to use /usr/bin/python.

https://bugzilla.gnome.org/show_bug.cgi?id=692764
Comment 8 Alberts Muktupāvels 2014-09-30 10:39:19 UTC
Review of attachment 287435 [details] [review]:

ok.
Comment 9 Alberts Muktupāvels 2014-09-30 10:39:43 UTC
Review of attachment 287421 [details] [review]:

ok.
Comment 10 Alberts Muktupāvels 2014-09-30 10:42:40 UTC
> Configure now checks for Python 3, but one of the checks still uses
> Python 2 syntax for some reason (but we can probably ignore that).

What check?
Comment 11 Dmitry Shachnev 2014-09-30 14:48:25 UTC
Created attachment 287456 [details] [review]
invest-applet: Port to Python 3

Ok, updated patch.
Comment 12 Dmitry Shachnev 2014-09-30 14:57:15 UTC
Created attachment 287459 [details] [review]
configure.ac: Require Python 3

> What check?

This one: https://git.gnome.org/browse/gnome-applets/tree/m4/python.m4#n46

In Python 3, 'print(foo)' is used instead of 'print foo' (the former works in both 2 and 3).

However, we don't need Python headers at all — they are only needed if one wants to write Python extensions in C, and we don't need that.

Updated the patch to remove that check.
Comment 13 Alberts Muktupāvels 2014-10-07 18:00:40 UTC
Applied all patches for testing. Looks like it requires more work... :(

1) Looks like "proxies = invest.PROXY" should be replaced with simply "invest.PROXY" in urlopen function in chart.py and quotes.py.
2) Sorting does not work. I got this error "Failed to populate quotes: 'dict_items' object has no attribute 'sort'". 415 line - quote_items.sort () in quotes.py
Comment 14 Dmitry Shachnev 2014-10-13 15:56:12 UTC
Created attachment 288398 [details] [review]
[PATCH 1/4] invest-applet: Remove unused imports
Comment 15 Dmitry Shachnev 2014-10-13 15:57:17 UTC
Created attachment 288399 [details] [review]
[PATCH 2/4] invest-applet: Remove unused code
Comment 16 Dmitry Shachnev 2014-10-13 15:57:50 UTC
Created attachment 288400 [details] [review]
[PATCH 3/4] invest-applet: Fix some undefined variables in quotes.py
Comment 17 Dmitry Shachnev 2014-10-13 15:59:24 UTC
Created attachment 288401 [details] [review]
[PATCH 4/4] invest-applet: Port to Python 3

Attached updated patch set.

This time it designed in a way that after applying first three patches the applet still works with Python 2 (i.e. it should be safe to do that), while all porting is done in the fourth patch.

The code that did sorting was not used, so I dropped it.
Comment 18 Alberts Muktupāvels 2014-10-13 17:04:31 UTC
Ok. Looks like it is working. Patches added to master.