Skip to content
This repository was archived by the owner on Oct 4, 2024. It is now read-only.

Commit 0b86a42

Browse files
committed
update libssh2 issue #15
1 parent d492a77 commit 0b86a42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+12859
-1387
lines changed
610 KB
Binary file not shown.
Binary file not shown.
264 KB
Binary file not shown.
27.1 KB
Binary file not shown.

functions/source/GitPullS3/cffi/LICENSE

Lines changed: 0 additions & 26 deletions
This file was deleted.

functions/source/GitPullS3/cffi/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
__all__ = ['FFI', 'VerificationError', 'VerificationMissing', 'CDefError',
22
'FFIError']
33

4-
from .api import FFI, CDefError, FFIError
5-
from .ffiplatform import VerificationError, VerificationMissing
4+
from .api import FFI
5+
from .error import CDefError, FFIError, VerificationError, VerificationMissing
66

7-
__version__ = "1.7.0"
8-
__version_info__ = (1, 7, 0)
7+
__version__ = "1.11.5"
8+
__version_info__ = (1, 11, 5)
99

1010
# The verifier module file names are based on the CRC32 of a string that
1111
# contains the following version number. It may be older than __version__
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#ifndef CFFI_MESSAGEBOX
2+
# ifdef _MSC_VER
3+
# define CFFI_MESSAGEBOX 1
4+
# else
5+
# define CFFI_MESSAGEBOX 0
6+
# endif
7+
#endif
8+
9+
10+
#if CFFI_MESSAGEBOX
11+
/* Windows only: logic to take the Python-CFFI embedding logic
12+
initialization errors and display them in a background thread
13+
with MessageBox. The idea is that if the whole program closes
14+
as a result of this problem, then likely it is already a console
15+
program and you can read the stderr output in the console too.
16+
If it is not a console program, then it will likely show its own
17+
dialog to complain, or generally not abruptly close, and for this
18+
case the background thread should stay alive.
19+
*/
20+
static void *volatile _cffi_bootstrap_text;
21+
22+
static PyObject *_cffi_start_error_capture(void)
23+
{
24+
PyObject *result = NULL;
25+
PyObject *x, *m, *bi;
26+
27+
if (InterlockedCompareExchangePointer(&_cffi_bootstrap_text,
28+
(void *)1, NULL) != NULL)
29+
return (PyObject *)1;
30+
31+
m = PyImport_AddModule("_cffi_error_capture");
32+
if (m == NULL)
33+
goto error;
34+
35+
result = PyModule_GetDict(m);
36+
if (result == NULL)
37+
goto error;
38+
39+
#if PY_MAJOR_VERSION >= 3
40+
bi = PyImport_ImportModule("builtins");
41+
#else
42+
bi = PyImport_ImportModule("__builtin__");
43+
#endif
44+
if (bi == NULL)
45+
goto error;
46+
PyDict_SetItemString(result, "__builtins__", bi);
47+
Py_DECREF(bi);
48+
49+
x = PyRun_String(
50+
"import sys\n"
51+
"class FileLike:\n"
52+
" def write(self, x):\n"
53+
" of.write(x)\n"
54+
" self.buf += x\n"
55+
"fl = FileLike()\n"
56+
"fl.buf = ''\n"
57+
"of = sys.stderr\n"
58+
"sys.stderr = fl\n"
59+
"def done():\n"
60+
" sys.stderr = of\n"
61+
" return fl.buf\n", /* make sure the returned value stays alive */
62+
Py_file_input,
63+
result, result);
64+
Py_XDECREF(x);
65+
66+
error:
67+
if (PyErr_Occurred())
68+
{
69+
PyErr_WriteUnraisable(Py_None);
70+
PyErr_Clear();
71+
}
72+
return result;
73+
}
74+
75+
#pragma comment(lib, "user32.lib")
76+
77+
static DWORD WINAPI _cffi_bootstrap_dialog(LPVOID ignored)
78+
{
79+
Sleep(666); /* may be interrupted if the whole process is closing */
80+
#if PY_MAJOR_VERSION >= 3
81+
MessageBoxW(NULL, (wchar_t *)_cffi_bootstrap_text,
82+
L"Python-CFFI error",
83+
MB_OK | MB_ICONERROR);
84+
#else
85+
MessageBoxA(NULL, (char *)_cffi_bootstrap_text,
86+
"Python-CFFI error",
87+
MB_OK | MB_ICONERROR);
88+
#endif
89+
_cffi_bootstrap_text = NULL;
90+
return 0;
91+
}
92+
93+
static void _cffi_stop_error_capture(PyObject *ecap)
94+
{
95+
PyObject *s;
96+
void *text;
97+
98+
if (ecap == (PyObject *)1)
99+
return;
100+
101+
if (ecap == NULL)
102+
goto error;
103+
104+
s = PyRun_String("done()", Py_eval_input, ecap, ecap);
105+
if (s == NULL)
106+
goto error;
107+
108+
/* Show a dialog box, but in a background thread, and
109+
never show multiple dialog boxes at once. */
110+
#if PY_MAJOR_VERSION >= 3
111+
text = PyUnicode_AsWideCharString(s, NULL);
112+
#else
113+
text = PyString_AsString(s);
114+
#endif
115+
116+
_cffi_bootstrap_text = text;
117+
118+
if (text != NULL)
119+
{
120+
HANDLE h;
121+
h = CreateThread(NULL, 0, _cffi_bootstrap_dialog,
122+
NULL, 0, NULL);
123+
if (h != NULL)
124+
CloseHandle(h);
125+
}
126+
/* decref the string, but it should stay alive as 'fl.buf'
127+
in the small module above. It will really be freed only if
128+
we later get another similar error. So it's a leak of at
129+
most one copy of the small module. That's fine for this
130+
situation which is usually a "fatal error" anyway. */
131+
Py_DECREF(s);
132+
PyErr_Clear();
133+
return;
134+
135+
error:
136+
_cffi_bootstrap_text = NULL;
137+
PyErr_Clear();
138+
}
139+
140+
#else
141+
142+
static PyObject *_cffi_start_error_capture(void) { return NULL; }
143+
static void _cffi_stop_error_capture(PyObject *ecap) { }
144+
145+
#endif

functions/source/GitPullS3/cffi/_cffi_include.h

Lines changed: 85 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
11
#define _CFFI_
2+
3+
/* We try to define Py_LIMITED_API before including Python.h.
4+
5+
Mess: we can only define it if Py_DEBUG, Py_TRACE_REFS and
6+
Py_REF_DEBUG are not defined. This is a best-effort approximation:
7+
we can learn about Py_DEBUG from pyconfig.h, but it is unclear if
8+
the same works for the other two macros. Py_DEBUG implies them,
9+
but not the other way around.
10+
11+
Issue #350 is still open: on Windows, the code here causes it to link
12+
with PYTHON36.DLL (for example) instead of PYTHON3.DLL. A fix was
13+
attempted in 164e526a5515 and 14ce6985e1c3, but reverted: virtualenv
14+
does not make PYTHON3.DLL available, and so the "correctly" compiled
15+
version would not run inside a virtualenv. We will re-apply the fix
16+
after virtualenv has been fixed for some time. For explanation, see
17+
issue #355. For a workaround if you want PYTHON3.DLL and don't worry
18+
about virtualenv, see issue #350. See also 'py_limited_api' in
19+
setuptools_ext.py.
20+
*/
21+
#if !defined(_CFFI_USE_EMBEDDING) && !defined(Py_LIMITED_API)
22+
# include <pyconfig.h>
23+
# if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG)
24+
# define Py_LIMITED_API
25+
# endif
26+
#endif
27+
228
#include <Python.h>
329
#ifdef __cplusplus
430
extern "C" {
@@ -42,7 +68,9 @@ extern "C" {
4268
# include <stdint.h>
4369
# endif
4470
# if _MSC_VER < 1800 /* MSVC < 2013 */
45-
typedef unsigned char _Bool;
71+
# ifndef __cplusplus
72+
typedef unsigned char _Bool;
73+
# endif
4674
# endif
4775
#else
4876
# include <stdint.h>
@@ -59,7 +87,7 @@ extern "C" {
5987

6088
#ifdef __cplusplus
6189
# ifndef _Bool
62-
# define _Bool bool /* semi-hackish: C++ has no _Bool; bool is builtin */
90+
typedef bool _Bool; /* semi-hackish: C++ has no _Bool; bool is builtin */
6391
# endif
6492
#endif
6593

@@ -77,6 +105,7 @@ extern "C" {
77105
#define _cffi_from_c_ulong PyLong_FromUnsignedLong
78106
#define _cffi_from_c_longlong PyLong_FromLongLong
79107
#define _cffi_from_c_ulonglong PyLong_FromUnsignedLongLong
108+
#define _cffi_from_c__Bool PyBool_FromLong
80109

81110
#define _cffi_to_c_double PyFloat_AsDouble
82111
#define _cffi_to_c_float PyFloat_AsDouble
@@ -123,9 +152,9 @@ extern "C" {
123152
#define _cffi_to_c_char \
124153
((int(*)(PyObject *))_cffi_exports[9])
125154
#define _cffi_from_c_pointer \
126-
((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[10])
155+
((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[10])
127156
#define _cffi_to_c_pointer \
128-
((char *(*)(PyObject *, CTypeDescrObject *))_cffi_exports[11])
157+
((char *(*)(PyObject *, struct _cffi_ctypedescr *))_cffi_exports[11])
129158
#define _cffi_get_struct_layout \
130159
not used any more
131160
#define _cffi_restore_errno \
@@ -135,35 +164,40 @@ extern "C" {
135164
#define _cffi_from_c_char \
136165
((PyObject *(*)(char))_cffi_exports[15])
137166
#define _cffi_from_c_deref \
138-
((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[16])
167+
((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[16])
139168
#define _cffi_to_c \
140-
((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[17])
169+
((int(*)(char *, struct _cffi_ctypedescr *, PyObject *))_cffi_exports[17])
141170
#define _cffi_from_c_struct \
142-
((PyObject *(*)(char *, CTypeDescrObject *))_cffi_exports[18])
171+
((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[18])
143172
#define _cffi_to_c_wchar_t \
144-
((wchar_t(*)(PyObject *))_cffi_exports[19])
173+
((_cffi_wchar_t(*)(PyObject *))_cffi_exports[19])
145174
#define _cffi_from_c_wchar_t \
146-
((PyObject *(*)(wchar_t))_cffi_exports[20])
175+
((PyObject *(*)(_cffi_wchar_t))_cffi_exports[20])
147176
#define _cffi_to_c_long_double \
148177
((long double(*)(PyObject *))_cffi_exports[21])
149178
#define _cffi_to_c__Bool \
150179
((_Bool(*)(PyObject *))_cffi_exports[22])
151180
#define _cffi_prepare_pointer_call_argument \
152-
((Py_ssize_t(*)(CTypeDescrObject *, PyObject *, char **))_cffi_exports[23])
181+
((Py_ssize_t(*)(struct _cffi_ctypedescr *, \
182+
PyObject *, char **))_cffi_exports[23])
153183
#define _cffi_convert_array_from_object \
154-
((int(*)(char *, CTypeDescrObject *, PyObject *))_cffi_exports[24])
184+
((int(*)(char *, struct _cffi_ctypedescr *, PyObject *))_cffi_exports[24])
155185
#define _CFFI_CPIDX 25
156186
#define _cffi_call_python \
157187
((void(*)(struct _cffi_externpy_s *, char *))_cffi_exports[_CFFI_CPIDX])
158-
#define _CFFI_NUM_EXPORTS 26
188+
#define _cffi_to_c_wchar3216_t \
189+
((int(*)(PyObject *))_cffi_exports[26])
190+
#define _cffi_from_c_wchar3216_t \
191+
((PyObject *(*)(int))_cffi_exports[27])
192+
#define _CFFI_NUM_EXPORTS 28
159193

160-
typedef struct _ctypedescr CTypeDescrObject;
194+
struct _cffi_ctypedescr;
161195

162196
static void *_cffi_exports[_CFFI_NUM_EXPORTS];
163197

164198
#define _cffi_type(index) ( \
165199
assert((((uintptr_t)_cffi_types[index]) & 1) == 0), \
166-
(CTypeDescrObject *)_cffi_types[index])
200+
(struct _cffi_ctypedescr *)_cffi_types[index])
167201

168202
static PyObject *_cffi_init(const char *module_name, Py_ssize_t version,
169203
const struct _cffi_type_context_s *ctx)
@@ -196,20 +230,46 @@ static PyObject *_cffi_init(const char *module_name, Py_ssize_t version,
196230
return NULL;
197231
}
198232

199-
_CFFI_UNUSED_FN
200-
static PyObject **_cffi_unpack_args(PyObject *args_tuple, Py_ssize_t expected,
201-
const char *fnname)
233+
234+
#ifdef HAVE_WCHAR_H
235+
typedef wchar_t _cffi_wchar_t;
236+
#else
237+
typedef uint16_t _cffi_wchar_t; /* same random pick as _cffi_backend.c */
238+
#endif
239+
240+
_CFFI_UNUSED_FN static uint16_t _cffi_to_c_char16_t(PyObject *o)
202241
{
203-
if (PyTuple_GET_SIZE(args_tuple) != expected) {
204-
PyErr_Format(PyExc_TypeError,
205-
"%.150s() takes exactly %zd arguments (%zd given)",
206-
fnname, expected, PyTuple_GET_SIZE(args_tuple));
207-
return NULL;
208-
}
209-
return &PyTuple_GET_ITEM(args_tuple, 0); /* pointer to the first item,
210-
the others follow */
242+
if (sizeof(_cffi_wchar_t) == 2)
243+
return (uint16_t)_cffi_to_c_wchar_t(o);
244+
else
245+
return (uint16_t)_cffi_to_c_wchar3216_t(o);
211246
}
212247

248+
_CFFI_UNUSED_FN static PyObject *_cffi_from_c_char16_t(uint16_t x)
249+
{
250+
if (sizeof(_cffi_wchar_t) == 2)
251+
return _cffi_from_c_wchar_t((_cffi_wchar_t)x);
252+
else
253+
return _cffi_from_c_wchar3216_t((int)x);
254+
}
255+
256+
_CFFI_UNUSED_FN static int _cffi_to_c_char32_t(PyObject *o)
257+
{
258+
if (sizeof(_cffi_wchar_t) == 4)
259+
return (int)_cffi_to_c_wchar_t(o);
260+
else
261+
return (int)_cffi_to_c_wchar3216_t(o);
262+
}
263+
264+
_CFFI_UNUSED_FN static PyObject *_cffi_from_c_char32_t(int x)
265+
{
266+
if (sizeof(_cffi_wchar_t) == 4)
267+
return _cffi_from_c_wchar_t((_cffi_wchar_t)x);
268+
else
269+
return _cffi_from_c_wchar3216_t(x);
270+
}
271+
272+
213273
/********** end CPython-specific section **********/
214274
#else
215275
_CFFI_UNUSED_FN

0 commit comments

Comments
 (0)