Fix parameter passing of describe patterns
When ffi.new() is used to build a new pointer object, the returned pointer object has ownership on the allocated memory. When it is garbage-collected, then the memory is freed. Thus, we need to make sure the original object survives its use, otherwise the casted pointer will point to garbage. This fixes one test which was failing with the latest CFFI version, see issue #694. Thus, this commit also reverts 803b1cb (cffi 1.10 not yet supported, 2017-03-22) where the latest CFFI version was marked as unsupported. Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
This commit is contained in:
parent
8559b2da20
commit
b88dc86842
@ -14,7 +14,7 @@ env: LIBGIT2=~/libgit2/_install/ LD_LIBRARY_PATH=~/libgit2/_install/lib
|
||||
|
||||
before_install:
|
||||
- sudo apt-get install cmake
|
||||
- pip install cffi==1.9.1
|
||||
- pip install cffi
|
||||
- "./.travis.sh"
|
||||
|
||||
script:
|
||||
|
@ -692,7 +692,11 @@ class BaseRepository(_Repository):
|
||||
if describe_strategy is not None:
|
||||
options.describe_strategy = describe_strategy
|
||||
if pattern:
|
||||
options.pattern = ffi.new('char[]', to_bytes(pattern))
|
||||
# The returned pointer object has ownership on the allocated
|
||||
# memory. Make sure it is kept alive until git_describe_commit() or
|
||||
# git_describe_workdir() are called below.
|
||||
pattern_char = ffi.new('char[]', to_bytes(pattern))
|
||||
options.pattern = pattern_char
|
||||
if only_follow_first_parent is not None:
|
||||
options.only_follow_first_parent = only_follow_first_parent
|
||||
if show_commit_oid_as_fallback is not None:
|
||||
|
4
setup.py
4
setup.py
@ -203,8 +203,8 @@ setup(name='pygit2',
|
||||
long_description=long_description,
|
||||
packages=['pygit2'],
|
||||
package_data={'pygit2': ['decl.h']},
|
||||
setup_requires=['cffi<1.10'],
|
||||
install_requires=['cffi<1.10', 'six'],
|
||||
setup_requires=['cffi'],
|
||||
install_requires=['cffi', 'six'],
|
||||
zip_safe=False,
|
||||
cmdclass=cmdclass,
|
||||
**extra_args)
|
||||
|
Loading…
x
Reference in New Issue
Block a user