Some python3 fixes
This commit is contained in:
@@ -59,7 +59,7 @@ def _credentials_cb(cred_out, url, username_from_url, allowed, data):
|
|||||||
try:
|
try:
|
||||||
ccred = get_credentials(d['callback'], url, username_from_url, allowed)
|
ccred = get_credentials(d['callback'], url, username_from_url, allowed)
|
||||||
cred_out[0] = ccred[0]
|
cred_out[0] = ccred[0]
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
d['exception'] = e
|
d['exception'] = e
|
||||||
return C.GIT_EUSER
|
return C.GIT_EUSER
|
||||||
|
|
||||||
|
@@ -29,7 +29,8 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
from os import path
|
import codecs
|
||||||
|
from os import path, getenv
|
||||||
from cffi import FFI
|
from cffi import FFI
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@@ -51,10 +52,10 @@ else:
|
|||||||
|
|
||||||
if sys.version_info.major < 3:
|
if sys.version_info.major < 3:
|
||||||
def is_string(s):
|
def is_string(s):
|
||||||
return isinstance(s, str)
|
return isinstance(s, basestring)
|
||||||
else:
|
else:
|
||||||
def is_string(s):
|
def is_string(s):
|
||||||
return isinstance(s, basestring)
|
return isinstance(s, str)
|
||||||
|
|
||||||
ffi = FFI()
|
ffi = FFI()
|
||||||
|
|
||||||
@@ -88,7 +89,7 @@ def strings_to_strarray(l):
|
|||||||
if not is_string(l[i]):
|
if not is_string(l[i]):
|
||||||
raise TypeError("Value must be a string")
|
raise TypeError("Value must be a string")
|
||||||
|
|
||||||
s = ffi.new('char []', l[i])
|
s = ffi.new('char []', to_str(l[i]))
|
||||||
refs[i] = s
|
refs[i] = s
|
||||||
strings[i] = s
|
strings[i] = s
|
||||||
|
|
||||||
@@ -100,7 +101,7 @@ def strings_to_strarray(l):
|
|||||||
dir_path = path.dirname(path.abspath(inspect.getfile(inspect.currentframe())))
|
dir_path = path.dirname(path.abspath(inspect.getfile(inspect.currentframe())))
|
||||||
|
|
||||||
decl_path = path.join(dir_path, 'decl.h')
|
decl_path = path.join(dir_path, 'decl.h')
|
||||||
with open(decl_path, 'rb') as f:
|
with codecs.open(decl_path, 'r', 'utf-8') as header:
|
||||||
ffi.cdef(f.read())
|
ffi.cdef(header.read())
|
||||||
|
|
||||||
C = ffi.verify("#include <git2.h>", libraries=["git2"])
|
C = ffi.verify("#include <git2.h>", libraries=["git2"])
|
||||||
|
@@ -303,7 +303,7 @@ class Remote(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.transfer_progress(TransferProgress(stats_ptr))
|
self.transfer_progress(TransferProgress(stats_ptr))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self._stored_exception = e
|
self._stored_exception = e
|
||||||
return C.GIT_EUSER
|
return C.GIT_EUSER
|
||||||
|
|
||||||
@@ -319,7 +319,7 @@ class Remote(object):
|
|||||||
try:
|
try:
|
||||||
s = ffi.string(string, length).decode()
|
s = ffi.string(string, length).decode()
|
||||||
self.progress(s)
|
self.progress(s)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self._stored_exception = e
|
self._stored_exception = e
|
||||||
return C.GIT_EUSER
|
return C.GIT_EUSER
|
||||||
|
|
||||||
@@ -338,7 +338,7 @@ class Remote(object):
|
|||||||
b = Oid(raw=bytes(ffi.buffer(b)))
|
b = Oid(raw=bytes(ffi.buffer(b)))
|
||||||
|
|
||||||
self.update_tips(s, a, b)
|
self.update_tips(s, a, b)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self._stored_exception = e
|
self._stored_exception = e
|
||||||
return C.GIT_EUSER
|
return C.GIT_EUSER
|
||||||
|
|
||||||
@@ -355,7 +355,7 @@ class Remote(object):
|
|||||||
ccred = get_credentials(self.credentials, url, username, allowed)
|
ccred = get_credentials(self.credentials, url, username, allowed)
|
||||||
cred_out[0] = ccred[0]
|
cred_out[0] = ccred[0]
|
||||||
|
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self._stored_exception = e
|
self._stored_exception = e
|
||||||
return C.GIT_EUSER
|
return C.GIT_EUSER
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user