Commit 1eb3c14
Fix FutureWarning: split() requires a non-empty pattern match (#485)
Fix FutureWarning: split() requires a non-empty pattern match
These warnings are emitted with Python 3.6.8 (and probably other versions as well).
Fixes FutureWarning: split() requires a non-empty pattern match
This can be easily reproduced with the below:
import sys
from specfile import Specfile
specfile = Specfile(sys.argv[1])
with specfile as spec:
print (spec.expanded_release)
Sample stacktrace:
Traceback (most recent call last):
File "/tmp/3.py", line 11, in <module>
print (spec.expanded_release)
File "/home/jesse/.local/lib/python3.6/site-packages/specfile/specfile.py", line 770, in expanded_release
return self.expand(self.release, extra_macros=[("dist", "")])
File "/home/jesse/.local/lib/python3.6/site-packages/specfile/specfile.py", line 761, in release
return self._split_raw_release(self.raw_release)[0]
File "/home/jesse/.local/lib/python3.6/site-packages/specfile/specfile.py", line 667, in getter
with self.tags() as tags:
File "/home/jesse/.local/lib/python3.6/site-packages/specfile/context_management.py", line 134, in __call__
self.values[key] = next(self.generators[key])
File "/home/jesse/.local/lib/python3.6/site-packages/specfile/specfile.py", line 393, in tags
tags = Tags.parse(section, context=self)
File "/home/jesse/.local/lib/python3.6/site-packages/specfile/tags.py", line 514, in parse
line, prefix, suffix = split_conditional_macro_expansion(line)
File "/home/jesse/.local/lib/python3.6/site-packages/specfile/utils.py", line 315, in split_conditional_macro_expansion
nodes = ValueParser.parse(value)
File "/home/jesse/.local/lib/python3.6/site-packages/specfile/value_parser.py", line 278, in parse
ConditionalMacroExpansion(condition, cls.parse(body))
File "/home/jesse/.local/lib/python3.6/site-packages/specfile/value_parser.py", line 132, in __init__
tokens = re.split(r"^([?!]*)", condition, maxsplit=1)
File "/usr/lib64/python3.6/re.py", line 212, in split
return _compile(pattern, flags).split(string, maxsplit)
Reviewed-by: gemini-code-assist[bot]
Reviewed-by: Nikola Forró1 file changed
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
275 | | - | |
| 274 | + | |
| 275 | + | |
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| |||
0 commit comments