# https://git-scm.com/docs/gitignore#_pattern_format
# GitHub
-.github/** @ezio-melotti
+.github/** @ezio-melotti @hugovk
+
+# pre-commit
+.pre-commit-config.yaml @hugovk @AlexWaygood
# asyncio
**/*asyncio* @1st1 @asvetlov
--- /dev/null
+name: Lint
+
+on: [push, pull_request, workflow_dispatch]
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
+ cancel-in-progress: true
+
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-python@v4
+ with:
+ python-version: "3.x"
+ - uses: pre-commit/action@v3.0.0
--- /dev/null
+repos:
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v4.4.0
+ hooks:
+ - id: check-yaml
+ - id: trailing-whitespace
+ types_or: [c, python, rst]
with asyncio.Runner() as runner:
with self.assertRaises(asyncio.CancelledError):
runner.run(coro())
-
+
def test_signal_install_not_supported_ok(self):
# signal.signal() can throw if the "main thread" doensn't have signals enabled
assert threading.current_thread() is threading.main_thread()
from test import support
-\f
class TestIsInstanceExceptions(unittest.TestCase):
# Test to make sure that an AttributeError when accessing the instance's
# class's bases is masked. This was actually a bug in Python 2.2 and
class D: pass
self.assertRaises(RuntimeError, isinstance, c, D)
-\f
+
# These tests are similar to above, but tickle certain code paths in
# issubclass() instead of isinstance() -- really PyObject_IsSubclass()
# vs. PyObject_IsInstance().
self.assertRaises(TypeError, issubclass, B, C())
-\f
# meta classes for creating abstract classes and instances
class AbstractClass(object):
def __init__(self, bases):
class Child(Super):
pass
-\f
+
class TestIsInstanceIsSubclass(unittest.TestCase):
# Tests to ensure that isinstance and issubclass work on abstract
# classes and instances. Before the 2.2 release, TypeErrors were
tuple_arg = (tuple_arg,)
fxn(arg, tuple_arg)
-\f
+
if __name__ == '__main__':
unittest.main()
#endif // HAVE_LIBB2
// for secure_zero_memory(), store32(), store48(), and store64()
-#include "impl/blake2-impl.h"
+#include "impl/blake2-impl.h"
#endif // Py_BLAKE2MODULE_H
\
row2l = _mm_roti_epi64(row2l, -24); \
row2h = _mm_roti_epi64(row2h, -24); \
-
+
#define G2(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1) \
row1l = _mm_add_epi64(_mm_add_epi64(row1l, b0), row2l); \
row1h = _mm_add_epi64(_mm_add_epi64(row1h, b1), row2h); \
\
row2l = _mm_roti_epi64(row2l, -63); \
row2h = _mm_roti_epi64(row2h, -63); \
-
+
#if defined(HAVE_SSSE3)
#define DIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \
t0 = _mm_alignr_epi8(row2h, row2l, 8); \
#define LOAD_MSG_8_3(buf) \
t0 = _mm_perm_epi8(m0, m2, _mm_set_epi32(TOB(6),TOB(1),TOB(0),TOB(0)) ); \
buf = _mm_perm_epi8(t0, m3, _mm_set_epi32(TOB(3),TOB(2),TOB(5),TOB(4)) ); \
-
+
#define LOAD_MSG_8_4(buf) \
buf = _mm_perm_epi8(m0, m1, _mm_set_epi32(TOB(5),TOB(4),TOB(7),TOB(2)) );
LOAD_MSG_ ##r ##_4(buf4); \
G2(row1,row2,row3,row4,buf4); \
UNDIAGONALIZE(row1,row2,row3,row4); \
-
+
#endif
/*
Copyright (c) 2002 Jorge Acereda <jacereda@users.sourceforge.net> &
Peter O'Gorman <ogorman@users.sourceforge.net>
-
+
Portions may be copyright others, see the AUTHORS file included with this
distribution.
arg->size = ALIGN(arg->size, curalign);
arg->size += (*ptr)->size;
- arg->alignment = (arg->alignment > curalign) ?
+ arg->alignment = (arg->alignment > curalign) ?
arg->alignment : curalign;
#else
arg->size = ALIGN(arg->size, (*ptr)->alignment);
arg->size += (*ptr)->size;
- arg->alignment = (arg->alignment > (*ptr)->alignment) ?
+ arg->alignment = (arg->alignment > (*ptr)->alignment) ?
arg->alignment : (*ptr)->alignment;
#endif
// Arguments' ffi_type->alignment must be nonzero.
ffi_status
ffi_prep_cif(
-/*@out@*/ /*@partial@*/ ffi_cif* cif,
+/*@out@*/ /*@partial@*/ ffi_cif* cif,
ffi_abi abi,
- unsigned int nargs,
-/*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type* rtype,
+ unsigned int nargs,
+/*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type* rtype,
/*@dependent@*/ ffi_type** atypes)
{
unsigned int bytes = 0;
if ((*ptr)->alignment == 0)
return FFI_BAD_TYPEDEF;
- /* Perform a sanity check on the argument type, do this
+ /* Perform a sanity check on the argument type, do this
check after the initialization. */
FFI_ASSERT_VALID_TYPE(*ptr);
void
ffi_raw_call(
-/*@dependent@*/ ffi_cif* cif,
- void (*fn)(void),
-/*@out@*/ void* rvalue,
+/*@dependent@*/ ffi_cif* cif,
+ void (*fn)(void),
+/*@out@*/ void* rvalue,
/*@dependent@*/ ffi_raw* avalue);
void
longs and doubles are followed by an empty 64-bit word. */
void
ffi_java_raw_call(
-/*@dependent@*/ ffi_cif* cif,
- void (*fn)(void),
-/*@out@*/ void* rvalue,
+/*@dependent@*/ ffi_cif* cif,
+ void (*fn)(void),
+/*@out@*/ void* rvalue,
/*@dependent@*/ ffi_raw* avalue);
void
ffi_cif* cif;
#if !FFI_NATIVE_RAW_API
- /* if this is enabled, then a raw closure has the same layout
- as a regular closure. We use this to install an intermediate
+ /* if this is enabled, then a raw closure has the same layout
+ as a regular closure. We use this to install an intermediate
handler to do the transaltion, void** -> ffi_raw*. */
void (*translate_args)(ffi_cif*,void*,void**,void*);
void* this_closure;
ffi_status
ffi_prep_cif(
-/*@out@*/ /*@partial@*/ ffi_cif* cif,
+/*@out@*/ /*@partial@*/ ffi_cif* cif,
ffi_abi abi,
- unsigned int nargs,
-/*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type* rtype,
+ unsigned int nargs,
+/*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type* rtype,
/*@dependent@*/ ffi_type** atypes);
void
ffi_call(
-/*@dependent@*/ ffi_cif* cif,
- void (*fn)(void),
-/*@out@*/ void* rvalue,
+/*@dependent@*/ ffi_cif* cif,
+ void (*fn)(void),
+/*@out@*/ void* rvalue,
/*@dependent@*/ void** avalue);
/* Useful for eliminating compiler warnings */
# endif
#endif
-/*#if defined(FFI_DEBUG)
+/*#if defined(FFI_DEBUG)
#include <stdio.h>
#endif*/
# define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
# define FFI_ASSERT_VALID_TYPE(x) ffi_type_test(x, __FILE__, __LINE__)
#else
-# define FFI_ASSERT(x)
+# define FFI_ASSERT(x)
# define FFI_ASSERT_AT(x, f, l)
# define FFI_ASSERT_VALID_TYPE(x)
#endif // #ifdef FFI_DEBUG
-/* Manually created fficonfig.h for Darwin on PowerPC or Intel
+/* Manually created fficonfig.h for Darwin on PowerPC or Intel
This file is manually generated to do away with the need for autoconf and
therefore make it easier to cross-compile and build fat binaries.
# define SIZEOF_DOUBLE 8
# if __GNUC__ >= 4
# define HAVE_LONG_DOUBLE 1
-# define SIZEOF_LONG_DOUBLE 16
+# define SIZEOF_LONG_DOUBLE 16
# else
# undef HAVE_LONG_DOUBLE
-# define SIZEOF_LONG_DOUBLE 8
+# define SIZEOF_LONG_DOUBLE 8
# endif
#elif defined(__ppc64__)
# define X86
#endif
-#if defined(__x86_64__)
+#if defined(__x86_64__)
# ifndef X86_64
# define X86_64
# endif
avalue[i] = alloca(arg_types[i]->size);
ffi64_struct_to_ram_form(arg_types[i], (const char*)pgr,
&gprSize, (const char*)pfr, &fprSize, &nf, avalue[i], NULL);
-
+
ng += gprSize / sizeof(long);
pgr += gprSize / sizeof(long);
pfr += (fprSize - savedFPRSize) / sizeof(double);
memcpy(&outGPRs[destGMarker],
&inStruct[srcMarker], inType->size);
}
-
+
srcMarker += inType->size;
destGMarker += inType->size;
i += inType->size - 1;
case FFI_TYPE_STRUCT:
recurseCount++;
ffi64_struct_to_reg_form(inType->elements[i],
- inStruct, &srcMarker, &fprsUsed, outGPRs,
+ inStruct, &srcMarker, &fprsUsed, outGPRs,
&destGMarker, outFPRs, &destFMarker);
recurseCount--;
break;
/* -----------------------------------------------------------------------
types.c - Copyright (c) 1996, 1998 Red Hat, Inc.
-
+
Predefined ffi_types needed by libffi.
Permission is hereby granted, free of charge, to any person obtaining
FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
# endif
-#elif defined ARM || defined SH || defined POWERPC_AIX
+#elif defined ARM || defined SH || defined POWERPC_AIX
FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
FFI_INTEGRAL_TYPEDEF(longdouble, 8, 4, FFI_TYPE_LONGDOUBLE);
#elif defined POWERPC_DARWIN
/* -----------------------------------------------------------------------
x86-ffi64.c - Copyright (c) 2002 Bo Thorsen <bo@suse.de>
-
- x86-64 Foreign Function Interface
+
+ x86-64 Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
case FFI_TYPE_STRUCT:
{
- ffi_type** ptr;
+ ffi_type** ptr;
int i;
enum x86_64_reg_class subclasses[MAX_CLASSES];
const int UNITS_PER_WORD = 8;
Copyright (c) 2002 Ranjit Mathew
Copyright (c) 2002 Bo Thorsen
Copyright (c) 2002 Roger Sayle
-
- x86 Foreign Function Interface
+
+ x86 Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
register void **p_argv;
register char *argp;
register ffi_type **p_arg;
-
+
argp = stack;
-
+
if (ecif->cif->flags == FFI_TYPE_STRUCT)
{
*(void **) argp = ecif->rvalue;
argp += 4;
}
-
+
p_argv = ecif->avalue;
-
+
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
i != 0;
i--, p_arg++)
{
size_t z;
-
+
/* Align if necessary */
if ((sizeof(int) - 1) & (unsigned) argp)
argp = (char *) ALIGN(argp, sizeof(int));
-
+
z = (*p_arg)->size;
if (z < sizeof(int))
{
case FFI_TYPE_SINT8:
*(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
break;
-
+
case FFI_TYPE_UINT8:
*(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
break;
-
+
case FFI_TYPE_SINT16:
*(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
break;
-
+
case FFI_TYPE_UINT16:
*(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
break;
-
+
case FFI_TYPE_SINT32:
*(signed int *) argp = (signed int)*(SINT32 *)(* p_argv);
break;
-
+
case FFI_TYPE_UINT32:
*(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
break;
-
+
case FFI_TYPE_STRUCT:
*(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
break;
-
+
default:
FFI_ASSERT(0);
}
p_argv++;
argp += z;
}
-
+
return;
}
case FFI_TYPE_SINT8:
case FFI_TYPE_SINT16:
#endif
-
+
case FFI_TYPE_SINT64:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
case FFI_TYPE_LONGDOUBLE:
cif->flags = (unsigned) cif->rtype->type;
break;
-
+
case FFI_TYPE_UINT64:
cif->flags = FFI_TYPE_SINT64;
break;
-
+
#ifndef X86
case FFI_TYPE_STRUCT:
if (cif->rtype->size == 1)
}
break;
#endif
-
+
default:
cif->flags = FFI_TYPE_INT;
break;
}
-
+
#ifdef X86_DARWIN
cif->bytes = (cif->bytes + 15) & ~0xF;
#endif
-
+
return FFI_OK;
}
void ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
{
extended_cif ecif;
-
+
ecif.cif = cif;
ecif.avalue = avalue;
-
+
/* If the return value is a struct and we don't have a return */
/* value address then we need to make one */
-
- if ((rvalue == NULL) &&
+
+ if ((rvalue == NULL) &&
(cif->flags == FFI_TYPE_STRUCT))
{
ecif.rvalue = alloca(cif->rtype->size);
}
else
ecif.rvalue = rvalue;
-
-
- switch (cif->abi)
+
+
+ switch (cif->abi)
{
case FFI_SYSV:
ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue,
// our various things...
ffi_cif *cif;
void **arg_area;
-
+
cif = closure->cif;
- arg_area = (void**) alloca (cif->nargs * sizeof (void*));
-
+ arg_area = (void**) alloca (cif->nargs * sizeof (void*));
+
/* this call will initialize ARG_AREA, such that each
- * element in that array points to the corresponding
+ * element in that array points to the corresponding
* value on the stack; and if the function returns
* a structure, it will re-set RESP to point to the
* structure return address. */
-
+
ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif);
-
+
(closure->fun) (cif, *respp, arg_area, closure->user_data);
-
+
return cif->flags;
}
register void **p_argv;
register char *argp;
register ffi_type **p_arg;
-
+
argp = stack;
-
+
if ( cif->flags == FFI_TYPE_STRUCT ) {
*rvalue = *(void **) argp;
argp += 4;
}
-
+
p_argv = avalue;
-
+
for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
{
size_t z;
-
+
/* Align if necessary */
if ((sizeof(int) - 1) & (unsigned) argp) {
argp = (char *) ALIGN(argp, sizeof(int));
}
-
+
z = (*p_arg)->size;
-
+
/* because we're little endian, this is what it turns into. */
-
+
*p_argv = (void*) argp;
-
+
p_argv++;
argp += z;
}
-
+
return;
}
{
if (cif->abi != FFI_SYSV)
return FFI_BAD_ABI;
-
+
FFI_INIT_TRAMPOLINE (&closure->tramp[0], \
&ffi_closure_SYSV, \
(void*)closure);
-
+
closure->cif = cif;
closure->user_data = user_data;
closure->fun = fun;
-
+
return FFI_OK;
}
void *codeloc)
{
int i;
-
+
FFI_ASSERT (cif->abi == FFI_SYSV);
-
+
// we currently don't support certain kinds of arguments for raw
// closures. This should be implemented by a separate assembly language
// routine, since it would require argument processing, something we
// don't do now for performance.
-
+
for (i = cif->nargs-1; i >= 0; i--)
{
FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_STRUCT);
FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_LONGDOUBLE);
}
-
-
+
+
FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_raw_SYSV,
codeloc);
-
+
closure->cif = cif;
closure->user_data = user_data;
closure->fun = fun;
-
+
return FFI_OK;
}
-static void
+static void
ffi_prep_args_raw(char *stack, extended_cif *ecif)
{
memcpy (stack, ecif->avalue, ecif->cif->bytes);
*/
extern void
-ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, unsigned,
+ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, unsigned,
unsigned, unsigned *, void (*fn)());
#ifdef X86_WIN32
{
extended_cif ecif;
void **avalue = (void **)fake_avalue;
-
+
ecif.cif = cif;
ecif.avalue = avalue;
-
+
/* If the return value is a struct and we don't have a return */
/* value address then we need to make one */
-
- if ((rvalue == NULL) &&
+
+ if ((rvalue == NULL) &&
(cif->rtype->type == FFI_TYPE_STRUCT))
{
ecif.rvalue = alloca(cif->rtype->size);
}
else
ecif.rvalue = rvalue;
-
-
- switch (cif->abi)
+
+
+ switch (cif->abi)
{
case FFI_SYSV:
ffi_call_SYSV(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags,
" I/O classes. open() uses the file's blksize (as obtained by os.stat) if\n"
" possible.\n"
);
-\f
+
/*
* The main open() function
{
return PyFile_OpenCodeObject(path);
}
-\f
+
/*
* Private helpers for the io module.
*/
int r;
Py_BEGIN_ALLOW_THREADS
- r = tcgetattr(fd, &mode);
+ r = tcgetattr(fd, &mode);
Py_END_ALLOW_THREADS
if (r == -1) {
return PyErr_SetFromErrno(state->TermiosError);
#if defined(TIOCGWINSZ)
termiosmodulestate *state = PyModule_GetState(module);
struct winsize w;
- int r;
+ int r;
Py_BEGIN_ALLOW_THREADS
r = ioctl(fd, TIOCGWINSZ, &w);
{
Py_ssize_t i,j;
switch (typ) {
- case REG_DWORD:
+ case REG_DWORD:
{
if (value != Py_None && !PyLong_Check(value)) {
return FALSE;
*retDataSize = sizeof(DWORD);
break;
}
- case REG_QWORD:
+ case REG_QWORD:
{
if (value != Py_None && !PyLong_Check(value)) {
return FALSE;
// The license and further copyright text can be found in the file
// LICENSE.TXT at the root directory of the distribution.
// </copyright>
-//
+//
// <summary>
// Precompiled header for standard bootstrapper application.
// </summary>
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102