Skip to content

Conversation

@batchar2
Copy link

@batchar2 batchar2 commented Dec 8, 2017

Hi!
Error fix:

import git
repository = git.Repo("/home/bat/Apps/fsoft/")
repository.submodules

Traceback (most recent call last):
File "", line 1, in
File "/home/bat/Apps/GitPython/git/repo/base.py", line 323, in submodules
return Submodule.list_items(self)
File "/home/bat/Apps/GitPython/git/util.py", line 942, in list_items
out_list.extend(cls.iter_items(repo, *args, **kwargs))
File "/home/bat/Apps/GitPython/git/objects/submodule/base.py", line 1171, in iter_items
for sms in parser.sections():
File "/home/bat/Apps/GitPython/git/config.py", line 78, in assure_data_present
self.read()
File "/home/bat/Apps/GitPython/git/config.py", line 412, in read
self._read(fp, fp.name)
File "/home/bat/Apps/GitPython/git/config.py", line 337, in _read
raise cp.MissingSectionHeaderError(fpname, lineno, line)
configparser.MissingSectionHeaderError: File contains no section headers.
file: '/home/bat/Apps/fsoft/.gitmodules', line: 1
'\ufeff[submodule "eflib"]\n'

@Byron
Copy link
Member

Byron commented Dec 11, 2017

@batchar2 Thanks a lot for the fix! This one should be easy to test, too! Could you have a look at test_config.py and add a test that reads such a file?
Also I am wondering what happens if a BOM is removed, and the file is changed afterwards so it gets written back to disk. If I remember correctly the UTF-8 standard assures files don't need a BOM to be decodable correctly?

@Byron Byron closed this Jan 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants