-
-
Notifications
You must be signed in to change notification settings - Fork 10
empty version (or project (?)) cause regex matching crash #85
Copy link
Copy link
Closed
Labels
type: bug 🪲Something is wrongSomething is wrong
Milestone
Description
Found what I think is a bug in the header parsing. This project commented out their version number resulting in an empty Version in the header to the objects.inv:
sven:/tmp> wget https://bootstrap-datepicker.readthedocs.io/en/master/objects.inv
sven:/tmp> head -4 objects.inv
# Sphinx inventory version 2
# Project: bootstrap-datepicker
# Version:
# The remainder of this file is compressed using zlib.
sven:/tmp> sphobjinv convert plain objects.inv
Error: Unrecognized file formatIf you do it directly, you get information that seems to mean that you assume Version and Project actually have values after them (and apparently they don't need to):
>>> import sphobjinv as soi
>>> inv = soi.Inventory('objects.inv')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<attrs generated init d264050f79466679381c6c61e7053ac5e806eac0>", line 16, in __init__
File "/usr/local/lib/python3.6/site-packages/sphobjinv/inventory.py", line 365, in __attrs_post_init__
self._general_import()
File "/usr/local/lib/python3.6/site-packages/sphobjinv/inventory.py", line 598, in _general_import
import_errors[st]):
File "/usr/local/lib/python3.6/site-packages/sphobjinv/inventory.py", line 612, in _try_import
p, v, o = import_fxn(src)
File "/usr/local/lib/python3.6/site-packages/sphobjinv/inventory.py", line 659, in _import_plaintext_fname
return self._import_plaintext_bytes(b_plain)
File "/usr/local/lib/python3.6/site-packages/sphobjinv/inventory.py", line 629, in _import_plaintext_bytes
b_res = pb_version.search(b_str).group(HeaderFields.Version.value)
AttributeError: 'NoneType' object has no attribute 'group'I think you want to change .+ to be .*?
Line 42 in 11db748
| (?P<{}>.+?) # Lazy rest of line is the project name |
Line 51 in 11db748
| (?P<{}>.+?) # Lazy rest of line is the version |
And then it will return you empty strings?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type: bug 🪲Something is wrongSomething is wrong