anki: Use fetchpatch for python compatibilty patch

This commit is contained in:
Alexey Lebedeff 2018-12-01 11:05:28 +01:00
parent 8d61b9d079
commit 19bffeee70
2 changed files with 11 additions and 24 deletions

View file

@ -4,6 +4,7 @@
, lib
, python
, fetchurl
, fetchpatch
, lame
, mplayer
, libpulseaudio
@ -53,7 +54,16 @@ buildPythonApplication rec {
patches = [
# Disable updated version check.
./no-version-check.patch
./python-3.7-compat.patch
# This is needed to fix python 3.7 compatibilty, where the
# behaviour of `re.escape()` was changed in a way that it no
# longer escapes `%`. This patch detects this difference at
# runtime and makes anki work with any python version.
# Upstream PR: https://github.com/dae/anki/pull/266
(fetchpatch {
url = "https://github.com/dae/anki/commit/3d69aa9ce454a151ba75deafd7de117af2c7307d.patch";
sha256 = "0kf9gajhy0wcajp24xfia71z6gn1mc4vl37svvq4sqbhj3gigd0h";
})
];
buildPhase = ''

View file

@ -1,23 +0,0 @@
commit 3d69aa9ce454a151ba75deafd7de117af2c7307d
Author: Alexey Lebedeff <binarin@binarin.ru>
Date: Fri Nov 30 10:44:39 2018 +0100
Fix searching for python 3.7
3.7 introduced a change to `re.escape()`, which no longer escapes
`%`. By using `re.escape("%")` instead of a literal, we can detect
a proper form at runtime.
diff --git a/anki/find.py b/anki/find.py
index 48d0dd1..213216d 100644
--- a/anki/find.py
+++ b/anki/find.py
@@ -440,7 +440,7 @@ select distinct(n.id) from cards c, notes n where c.nid=n.id and """+preds
# nothing has that field
return
# gather nids
- regex = re.escape(val).replace("_", ".").replace("\\%", ".*")
+ regex = re.escape(val).replace("_", ".").replace(re.escape('%'), ".*")
nids = []
for (id,mid,flds) in self.col.db.execute("""
select id, mid, flds from notes