Skip to content

Commit febd0fd

Browse files
committed
BF(PY<3.7): just sample the class of a compiled regex
1 parent f0738ce commit febd0fd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

heudiconv/heuristics/reproin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@
126126
import logging
127127
lgr = logging.getLogger('heudiconv')
128128

129+
# pythons before 3.7 didn't have re.Pattern, it was some protected
130+
# _sre.SRE_Pattern, so let's just sample a class of the compiled regex
131+
re_Pattern = re.compile('.').__class__
132+
129133
# Terminology to harmonise and use to name variables etc
130134
# experiment
131135
# subject
@@ -416,7 +420,7 @@ def fix_dbic_protocol(seqinfo):
416420
# Then go through all regexps returning regex "search" result
417421
# on study_description
418422
for sub, substitutions in protocols2fix.items():
419-
if isinstance(sub, re.Pattern) and sub.search(study_description):
423+
if isinstance(sub, re_Pattern) and sub.search(study_description):
420424
_apply_substitutions(seqinfo,
421425
substitutions,
422426
'%r regex matching' % sub.pattern)

0 commit comments

Comments
 (0)