-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ion failing to raise an exception when decrypt fails #662
Conversation
Thanks, that does seem to be a sensible fix. |
I see you have added back the Python 2 UTF header in 815d86e, is there a reason why? It looks like this project does the usual thing of telling people with dead Python(and Calibre) versions to use old versions of the plugin: "Users with calibe 4.x or earlier should use release 6.8.x of the tools." Afaik this PR itself won't work on any unsupported Python version (sans the freshly-EOL 3.8), as they don't support the required typing features. EDIT: Oh, there's a copied readme from two projects. I suggest dropping the old versions, not having typing available is going to lead to bugs like these, the main issue this PR fixes is highlighted even with a basic linter/LSP, which is Ruff/Jedi in my case. EDIT2: Fixed the readme - #671 |
Yeah, the readme is kind of a mess ... The release 7.2.0 from Apprentice Harper years ago did drop support for Python 2 (Calibre < 5) and this recommendation was added, but in my fork I later decided to add back Python 2 support so people that were stuck on an old Calibre installation for whatever reason could still enjoy all the new features, so that's why I added back the UTF8 header (because IIRC it's needed for Python 2). As for the type hint - I simply missed that that's not yet supported in Python 2. For the time being, I think i'm going to replace that with a A few years ago quite a few people were still stuck on Python2, but maybe the number has decreased to a point where it might be worth it to drop Python2 support. But if i decide to do that I'll definitely need to make a proper last release with Python2 support instead of the current, rolling-release 10.0.9 builds. I'll take a look at your readme MR later. |
You should probably also comment out the future import since you commented out the annotation, unsure how well dead Python versions handle it.
I think that today, the use case is gone. From the eBooks ecosystem, even Kindle mods use Python 3 nowadays, and those took even longer to switch than Calibre itself.
This bug fix itself should highlight the usefulness of the typing system, the issue is marked as an error in an LSP. You'll likely find many more. People have had some 17 years to migrate, including 5 years since Python 2 was marked EOL. Making a final P2 release, tearing out support and switching to modern, secure and support Python versions will be beneficial. |
Thanks for the note regarding the import, I'll remove that as well. The first Python 3 versions of Calibre were released at the end of 2020, so, like 4 years ago. If I remember, the very first Calibre versions with Python 3 also had a bunch of teething problems, and they also dropped support for Windows 7. Yes, Windows 7 is also already EOL, but only since 2023. So it wasn't too surprising that people were still on older Calibre builds up until then. Linux distributions like Ubuntu 20.04 (which is still actively being supported for another year or so) are also shipping with Calibre < 5 (Python2). As for the many more errors stricter typing would catch - i definitely agree, it would. And for new code it's probably best to write it with the correct typing indicators, whether that would use the Python3-only syntax or the comment syntax also compatible with Python2. So it's not like A) Python-2-support currently prevents me from using proper typing, nor would B) dropping Pytho 2 immediately result in better code quality, it would still require me or someone else to update all the code to actually make use of newer Python3 features. All while making sure not to break existing code because I don't even have books with all the different DRM types to test this with. When I started working on the plugins back in mid-2021 (half a year after the first Python3 release), almost a third of all users were still on a Python 2 build of Calibre, that's why I added back Python2 support. That said, looking at Calibre's usage statistics now, the amount of people still on Calibre 4 or older seems to be drastically dropping (thankfully). November 21 it was ~30%, November 22 it was 19%, November 23 it was 13% and now it's "only" 10%. So maybe it's time to think about dropping support for Python2 eventually. |
That exists, huh, neat!
It's unfortunately however incompatible with the tooling and presumably, Python itself won't toss an error if you add a nonsensical type:
Windows 7 itself is EOL since 2020, supporting software on insecure operating systems is in my opinion a disservice to the user, rather than giving them a positive reason to migrate to a secured version and informing them, they will keep using the insecure software, possibly while being ignorant about it.
It will in fact be supported even way beyond that with a subscription, which is necessary in the first place, as Calibre is in Canonical's Universe repository, which does not get guaranteed security updates outside of a Ubuntu Pro subscription. The software ecosystem getting the burden of maintaining legacy versions simply because someone slaps a supported sticker on a software package abandoned by upstream years ago is not necessarily a good thing.
That someone else first needs to see the project is actually open to being maintained :)
I would suggest:
Dropping old versions will make it easier to do CI too. On the end note, massive thanks for keeping this project alive! |
ex
is never set to anything but None, so it just tries to raise None and fails.There are also small whitespace cleanups and moving commented docs to a docstring.
Future import added (stabilized in 3.14) as the exception variable now has an annotated type.
Review with hidden whitespace changes for saner view - https://github.com/noDRM/DeDRM_tools/pull/662/files?diff=split&w=1
Fixes:
Issues that ran into it - #434 #472 #561
Built release with this change (in case anyone cares, mostly left it here for myself)