News for hackers. Stuff that matters.
Re:Sunsetting Python 2 by shakna on Monday September 09, 2019 @06:11AM (#20916763)
Python 2's EOL was first announced in 2008, it was extended in 2014. That's more than a decade of forewarning that this was coming down the line. A decade of Python2 receiving security fixes.

Were I a commercial customer, and had been told to switch to the new version ten years ago, then it's on me if I still have started the migration yet.

Re:Sunsetting Python 2 by mikepurvis on Monday September 09, 2019 @09:58AM (#20918191)
It's interesting seeing who the holdouts are, though. Less than a year ago, the CEO of Sentry (the crash reporter) locked a Github thread with essentially "we'll get there when we get there, sometime in or after 2020." But then, as late as 2016 their stance was pretty much that they would never migrate, so I suppose it's not surprising that they aren't super prepared for it:

https://github.com/getsentry/sentry/issues/8806#issuecomment...

https://github.com/getsentry/sentry/issues/1152#issuecomment...

I mean, even supervisord is migrated at this point, and it was a long-time laggard.

Re:Sunsetting Python 2 by bscphil on Monday September 09, 2019 @12:18PM (#20919528)
Calibre is another well known case, and they don't plan to migrate.

Actually, I can't wait to remove it from my hard drive on Jan 1, since it's one of the most poorly designed apps I've ever used. It's really not surprising at all that they're not able to migrate it, assuming the quality of the app is indicative of the quality of the code. I wouldn't be surprised if the same was true of a lot of applications that are refusing to migrate. (I'll probably have to find an alternative to ebook-convert, the command line tool that's the only part of Calibre I use, or maybe I'll rewrite it in Python 3 myself.)

Re:Sunsetting Python 2 by partialrecall on Monday September 09, 2019 @12:50PM (#20919854)
The only good part of calibre is the `ebook-convert` commandline tool that has a stupid-simple interface (polar opposite of the gui) and handles all kinds of formats that pandoc doesn't.

The gui, Calibre proper, is a total nightmare. Functional, but my god is it esoteric and ugly. I've heard people actually use that gui as their primary ebook reading software and I just can't fathom how they find that tolerable.

https://manual.calibre-ebook.com/generated/en/ebook-convert....

Re:Sunsetting Python 2 by shscs911 on Monday September 09, 2019 @01:13PM (#20920053)
I dislike Calibre main GUI as well. It looks a bit dated and all, but really convenient for downloading books from Userfiction forums like Spacebattles via the Fanficfare plugin. Also good for simple editing of ebook metadata. Built-in ebook-viewer is highly configurable with custom keybindings and themable with custom CSS.This is my setup

https://imgur.com/a/nlAAlZn

Re:Sunsetting Python 2 by notthemessiah on Monday September 09, 2019 @01:15PM (#20920079)
I use Calibre as my primary e-book reader. I don't see many alternatives on Linux.
Re:Sunsetting Python 2 by shscs911 on Monday September 09, 2019 @01:27PM (#20920231)
I basically use Calibre ebook viewer for its configurability and customization. If you want a good ebook reader, give Foliate (https://github.com/johnfactotum/foliate) a try. That and Bookworm (https://github.com/babluboy/bookworm) are the best standalone ebook readers I've seen in Linux.
Re:Sunsetting Python 2 by michaelmrose on Tuesday September 10, 2019 @02:23AM (#20925565)
Other than having a simpler layout I don't really see either as better than calibres reader. What's better other than looks?
Re:Sunsetting Python 2 by shscs911 on Monday September 09, 2019 @12:49PM (#20919837)
Re:Sunsetting Python 2 by bscphil on Monday September 09, 2019 @02:05PM (#20920652)
If that's the case, I'm glad to see things are changing. Up until very recently, there seem to have been no plans to switch: https://bugs.launchpad.net/calibre/+bug/1714107

> No, it doesn't [need to convert to Python 3]. I am perfectly capable of maintaining python 2 myself. Far less work than migrating the entire calibre codebase.

Re:Sunsetting Python 2 by gnulinux on Tuesday September 10, 2019 @11:53AM (#20929581)
> I am perfectly capable of maintaining python 2 myself.

That's a very strange quote. I want to have this much self-confidence.

Re:Sunsetting Python 2 by dralley on Monday September 09, 2019 @03:51PM (#20921736)
Calibre is, in fact, migrating. There are at this point dozens of commits over the past few months to that goal. Not sure what changed his mind.
Re:Sunsetting Python 2 by iamnotacrook on Tuesday September 10, 2019 @01:35PM (#20930853)
Reality? You can maintain an absurd, unintuitive, dated UI by yourself fairly easily, but even someone who pushes out two minor updates per week is going to be taking on a little too much in my opinion if they believe they can also support a fork of a major language.
Re:Sunsetting Python 2 by tapia on Monday September 09, 2019 @12:38PM (#20919722)
And make a gnome core app with GTK3? That would pretty cool :)
Re:Sunsetting Python 2 by mynameisvlad on Monday September 09, 2019 @10:13PM (#20924535)
His responses leave an incredibly sour taste in my mouth. Not only is he obviously short sighted with his "Python 2 is not the past and Python 3 is not the future" but all his responses just sound like someone who got up on the wrong side of the bed. Every morning.
Re:Sunsetting Python 2 by mantap on Monday September 09, 2019 @06:58AM (#20916990)
You couldn't switch to Python 3 until the middle part of this decade unless the stars aligned with your dependencies, the library support wasn't there. And the first releases of Python 3 were glorified betas, the first "usable" version of Python 3 is often considered to be version 3.3 released in 2012.
Re:Sunsetting Python 2 by ensignavenger on Monday September 09, 2019 @07:34AM (#20917160)
But you could easily write Python 3 compatible code so that upgrading once your dependacies were ready was easy. You also could have contributed to your dependancies to help them become Python 3 compatible.
Re:Sunsetting Python 2 by pfranz on Monday September 09, 2019 @01:58PM (#20920578)
I often hear this, but I just don't see this working in practice. A very similar example I have experience with, I've often worked with people who tried to write code that would be "compatible with Windows" (I primary work in a Linux environment). It makes the code more difficult to read and as soon as you try and run it in Windows it fails spectacularly.

You can write code that's compatible with both Python 2 and 3, but I don't think you can expect to be using Python 2 exclusively and write code that works well in Python 3 unless you're constantly running it with Python 3. Especially, if you don't have much firsthand Python 3 experience. This is much easier if your code is isolated from those dependencies and you write tests that run in both Python 2 and 3, but that's quite a bit more of a commitment than you seem to be implying.

Re:Sunsetting Python 2 by ensignavenger on Monday September 09, 2019 @06:32PM (#20923205)
There are a ton of open source projects that have done python 2/3 simultaneously in practice.

I get your point though about not being able to run full integration tests due to dependencies. Still, if you were making a good effort to keep the code Python 3 compliant, it would make upgrading much easier.

Also, my other suggestion- contributing to Python 3 compatibility for modules you depend on! That will give you Python 3 experience :)

Re:Sunsetting Python 2 by mikepurvis on Monday September 09, 2019 @09:45AM (#20918066)
Quick: run a shell command, split up the reply by line, run a regex on each line, and save the results to a yaml file— now, does what you wrote work correctly on both Python 2.7 and Python 3.3+? Yeah that's what I thought.

It's still hard to get bilingual Python correct today, and it was considerably harder before 3.3.

Re:Sunsetting Python 2 by radus on Monday September 09, 2019 @02:50PM (#20921068)
Okay, I did it.

    import subprocess
    import re
    import yaml

    output = subprocess.check_output(['ls', '-l'], universal_newlines=True)
    matching_lines = []

    for line in output.splitlines():
        if re.search(r'total', line):
            matching_lines.append(line)

    with open('matching_lines.yaml', 'w') as f:
        f.write(yaml.dump(matching_lines))
Python 3.7: https://repl.it/repls/PotableDamagedAutocad

Python 2.7: https://repl.it/repls/OrchidDirtyNotification

Re:Sunsetting Python 2 by mikepurvis on Monday September 09, 2019 @08:12PM (#20923924)
Nice. Yeah my life got a lot easier when I learned about `universal_newlines` changing the subprocess return type under Python 3.

The much worse case of this that I dealt with a few years ago was reading in and modifying XML files, and then saving the modified XML contents as strings in a yaml file (a keyed cache). The input XML files (which I didn't control) were not consistent about having the encoding marked, and that really made things a mess for ElementTree.

A taste: https://github.com/ros-infrastructure/rosdistro/search?q=utf...

Re:Sunsetting Python 2 by slavik81 on Tuesday September 10, 2019 @07:50AM (#20927180)
This program would crash with a UnicodeEncodeError upon encountering any file with a non-latin character in its name on Windows with Python 3.5 or earlier.

I know that's not the version of Python you were targeting, and I know you didn't write this program to be cross-platform, but I wrote a similar program and I was repeatedly surprised by those sorts of problems. I don't entirely agree with mikepurvis, but I do feel his pain.

Re:Sunsetting Python 2 by weberc2 on Monday September 09, 2019 @10:26AM (#20918477)
No one is arguing that upgrading would be trivial; the argument is that it's necessary work that could have been started 10 years ago. Also, if you run your unit tests on Python 2 and 3, you'll get pretty good pretty fast at writing 2-3 compatible code.
Re:Sunsetting Python 2 by mikepurvis on Monday September 09, 2019 @10:33AM (#20918549)
The comment I was specifically replying to asserted that "you could easily write Python 3 compatible code", and could have been doing so 10 years ago.

This is simply untrue— there are a dozen small stumbling blocks that mean that writing bilingual code has a real cost. And it's not as easy as just having the right CI setup, especially if it's ten years ago and most of your dependencies haven't migrated.

Re:Sunsetting Python 2 by weberc2 on Monday September 09, 2019 @10:50AM (#20918713)
Ah, I see the confusion. In this case, "easily" is relative. The assertion "you could easily write Python 3 compatible code" was in response to the (implied?) assertion "you can't do anything to migrate unless your dependencies are migrated". Perhaps "simply" would have been a better word choice than "easily". To your point, writing 2-3 compatible code has a real cost, but to the GP's point, it's the obvious solution to the "can't do anything until deps are migrated" problem.
Re:Sunsetting Python 2 by logifail on Monday September 09, 2019 @01:05PM (#20919977)
> To your point, writing 2-3 compatible code has a real cost, but to the GP's point, it's the obvious solution to the "can't do anything until deps are migrated" problem

Q: Ten years ago how would you have explained to your manager that you needed your team to start writing 2-3 compatible code, which obviously takes considerably more time and effort than sticking with 2 compatible code?

Re:Sunsetting Python 2 by joshuamorton on Monday September 09, 2019 @09:21PM (#20924285)
It doesn't take considerably more time.

At this point, all the code I write is 2/3 compatible, and the things that annoy me are all py3 only features. Backwards compatibility stuff is pretty easy. Most of the easy problems are easy, and six has solved all the hard ones for like 7 years.

And I've been writing some of my code 2/3 compatible since 3.4.

Re:Sunsetting Python 2 by mehrdadn on Monday September 09, 2019 @07:47AM (#20917230)
> But you could easily write Python 3 compatible code so that upgrading once your dependacies were ready was easy.

This sounds a bit like telling someone, oh, you could've easily started driving an EV, so that once charging stations were actually out there, you'd have been ready...

Re:Sunsetting Python 2 by ericvsmith on Monday September 09, 2019 @07:58AM (#20917308)
> This sounds a bit like telling someone, oh, you could've easily started driving an EV, so that once charging stations were actually out there, you'd have been ready...

While car analogies are notoriously bad, it's much more like "I'm going to buy a plug-in hybrid and use gasoline until charging stations are widely available". You can write code that works in Python 2 that takes zero effort to run in Python 3. I (and many others) have been doing this for years. Just look at the number of packages on PyPI that run, unmodified, on 2 and 3.

[Edit: gas -> gasoline]

Re:Sunsetting Python 2 by mehrdadn on Monday September 09, 2019 @08:03AM (#20917334)
I try to write compatible code myself too, and the only reason it's "zero effort" to run in Python 3 is that I've already invested said effort when making it compatible. Getting strings and paths and stdio to be cross-compatible and working correctly in both 2 and 3 can be quite painful in my experience. Which was kind of my point with the vehicle analogy. It requires a significant investment that you're ignoring, and lack of enough underlying support to justify it during that time.
Re:Sunsetting Python 2 by weberc2 on Monday September 09, 2019 @10:31AM (#20918517)
Driving an EV without charging stations is (nearly) useless. You can still run Python 2-3 code with a Python 2 interpreter with no significant consequence.
Re:Sunsetting Python 2 by WorldMaker on Monday September 09, 2019 @04:57PM (#20922400)
EV drivers don't need charging stations at all if they have an open plug at home or at work. The metaphor still sort of works that Python developers had plenty of time where maybe they didn't have enough charging stations on the wide open highway roads of Production to use Python 3 there, but certainly could have been happy to use an EV to commute from home (hobby projects) to the work parking lot (side projects, automation projects, new projects) and back while they waited for those "charging stations" to be built.
Re:Sunsetting Python 2 by weberc2 on Monday September 09, 2019 @07:00PM (#20923431)
I don't want to debate the amount of shoehorning necessary to validate the metaphor. We all understand concretely the issue at hand, the metaphor is only obfuscating at this point.
Re:Sunsetting Python 2 by collinmanderson on Monday September 09, 2019 @10:13AM (#20918347)
I feel like there were 3 steps:

- 2008-2012 Python 3 becoming usable (byte formatting, six library)

- 2012-2016 Libraries (Django, etc) becoming compatible

- 2016-today Applications (Trac, Ansible, Chrome[1], etc) becoming compatible.

[1] https://bugs.chromium.org/p/chromium/issues/detail?id=942720

Re:Sunsetting Python 2 by oblio on Monday September 09, 2019 @08:24AM (#20917439)
2012 was 7 years ago.
Re:Sunsetting Python 2 by your-nanny on Monday September 09, 2019 @04:31PM (#20922144)
well what if your best guess was that py2 would never actually be deprecated. Certainly in the early tens I had serious doubts.