Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterate over the config keys #395

Merged
merged 2 commits into from
Jul 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pygit2/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ def next(self):
def __next__(self):
entry = self._next_entry()
name = ffi.string(entry.name).decode('utf-8')
value = ffi.string(entry.value).decode('utf-8')

return name, value
return name


class ConfigMultivarIterator(ConfigIterator):
Expand Down Expand Up @@ -130,7 +129,7 @@ def __contains__(self, key):
def __getitem__(self, key):
val = self._get_string(key)

return ffi.string(val).decode()
return ffi.string(val).decode('utf-8')

def __setitem__(self, key, value):
assert_string(key, "key")
Expand Down
4 changes: 2 additions & 2 deletions test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ def test_iterator(self):
config = self.repo.config
lst = {}

for name, value in config:
lst[name] = value
for name in config:
lst[name] = config[name]

self.assertTrue('core.bare' in lst)
self.assertTrue(lst['core.bare'])
Expand Down