From 9327cf719accc962c2d2c22d546f11100f1290e0 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 5 Mar 2022 19:53:25 +0200 Subject: [PATCH 1/7] Add pre-commit config and test on CI --- .github/CODEOWNERS | 5 ++++- .github/workflows/lint.yml | 18 ++++++++++++++++++ .pre-commit-config.yaml | 7 +++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 3d39e0c4ef0417..57a8395943563e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,7 +5,10 @@ # https://git-scm.com/docs/gitignore#_pattern_format # GitHub -.github/** @ezio-melotti +.github/** @ezio-melotti @hugovk + +# pre-commit +.pre-commit-config.yaml @hugovk # asyncio **/*asyncio* @1st1 @asvetlov diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000000000..2556f48bd45051 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,18 @@ +name: Lint + +on: [push, pull_request, workflow_dispatch] + +permissions: + contents: read + +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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000000000..808622f19a3dbf --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,7 @@ +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] From cd547a2fd51455f9816bfba8e6912a2a4ca8155f Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Mon, 21 Aug 2023 16:23:45 +0300 Subject: [PATCH 2/7] Trim trailing whitespace --- Lib/email/__init__.py | 2 +- Lib/email/base64mime.py | 8 +- Lib/email/charset.py | 10 +- Lib/email/encoders.py | 8 +- Lib/email/feedparser.py | 4 +- Lib/email/generator.py | 8 +- Lib/email/header.py | 10 +- Lib/email/iterators.py | 6 +- Lib/email/mime/base.py | 2 +- Lib/email/mime/message.py | 2 +- Lib/email/mime/multipart.py | 2 +- Lib/email/mime/nonmultipart.py | 2 +- Lib/email/mime/text.py | 2 +- Lib/email/parser.py | 4 +- Lib/test/test_asyncio/test_runners.py | 2 +- Lib/test/test_isinstance.py | 10 +- Modules/_blake2/blake2module.h | 2 +- Modules/_blake2/impl/blake2b-round.h | 4 +- Modules/_blake2/impl/blake2s-load-xop.h | 2 +- Modules/_blake2/impl/blake2s-round.h | 2 +- Modules/_ctypes/darwin/dlfcn.h | 2 +- Modules/_ctypes/libffi_osx/ffi.c | 12 +- Modules/_ctypes/libffi_osx/include/ffi.h | 28 ++-- .../_ctypes/libffi_osx/include/ffi_common.h | 4 +- .../_ctypes/libffi_osx/include/fficonfig.h | 6 +- .../libffi_osx/include/x86-ffitarget.h | 2 +- .../libffi_osx/powerpc/ppc-ffi_darwin.c | 6 +- Modules/_ctypes/libffi_osx/types.c | 4 +- Modules/_ctypes/libffi_osx/x86/x86-ffi64.c | 6 +- .../_ctypes/libffi_osx/x86/x86-ffi_darwin.c | 130 +++++++++--------- Modules/_io/_iomodule.c | 4 +- Modules/_io/bufferedio.c | 6 +- Modules/termios.c | 4 +- PC/winreg.c | 4 +- Tools/i18n/pygettext.py | 14 +- Tools/msi/bundle/bootstrap/pch.h | 2 +- Tools/msi/bundle/bootstrap/resource.h | 2 +- 37 files changed, 164 insertions(+), 164 deletions(-) diff --git a/Lib/email/__init__.py b/Lib/email/__init__.py index fae872439edc66..0ee21b44f9d690 100644 --- a/Lib/email/__init__.py +++ b/Lib/email/__init__.py @@ -25,7 +25,7 @@ ] - + # Some convenience routines. Don't import Parser and Message as side-effects # of importing email since those cascadingly import most of the rest of the # email package. diff --git a/Lib/email/base64mime.py b/Lib/email/base64mime.py index a7cc37365c6f9a..35c5537527dc49 100644 --- a/Lib/email/base64mime.py +++ b/Lib/email/base64mime.py @@ -45,7 +45,7 @@ MISC_LEN = 7 - + # Helpers def header_length(bytearray): """Return the length of s when it is encoded with base64.""" @@ -57,7 +57,7 @@ def header_length(bytearray): return n - + def header_encode(header_bytes, charset='iso-8859-1'): """Encode a single header line with Base64 encoding in a given charset. @@ -72,7 +72,7 @@ def header_encode(header_bytes, charset='iso-8859-1'): return '=?%s?b?%s?=' % (charset, encoded) - + def body_encode(s, maxlinelen=76, eol=NL): r"""Encode a string with base64. @@ -98,7 +98,7 @@ def body_encode(s, maxlinelen=76, eol=NL): return EMPTYSTRING.join(encvec) - + def decode(string): """Decode a raw base64 string, returning a bytes object. diff --git a/Lib/email/charset.py b/Lib/email/charset.py index d3d759ad9115f0..e849827aa466e3 100644 --- a/Lib/email/charset.py +++ b/Lib/email/charset.py @@ -18,7 +18,7 @@ from email.encoders import encode_7or8bit - + # Flags for types of header encodings QP = 1 # Quoted-Printable BASE64 = 2 # Base64 @@ -32,7 +32,7 @@ EMPTYSTRING = '' - + # Defaults CHARSETS = { # input header enc body enc output conv @@ -104,7 +104,7 @@ } - + # Convenience functions for extending the above mappings def add_charset(charset, header_enc=None, body_enc=None, output_charset=None): """Add character set properties to the global registry. @@ -153,7 +153,7 @@ def add_codec(charset, codecname): CODEC_MAP[charset] = codecname - + # Convenience function for encoding strings, taking into account # that they might be unknown-8bit (ie: have surrogate-escaped bytes) def _encode(string, codec): @@ -163,7 +163,7 @@ def _encode(string, codec): return string.encode(codec) - + class Charset: """Map character sets to their email properties. diff --git a/Lib/email/encoders.py b/Lib/email/encoders.py index 0a66acb6240bd7..b818b9cd916d6f 100644 --- a/Lib/email/encoders.py +++ b/Lib/email/encoders.py @@ -16,7 +16,7 @@ from quopri import encodestring as _encodestring - + def _qencode(s): enc = _encodestring(s, quotetabs=True) # Must encode spaces, which quopri.encodestring() doesn't do @@ -34,7 +34,7 @@ def encode_base64(msg): msg['Content-Transfer-Encoding'] = 'base64' - + def encode_quopri(msg): """Encode the message's payload in quoted-printable. @@ -46,7 +46,7 @@ def encode_quopri(msg): msg['Content-Transfer-Encoding'] = 'quoted-printable' - + def encode_7or8bit(msg): """Set the Content-Transfer-Encoding header to 7bit or 8bit.""" orig = msg.get_payload(decode=True) @@ -64,6 +64,6 @@ def encode_7or8bit(msg): msg['Content-Transfer-Encoding'] = '7bit' - + def encode_noop(msg): """Do nothing.""" diff --git a/Lib/email/feedparser.py b/Lib/email/feedparser.py index e400dc7fb89b05..2462a36f2bd3b3 100644 --- a/Lib/email/feedparser.py +++ b/Lib/email/feedparser.py @@ -41,7 +41,7 @@ NeedMoreData = object() - + class BufferedSubFile(object): """A file-ish object that can have new data loaded into it. @@ -132,7 +132,7 @@ def __next__(self): return line - + class FeedParser: """A feed-style parser of email.""" diff --git a/Lib/email/generator.py b/Lib/email/generator.py index c9b121624e08d5..4763038bae34dc 100644 --- a/Lib/email/generator.py +++ b/Lib/email/generator.py @@ -22,7 +22,7 @@ fcre = re.compile(r'^From ', re.MULTILINE) - + class Generator: """Generates output from a Message object tree. @@ -392,7 +392,7 @@ def _make_boundary(cls, text=None): def _compile_re(cls, s, flags): return re.compile(s, flags) - + class BytesGenerator(Generator): """Generates a bytes version of a Message object tree. @@ -443,7 +443,7 @@ def _compile_re(cls, s, flags): return re.compile(s.encode('ascii'), flags) - + _FMT = '[Non-text (%(type)s) part of message omitted, filename %(filename)s]' class DecodedGenerator(Generator): @@ -503,7 +503,7 @@ def _dispatch(self, msg): }, file=self) - + # Helper used by Generator._make_boundary _width = len(repr(sys.maxsize-1)) _fmt = '%%0%dd' % _width diff --git a/Lib/email/header.py b/Lib/email/header.py index 4ab0032bc66123..27e70dc4be2713 100644 --- a/Lib/email/header.py +++ b/Lib/email/header.py @@ -52,12 +52,12 @@ _embedded_header = re.compile(r'\n[^ \t]+:') - + # Helpers _max_append = email.quoprimime._max_append - + def decode_header(header): """Decode a message header value without converting charset. @@ -152,7 +152,7 @@ def decode_header(header): return collapsed - + def make_header(decoded_seq, maxlinelen=None, header_name=None, continuation_ws=' '): """Create a Header from a sequence of pairs as returned by decode_header() @@ -175,7 +175,7 @@ def make_header(decoded_seq, maxlinelen=None, header_name=None, return h - + class Header: def __init__(self, s=None, charset=None, maxlinelen=None, header_name=None, @@ -409,7 +409,7 @@ def _normalize(self): self._chunks = chunks - + class _ValueFormatter: def __init__(self, headerlen, maxlen, continuation_ws, splitchars): self._maxlen = maxlen diff --git a/Lib/email/iterators.py b/Lib/email/iterators.py index b5502ee975266b..1ea220baecce9c 100644 --- a/Lib/email/iterators.py +++ b/Lib/email/iterators.py @@ -15,7 +15,7 @@ from io import StringIO - + # This function will become a method of the Message class def walk(self): """Walk over the message tree, yielding each subpart. @@ -29,7 +29,7 @@ def walk(self): yield from subpart.walk() - + # These two functions are imported into the Iterators.py interface module. def body_line_iterator(msg, decode=False): """Iterate over the parts, returning string payloads line-by-line. @@ -55,7 +55,7 @@ def typed_subpart_iterator(msg, maintype='text', subtype=None): yield subpart - + def _structure(msg, fp=None, level=0, include_default=False): """A handy debugging aid""" if fp is None: diff --git a/Lib/email/mime/base.py b/Lib/email/mime/base.py index 1a3f9b51f6c045..8eb7e5db5cc1c6 100644 --- a/Lib/email/mime/base.py +++ b/Lib/email/mime/base.py @@ -11,7 +11,7 @@ from email import message - + class MIMEBase(message.Message): """Base class for MIME specializations.""" diff --git a/Lib/email/mime/message.py b/Lib/email/mime/message.py index 07e4f2d1196151..ce50af26b24497 100644 --- a/Lib/email/mime/message.py +++ b/Lib/email/mime/message.py @@ -10,7 +10,7 @@ from email.mime.nonmultipart import MIMENonMultipart - + class MIMEMessage(MIMENonMultipart): """Class representing message/* MIME documents.""" diff --git a/Lib/email/mime/multipart.py b/Lib/email/mime/multipart.py index 2d3f288810dd91..93b5d27bfcdb3c 100644 --- a/Lib/email/mime/multipart.py +++ b/Lib/email/mime/multipart.py @@ -9,7 +9,7 @@ from email.mime.base import MIMEBase - + class MIMEMultipart(MIMEBase): """Base class for MIME multipart/* type messages.""" diff --git a/Lib/email/mime/nonmultipart.py b/Lib/email/mime/nonmultipart.py index e1f51968b59eb1..991a97d80d822e 100644 --- a/Lib/email/mime/nonmultipart.py +++ b/Lib/email/mime/nonmultipart.py @@ -10,7 +10,7 @@ from email.mime.base import MIMEBase - + class MIMENonMultipart(MIMEBase): """Base class for MIME non-multipart type messages.""" diff --git a/Lib/email/mime/text.py b/Lib/email/mime/text.py index 35b442383002b2..b6b394e49a060e 100644 --- a/Lib/email/mime/text.py +++ b/Lib/email/mime/text.py @@ -10,7 +10,7 @@ from email.mime.nonmultipart import MIMENonMultipart - + class MIMEText(MIMENonMultipart): """Class for generating text/* type MIME documents.""" diff --git a/Lib/email/parser.py b/Lib/email/parser.py index 7db4da1ff081c1..13d7816032a500 100644 --- a/Lib/email/parser.py +++ b/Lib/email/parser.py @@ -67,7 +67,7 @@ def parsestr(self, text, headersonly=False): return self.parse(StringIO(text), headersonly=headersonly) - + class HeaderParser(Parser): def parse(self, fp, headersonly=True): return Parser.parse(self, fp, True) @@ -75,7 +75,7 @@ def parse(self, fp, headersonly=True): def parsestr(self, text, headersonly=True): return Parser.parsestr(self, text, True) - + class BytesParser: def __init__(self, *args, **kw): diff --git a/Lib/test/test_asyncio/test_runners.py b/Lib/test/test_asyncio/test_runners.py index 8a4aba6d470bac..ae823cc7bec33e 100644 --- a/Lib/test/test_asyncio/test_runners.py +++ b/Lib/test/test_asyncio/test_runners.py @@ -441,7 +441,7 @@ async def coro(): 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() diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py index a0974640bc1146..e7508d9b1d5d19 100644 --- a/Lib/test/test_isinstance.py +++ b/Lib/test/test_isinstance.py @@ -8,7 +8,7 @@ from test import support - + 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 @@ -97,7 +97,7 @@ def getclass(self): class D: pass self.assertRaises(RuntimeError, isinstance, c, D) - + # These tests are similar to above, but tickle certain code paths in # issubclass() instead of isinstance() -- really PyObject_IsSubclass() # vs. PyObject_IsInstance(). @@ -147,7 +147,7 @@ def getbases(self): self.assertRaises(TypeError, issubclass, B, C()) - + # meta classes for creating abstract classes and instances class AbstractClass(object): def __init__(self, bases): @@ -179,7 +179,7 @@ class Super: class Child(Super): pass - + class TestIsInstanceIsSubclass(unittest.TestCase): # Tests to ensure that isinstance and issubclass work on abstract # classes and instances. Before the 2.2 release, TypeErrors were @@ -357,6 +357,6 @@ def blowstack(fxn, arg, compare_to): tuple_arg = (tuple_arg,) fxn(arg, tuple_arg) - + if __name__ == '__main__': unittest.main() diff --git a/Modules/_blake2/blake2module.h b/Modules/_blake2/blake2module.h index aa8f281178eadc..c8144ec9d48d29 100644 --- a/Modules/_blake2/blake2module.h +++ b/Modules/_blake2/blake2module.h @@ -38,6 +38,6 @@ #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 diff --git a/Modules/_blake2/impl/blake2b-round.h b/Modules/_blake2/impl/blake2b-round.h index cebc22550da4cd..5b452c4d63babe 100644 --- a/Modules/_blake2/impl/blake2b-round.h +++ b/Modules/_blake2/impl/blake2b-round.h @@ -62,7 +62,7 @@ \ 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); \ @@ -81,7 +81,7 @@ \ 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); \ diff --git a/Modules/_blake2/impl/blake2s-load-xop.h b/Modules/_blake2/impl/blake2s-load-xop.h index ac591a77d191a7..14d9e7f7640672 100644 --- a/Modules/_blake2/impl/blake2s-load-xop.h +++ b/Modules/_blake2/impl/blake2s-load-xop.h @@ -166,7 +166,7 @@ buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(3),TOB(2),TOB(1),TOB(7)) ); #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)) ); diff --git a/Modules/_blake2/impl/blake2s-round.h b/Modules/_blake2/impl/blake2s-round.h index 1e2f2b7f59bd6c..3af4be35bee5d4 100644 --- a/Modules/_blake2/impl/blake2s-round.h +++ b/Modules/_blake2/impl/blake2s-round.h @@ -86,6 +86,6 @@ LOAD_MSG_ ##r ##_4(buf4); \ G2(row1,row2,row3,row4,buf4); \ UNDIAGONALIZE(row1,row2,row3,row4); \ - + #endif diff --git a/Modules/_ctypes/darwin/dlfcn.h b/Modules/_ctypes/darwin/dlfcn.h index a2afc3eeb84794..a9915c3115ceb6 100644 --- a/Modules/_ctypes/darwin/dlfcn.h +++ b/Modules/_ctypes/darwin/dlfcn.h @@ -1,7 +1,7 @@ /* Copyright (c) 2002 Jorge Acereda & Peter O'Gorman - + Portions may be copyright others, see the AUTHORS file included with this distribution. diff --git a/Modules/_ctypes/libffi_osx/ffi.c b/Modules/_ctypes/libffi_osx/ffi.c index 1776b795e2f83d..e16423aef19fc0 100644 --- a/Modules/_ctypes/libffi_osx/ffi.c +++ b/Modules/_ctypes/libffi_osx/ffi.c @@ -65,12 +65,12 @@ initialize_aggregate( 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 @@ -130,10 +130,10 @@ struct_on_stack( // 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; @@ -184,7 +184,7 @@ ffi_prep_cif( 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); diff --git a/Modules/_ctypes/libffi_osx/include/ffi.h b/Modules/_ctypes/libffi_osx/include/ffi.h index c104a5c89350b6..88c58fc43deb6b 100644 --- a/Modules/_ctypes/libffi_osx/include/ffi.h +++ b/Modules/_ctypes/libffi_osx/include/ffi.h @@ -199,9 +199,9 @@ typedef union { 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 @@ -225,9 +225,9 @@ ffi_raw_size( 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 @@ -272,8 +272,8 @@ typedef struct ffi_raw_closure { 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; @@ -303,17 +303,17 @@ ffi_prep_java_raw_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 */ diff --git a/Modules/_ctypes/libffi_osx/include/ffi_common.h b/Modules/_ctypes/libffi_osx/include/ffi_common.h index 685a3580f4fe05..02b53c8600e012 100644 --- a/Modules/_ctypes/libffi_osx/include/ffi_common.h +++ b/Modules/_ctypes/libffi_osx/include/ffi_common.h @@ -41,7 +41,7 @@ char* alloca(); # endif #endif -/*#if defined(FFI_DEBUG) +/*#if defined(FFI_DEBUG) #include #endif*/ @@ -65,7 +65,7 @@ ffi_type_test( # 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 diff --git a/Modules/_ctypes/libffi_osx/include/fficonfig.h b/Modules/_ctypes/libffi_osx/include/fficonfig.h index 217249071dcf48..dc0f4ecb26ee0b 100644 --- a/Modules/_ctypes/libffi_osx/include/fficonfig.h +++ b/Modules/_ctypes/libffi_osx/include/fficonfig.h @@ -1,4 +1,4 @@ -/* 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. @@ -33,10 +33,10 @@ # 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__) diff --git a/Modules/_ctypes/libffi_osx/include/x86-ffitarget.h b/Modules/_ctypes/libffi_osx/include/x86-ffitarget.h index 55c2b6c50cd90c..df149eb14d78c7 100644 --- a/Modules/_ctypes/libffi_osx/include/x86-ffitarget.h +++ b/Modules/_ctypes/libffi_osx/include/x86-ffitarget.h @@ -33,7 +33,7 @@ # define X86 #endif -#if defined(__x86_64__) +#if defined(__x86_64__) # ifndef X86_64 # define X86_64 # endif diff --git a/Modules/_ctypes/libffi_osx/powerpc/ppc-ffi_darwin.c b/Modules/_ctypes/libffi_osx/powerpc/ppc-ffi_darwin.c index 8953d5fda35818..875412a6766957 100644 --- a/Modules/_ctypes/libffi_osx/powerpc/ppc-ffi_darwin.c +++ b/Modules/_ctypes/libffi_osx/powerpc/ppc-ffi_darwin.c @@ -891,7 +891,7 @@ ffi_closure_helper_DARWIN( 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); @@ -1479,7 +1479,7 @@ ffi64_struct_to_reg_form( memcpy(&outGPRs[destGMarker], &inStruct[srcMarker], inType->size); } - + srcMarker += inType->size; destGMarker += inType->size; i += inType->size - 1; @@ -1561,7 +1561,7 @@ ffi64_struct_to_reg_form( 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; diff --git a/Modules/_ctypes/libffi_osx/types.c b/Modules/_ctypes/libffi_osx/types.c index 44806aeeb75d37..761d223ff1498c 100644 --- a/Modules/_ctypes/libffi_osx/types.c +++ b/Modules/_ctypes/libffi_osx/types.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- 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 @@ -85,7 +85,7 @@ FFI_INTEGRAL_TYPEDEF(sint64, 8, 8, FFI_TYPE_SINT64); 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 diff --git a/Modules/_ctypes/libffi_osx/x86/x86-ffi64.c b/Modules/_ctypes/libffi_osx/x86/x86-ffi64.c index 8e7d016488029f..b8ae6e80231ece 100644 --- a/Modules/_ctypes/libffi_osx/x86/x86-ffi64.c +++ b/Modules/_ctypes/libffi_osx/x86/x86-ffi64.c @@ -2,8 +2,8 @@ /* ----------------------------------------------------------------------- x86-ffi64.c - Copyright (c) 2002 Bo Thorsen - - 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 @@ -208,7 +208,7 @@ classify_argument( 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; diff --git a/Modules/_ctypes/libffi_osx/x86/x86-ffi_darwin.c b/Modules/_ctypes/libffi_osx/x86/x86-ffi_darwin.c index 706ea0f51206dc..59e36158067394 100644 --- a/Modules/_ctypes/libffi_osx/x86/x86-ffi_darwin.c +++ b/Modules/_ctypes/libffi_osx/x86/x86-ffi_darwin.c @@ -4,8 +4,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 @@ -43,27 +43,27 @@ void ffi_prep_args(char *stack, extended_cif *ecif) 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)) { @@ -73,31 +73,31 @@ void ffi_prep_args(char *stack, extended_cif *ecif) 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); } @@ -109,7 +109,7 @@ void ffi_prep_args(char *stack, extended_cif *ecif) p_argv++; argp += z; } - + return; } @@ -127,18 +127,18 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif) 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) @@ -163,16 +163,16 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif) } break; #endif - + default: cif->flags = FFI_TYPE_INT; break; } - + #ifdef X86_DARWIN cif->bytes = (cif->bytes + 15) & ~0xF; #endif - + return FFI_OK; } @@ -188,23 +188,23 @@ extern void ffi_call_STDCALL(void (*)(char *, extended_cif *), extended_cif *, 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, @@ -245,20 +245,20 @@ void *args; // 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; } @@ -270,35 +270,35 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue, 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; } @@ -325,15 +325,15 @@ ffi_prep_closure (ffi_closure* closure, { 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; } @@ -349,32 +349,32 @@ ffi_prep_raw_closure_loc (ffi_raw_closure* closure, 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); @@ -386,7 +386,7 @@ ffi_prep_args_raw(char *stack, extended_cif *ecif) */ 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 @@ -400,23 +400,23 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(), void *rvalue, ffi_raw *fake_avalue) { 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, diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index a7b2e984310d18..aa877174417cdd 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -59,7 +59,7 @@ PyDoc_STRVAR(module_doc, " I/O classes. open() uses the file's blksize (as obtained by os.stat) if\n" " possible.\n" ); - + /* * The main open() function @@ -512,7 +512,7 @@ _io_open_code_impl(PyObject *module, PyObject *path) { return PyFile_OpenCodeObject(path); } - + /* * Private helpers for the io module. */ diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 4a4a1992dbbb7a..4b94ed42dcf4b6 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -1740,7 +1740,7 @@ _bufferedreader_peek_unlocked(buffered *self) self->pos = 0; return PyBytes_FromStringAndSize(self->buffer, r); } - + /* @@ -2047,7 +2047,7 @@ _io_BufferedWriter_write_impl(buffered *self, Py_buffer *buffer) LEAVE_BUFFERED(self) return res; } - + /* @@ -2253,7 +2253,7 @@ bufferedrwpair_closed_get(rwpair *self, void *context) } return PyObject_GetAttr((PyObject *) self->writer, &_Py_ID(closed)); } - + /* diff --git a/Modules/termios.c b/Modules/termios.c index fcc8f042679870..3900a6f0b89860 100644 --- a/Modules/termios.c +++ b/Modules/termios.c @@ -85,7 +85,7 @@ termios_tcgetattr_impl(PyObject *module, int fd) 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); @@ -372,7 +372,7 @@ termios_tcgetwinsize_impl(PyObject *module, int fd) #if defined(TIOCGWINSZ) termiosmodulestate *state = PyModule_GetState(module); struct winsize w; - int r; + int r; Py_BEGIN_ALLOW_THREADS r = ioctl(fd, TIOCGWINSZ, &w); diff --git a/PC/winreg.c b/PC/winreg.c index f668cf3c19cab5..940278194f4cf5 100644 --- a/PC/winreg.c +++ b/PC/winreg.c @@ -564,7 +564,7 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) { Py_ssize_t i,j; switch (typ) { - case REG_DWORD: + case REG_DWORD: { if (value != Py_None && !PyLong_Check(value)) { return FALSE; @@ -588,7 +588,7 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) *retDataSize = sizeof(DWORD); break; } - case REG_QWORD: + case REG_QWORD: { if (value != Py_None && !PyLong_Check(value)) { return FALSE; diff --git a/Tools/i18n/pygettext.py b/Tools/i18n/pygettext.py index 7ada79105db1ca..f38b8569328900 100755 --- a/Tools/i18n/pygettext.py +++ b/Tools/i18n/pygettext.py @@ -174,7 +174,7 @@ EMPTYSTRING = '' - + # The normal pot-file header. msgmerge and Emacs's po-mode work better if it's # there. pot_header = _('''\ @@ -196,7 +196,7 @@ ''') - + def usage(code, msg=''): print(__doc__ % globals(), file=sys.stderr) if msg: @@ -204,7 +204,7 @@ def usage(code, msg=''): sys.exit(code) - + def make_escapes(pass_nonascii): global escapes, escape if pass_nonascii: @@ -258,7 +258,7 @@ def normalize(s, encoding): s = '""\n"' + lineterm.join(lines) + '"' return s - + def containsAny(str, set): """Check whether 'str' contains ANY of the chars in 'set'""" return 1 in [c in str for c in set] @@ -307,7 +307,7 @@ def getFilesForName(name): return [] - + class TokenEater: def __init__(self, options): self.__options = options @@ -515,7 +515,7 @@ def write(self, fp): print('msgstr ""\n', file=fp) - + def main(): global default_keywords try: @@ -675,7 +675,7 @@ class Options: if closep: fp.close() - + if __name__ == '__main__': main() # some more test strings diff --git a/Tools/msi/bundle/bootstrap/pch.h b/Tools/msi/bundle/bootstrap/pch.h index b0aa5111dabd0d..6d0974b34c61e7 100644 --- a/Tools/msi/bundle/bootstrap/pch.h +++ b/Tools/msi/bundle/bootstrap/pch.h @@ -5,7 +5,7 @@ // The license and further copyright text can be found in the file // LICENSE.TXT at the root directory of the distribution. // -// +// // // Precompiled header for standard bootstrapper application. // diff --git a/Tools/msi/bundle/bootstrap/resource.h b/Tools/msi/bundle/bootstrap/resource.h index 53c03c319f091f..d951e651f6d20d 100644 --- a/Tools/msi/bundle/bootstrap/resource.h +++ b/Tools/msi/bundle/bootstrap/resource.h @@ -14,7 +14,7 @@ // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 102 From b40bc8e4004f77899205d367f471e4d4b889c7c3 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Mon, 8 May 2023 12:51:43 +0300 Subject: [PATCH 3/7] Add Alex to CODEOWNERS Co-authored-by: Alex Waygood --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 57a8395943563e..99d701daa1d49a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -8,7 +8,7 @@ .github/** @ezio-melotti @hugovk # pre-commit -.pre-commit-config.yaml @hugovk +.pre-commit-config.yaml @hugovk @AlexWaygood # asyncio **/*asyncio* @1st1 @asvetlov From 877393b0778546c2beb98ee06f33fc6c67547e39 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Mon, 8 May 2023 15:02:18 +0300 Subject: [PATCH 4/7] Add concurrency key to avoid duplicate builds --- .github/workflows/lint.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2556f48bd45051..4481ea80bfd936 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,6 +5,10 @@ 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 From 834cc88f059cba705b87a5353492e04812803f67 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 22 Aug 2023 11:35:53 +0300 Subject: [PATCH 5/7] Revert "Trim trailing whitespace" This reverts commit cd547a2fd51455f9816bfba8e6912a2a4ca8155f. --- Lib/email/__init__.py | 2 +- Lib/email/base64mime.py | 8 +- Lib/email/charset.py | 10 +- Lib/email/encoders.py | 8 +- Lib/email/feedparser.py | 4 +- Lib/email/generator.py | 8 +- Lib/email/header.py | 10 +- Lib/email/iterators.py | 6 +- Lib/email/mime/base.py | 2 +- Lib/email/mime/message.py | 2 +- Lib/email/mime/multipart.py | 2 +- Lib/email/mime/nonmultipart.py | 2 +- Lib/email/mime/text.py | 2 +- Lib/email/parser.py | 4 +- Lib/test/test_asyncio/test_runners.py | 2 +- Lib/test/test_isinstance.py | 10 +- Modules/_blake2/blake2module.h | 2 +- Modules/_blake2/impl/blake2b-round.h | 4 +- Modules/_blake2/impl/blake2s-load-xop.h | 2 +- Modules/_blake2/impl/blake2s-round.h | 2 +- Modules/_ctypes/darwin/dlfcn.h | 2 +- Modules/_ctypes/libffi_osx/ffi.c | 12 +- Modules/_ctypes/libffi_osx/include/ffi.h | 28 ++-- .../_ctypes/libffi_osx/include/ffi_common.h | 4 +- .../_ctypes/libffi_osx/include/fficonfig.h | 6 +- .../libffi_osx/include/x86-ffitarget.h | 2 +- .../libffi_osx/powerpc/ppc-ffi_darwin.c | 6 +- Modules/_ctypes/libffi_osx/types.c | 4 +- Modules/_ctypes/libffi_osx/x86/x86-ffi64.c | 6 +- .../_ctypes/libffi_osx/x86/x86-ffi_darwin.c | 130 +++++++++--------- Modules/_io/_iomodule.c | 4 +- Modules/_io/bufferedio.c | 6 +- Modules/termios.c | 4 +- PC/winreg.c | 4 +- Tools/i18n/pygettext.py | 14 +- Tools/msi/bundle/bootstrap/pch.h | 2 +- Tools/msi/bundle/bootstrap/resource.h | 2 +- 37 files changed, 164 insertions(+), 164 deletions(-) diff --git a/Lib/email/__init__.py b/Lib/email/__init__.py index 0ee21b44f9d690..fae872439edc66 100644 --- a/Lib/email/__init__.py +++ b/Lib/email/__init__.py @@ -25,7 +25,7 @@ ] - + # Some convenience routines. Don't import Parser and Message as side-effects # of importing email since those cascadingly import most of the rest of the # email package. diff --git a/Lib/email/base64mime.py b/Lib/email/base64mime.py index 35c5537527dc49..a7cc37365c6f9a 100644 --- a/Lib/email/base64mime.py +++ b/Lib/email/base64mime.py @@ -45,7 +45,7 @@ MISC_LEN = 7 - + # Helpers def header_length(bytearray): """Return the length of s when it is encoded with base64.""" @@ -57,7 +57,7 @@ def header_length(bytearray): return n - + def header_encode(header_bytes, charset='iso-8859-1'): """Encode a single header line with Base64 encoding in a given charset. @@ -72,7 +72,7 @@ def header_encode(header_bytes, charset='iso-8859-1'): return '=?%s?b?%s?=' % (charset, encoded) - + def body_encode(s, maxlinelen=76, eol=NL): r"""Encode a string with base64. @@ -98,7 +98,7 @@ def body_encode(s, maxlinelen=76, eol=NL): return EMPTYSTRING.join(encvec) - + def decode(string): """Decode a raw base64 string, returning a bytes object. diff --git a/Lib/email/charset.py b/Lib/email/charset.py index e849827aa466e3..d3d759ad9115f0 100644 --- a/Lib/email/charset.py +++ b/Lib/email/charset.py @@ -18,7 +18,7 @@ from email.encoders import encode_7or8bit - + # Flags for types of header encodings QP = 1 # Quoted-Printable BASE64 = 2 # Base64 @@ -32,7 +32,7 @@ EMPTYSTRING = '' - + # Defaults CHARSETS = { # input header enc body enc output conv @@ -104,7 +104,7 @@ } - + # Convenience functions for extending the above mappings def add_charset(charset, header_enc=None, body_enc=None, output_charset=None): """Add character set properties to the global registry. @@ -153,7 +153,7 @@ def add_codec(charset, codecname): CODEC_MAP[charset] = codecname - + # Convenience function for encoding strings, taking into account # that they might be unknown-8bit (ie: have surrogate-escaped bytes) def _encode(string, codec): @@ -163,7 +163,7 @@ def _encode(string, codec): return string.encode(codec) - + class Charset: """Map character sets to their email properties. diff --git a/Lib/email/encoders.py b/Lib/email/encoders.py index b818b9cd916d6f..0a66acb6240bd7 100644 --- a/Lib/email/encoders.py +++ b/Lib/email/encoders.py @@ -16,7 +16,7 @@ from quopri import encodestring as _encodestring - + def _qencode(s): enc = _encodestring(s, quotetabs=True) # Must encode spaces, which quopri.encodestring() doesn't do @@ -34,7 +34,7 @@ def encode_base64(msg): msg['Content-Transfer-Encoding'] = 'base64' - + def encode_quopri(msg): """Encode the message's payload in quoted-printable. @@ -46,7 +46,7 @@ def encode_quopri(msg): msg['Content-Transfer-Encoding'] = 'quoted-printable' - + def encode_7or8bit(msg): """Set the Content-Transfer-Encoding header to 7bit or 8bit.""" orig = msg.get_payload(decode=True) @@ -64,6 +64,6 @@ def encode_7or8bit(msg): msg['Content-Transfer-Encoding'] = '7bit' - + def encode_noop(msg): """Do nothing.""" diff --git a/Lib/email/feedparser.py b/Lib/email/feedparser.py index 2462a36f2bd3b3..e400dc7fb89b05 100644 --- a/Lib/email/feedparser.py +++ b/Lib/email/feedparser.py @@ -41,7 +41,7 @@ NeedMoreData = object() - + class BufferedSubFile(object): """A file-ish object that can have new data loaded into it. @@ -132,7 +132,7 @@ def __next__(self): return line - + class FeedParser: """A feed-style parser of email.""" diff --git a/Lib/email/generator.py b/Lib/email/generator.py index 4763038bae34dc..c9b121624e08d5 100644 --- a/Lib/email/generator.py +++ b/Lib/email/generator.py @@ -22,7 +22,7 @@ fcre = re.compile(r'^From ', re.MULTILINE) - + class Generator: """Generates output from a Message object tree. @@ -392,7 +392,7 @@ def _make_boundary(cls, text=None): def _compile_re(cls, s, flags): return re.compile(s, flags) - + class BytesGenerator(Generator): """Generates a bytes version of a Message object tree. @@ -443,7 +443,7 @@ def _compile_re(cls, s, flags): return re.compile(s.encode('ascii'), flags) - + _FMT = '[Non-text (%(type)s) part of message omitted, filename %(filename)s]' class DecodedGenerator(Generator): @@ -503,7 +503,7 @@ def _dispatch(self, msg): }, file=self) - + # Helper used by Generator._make_boundary _width = len(repr(sys.maxsize-1)) _fmt = '%%0%dd' % _width diff --git a/Lib/email/header.py b/Lib/email/header.py index 27e70dc4be2713..4ab0032bc66123 100644 --- a/Lib/email/header.py +++ b/Lib/email/header.py @@ -52,12 +52,12 @@ _embedded_header = re.compile(r'\n[^ \t]+:') - + # Helpers _max_append = email.quoprimime._max_append - + def decode_header(header): """Decode a message header value without converting charset. @@ -152,7 +152,7 @@ def decode_header(header): return collapsed - + def make_header(decoded_seq, maxlinelen=None, header_name=None, continuation_ws=' '): """Create a Header from a sequence of pairs as returned by decode_header() @@ -175,7 +175,7 @@ def make_header(decoded_seq, maxlinelen=None, header_name=None, return h - + class Header: def __init__(self, s=None, charset=None, maxlinelen=None, header_name=None, @@ -409,7 +409,7 @@ def _normalize(self): self._chunks = chunks - + class _ValueFormatter: def __init__(self, headerlen, maxlen, continuation_ws, splitchars): self._maxlen = maxlen diff --git a/Lib/email/iterators.py b/Lib/email/iterators.py index 1ea220baecce9c..b5502ee975266b 100644 --- a/Lib/email/iterators.py +++ b/Lib/email/iterators.py @@ -15,7 +15,7 @@ from io import StringIO - + # This function will become a method of the Message class def walk(self): """Walk over the message tree, yielding each subpart. @@ -29,7 +29,7 @@ def walk(self): yield from subpart.walk() - + # These two functions are imported into the Iterators.py interface module. def body_line_iterator(msg, decode=False): """Iterate over the parts, returning string payloads line-by-line. @@ -55,7 +55,7 @@ def typed_subpart_iterator(msg, maintype='text', subtype=None): yield subpart - + def _structure(msg, fp=None, level=0, include_default=False): """A handy debugging aid""" if fp is None: diff --git a/Lib/email/mime/base.py b/Lib/email/mime/base.py index 8eb7e5db5cc1c6..1a3f9b51f6c045 100644 --- a/Lib/email/mime/base.py +++ b/Lib/email/mime/base.py @@ -11,7 +11,7 @@ from email import message - + class MIMEBase(message.Message): """Base class for MIME specializations.""" diff --git a/Lib/email/mime/message.py b/Lib/email/mime/message.py index ce50af26b24497..07e4f2d1196151 100644 --- a/Lib/email/mime/message.py +++ b/Lib/email/mime/message.py @@ -10,7 +10,7 @@ from email.mime.nonmultipart import MIMENonMultipart - + class MIMEMessage(MIMENonMultipart): """Class representing message/* MIME documents.""" diff --git a/Lib/email/mime/multipart.py b/Lib/email/mime/multipart.py index 93b5d27bfcdb3c..2d3f288810dd91 100644 --- a/Lib/email/mime/multipart.py +++ b/Lib/email/mime/multipart.py @@ -9,7 +9,7 @@ from email.mime.base import MIMEBase - + class MIMEMultipart(MIMEBase): """Base class for MIME multipart/* type messages.""" diff --git a/Lib/email/mime/nonmultipart.py b/Lib/email/mime/nonmultipart.py index 991a97d80d822e..e1f51968b59eb1 100644 --- a/Lib/email/mime/nonmultipart.py +++ b/Lib/email/mime/nonmultipart.py @@ -10,7 +10,7 @@ from email.mime.base import MIMEBase - + class MIMENonMultipart(MIMEBase): """Base class for MIME non-multipart type messages.""" diff --git a/Lib/email/mime/text.py b/Lib/email/mime/text.py index b6b394e49a060e..35b442383002b2 100644 --- a/Lib/email/mime/text.py +++ b/Lib/email/mime/text.py @@ -10,7 +10,7 @@ from email.mime.nonmultipart import MIMENonMultipart - + class MIMEText(MIMENonMultipart): """Class for generating text/* type MIME documents.""" diff --git a/Lib/email/parser.py b/Lib/email/parser.py index 13d7816032a500..7db4da1ff081c1 100644 --- a/Lib/email/parser.py +++ b/Lib/email/parser.py @@ -67,7 +67,7 @@ def parsestr(self, text, headersonly=False): return self.parse(StringIO(text), headersonly=headersonly) - + class HeaderParser(Parser): def parse(self, fp, headersonly=True): return Parser.parse(self, fp, True) @@ -75,7 +75,7 @@ def parse(self, fp, headersonly=True): def parsestr(self, text, headersonly=True): return Parser.parsestr(self, text, True) - + class BytesParser: def __init__(self, *args, **kw): diff --git a/Lib/test/test_asyncio/test_runners.py b/Lib/test/test_asyncio/test_runners.py index ae823cc7bec33e..8a4aba6d470bac 100644 --- a/Lib/test/test_asyncio/test_runners.py +++ b/Lib/test/test_asyncio/test_runners.py @@ -441,7 +441,7 @@ async def coro(): 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() diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py index e7508d9b1d5d19..a0974640bc1146 100644 --- a/Lib/test/test_isinstance.py +++ b/Lib/test/test_isinstance.py @@ -8,7 +8,7 @@ from test import support - + 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 @@ -97,7 +97,7 @@ def getclass(self): class D: pass self.assertRaises(RuntimeError, isinstance, c, D) - + # These tests are similar to above, but tickle certain code paths in # issubclass() instead of isinstance() -- really PyObject_IsSubclass() # vs. PyObject_IsInstance(). @@ -147,7 +147,7 @@ def getbases(self): self.assertRaises(TypeError, issubclass, B, C()) - + # meta classes for creating abstract classes and instances class AbstractClass(object): def __init__(self, bases): @@ -179,7 +179,7 @@ class Super: class Child(Super): pass - + class TestIsInstanceIsSubclass(unittest.TestCase): # Tests to ensure that isinstance and issubclass work on abstract # classes and instances. Before the 2.2 release, TypeErrors were @@ -357,6 +357,6 @@ def blowstack(fxn, arg, compare_to): tuple_arg = (tuple_arg,) fxn(arg, tuple_arg) - + if __name__ == '__main__': unittest.main() diff --git a/Modules/_blake2/blake2module.h b/Modules/_blake2/blake2module.h index c8144ec9d48d29..aa8f281178eadc 100644 --- a/Modules/_blake2/blake2module.h +++ b/Modules/_blake2/blake2module.h @@ -38,6 +38,6 @@ #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 diff --git a/Modules/_blake2/impl/blake2b-round.h b/Modules/_blake2/impl/blake2b-round.h index 5b452c4d63babe..cebc22550da4cd 100644 --- a/Modules/_blake2/impl/blake2b-round.h +++ b/Modules/_blake2/impl/blake2b-round.h @@ -62,7 +62,7 @@ \ 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); \ @@ -81,7 +81,7 @@ \ 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); \ diff --git a/Modules/_blake2/impl/blake2s-load-xop.h b/Modules/_blake2/impl/blake2s-load-xop.h index 14d9e7f7640672..ac591a77d191a7 100644 --- a/Modules/_blake2/impl/blake2s-load-xop.h +++ b/Modules/_blake2/impl/blake2s-load-xop.h @@ -166,7 +166,7 @@ buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(3),TOB(2),TOB(1),TOB(7)) ); #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)) ); diff --git a/Modules/_blake2/impl/blake2s-round.h b/Modules/_blake2/impl/blake2s-round.h index 3af4be35bee5d4..1e2f2b7f59bd6c 100644 --- a/Modules/_blake2/impl/blake2s-round.h +++ b/Modules/_blake2/impl/blake2s-round.h @@ -86,6 +86,6 @@ LOAD_MSG_ ##r ##_4(buf4); \ G2(row1,row2,row3,row4,buf4); \ UNDIAGONALIZE(row1,row2,row3,row4); \ - + #endif diff --git a/Modules/_ctypes/darwin/dlfcn.h b/Modules/_ctypes/darwin/dlfcn.h index a9915c3115ceb6..a2afc3eeb84794 100644 --- a/Modules/_ctypes/darwin/dlfcn.h +++ b/Modules/_ctypes/darwin/dlfcn.h @@ -1,7 +1,7 @@ /* Copyright (c) 2002 Jorge Acereda & Peter O'Gorman - + Portions may be copyright others, see the AUTHORS file included with this distribution. diff --git a/Modules/_ctypes/libffi_osx/ffi.c b/Modules/_ctypes/libffi_osx/ffi.c index e16423aef19fc0..1776b795e2f83d 100644 --- a/Modules/_ctypes/libffi_osx/ffi.c +++ b/Modules/_ctypes/libffi_osx/ffi.c @@ -65,12 +65,12 @@ initialize_aggregate( 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 @@ -130,10 +130,10 @@ struct_on_stack( // 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; @@ -184,7 +184,7 @@ ffi_prep_cif( 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); diff --git a/Modules/_ctypes/libffi_osx/include/ffi.h b/Modules/_ctypes/libffi_osx/include/ffi.h index 88c58fc43deb6b..c104a5c89350b6 100644 --- a/Modules/_ctypes/libffi_osx/include/ffi.h +++ b/Modules/_ctypes/libffi_osx/include/ffi.h @@ -199,9 +199,9 @@ typedef union { 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 @@ -225,9 +225,9 @@ ffi_raw_size( 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 @@ -272,8 +272,8 @@ typedef struct ffi_raw_closure { 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; @@ -303,17 +303,17 @@ ffi_prep_java_raw_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 */ diff --git a/Modules/_ctypes/libffi_osx/include/ffi_common.h b/Modules/_ctypes/libffi_osx/include/ffi_common.h index 02b53c8600e012..685a3580f4fe05 100644 --- a/Modules/_ctypes/libffi_osx/include/ffi_common.h +++ b/Modules/_ctypes/libffi_osx/include/ffi_common.h @@ -41,7 +41,7 @@ char* alloca(); # endif #endif -/*#if defined(FFI_DEBUG) +/*#if defined(FFI_DEBUG) #include #endif*/ @@ -65,7 +65,7 @@ ffi_type_test( # 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 diff --git a/Modules/_ctypes/libffi_osx/include/fficonfig.h b/Modules/_ctypes/libffi_osx/include/fficonfig.h index dc0f4ecb26ee0b..217249071dcf48 100644 --- a/Modules/_ctypes/libffi_osx/include/fficonfig.h +++ b/Modules/_ctypes/libffi_osx/include/fficonfig.h @@ -1,4 +1,4 @@ -/* 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. @@ -33,10 +33,10 @@ # 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__) diff --git a/Modules/_ctypes/libffi_osx/include/x86-ffitarget.h b/Modules/_ctypes/libffi_osx/include/x86-ffitarget.h index df149eb14d78c7..55c2b6c50cd90c 100644 --- a/Modules/_ctypes/libffi_osx/include/x86-ffitarget.h +++ b/Modules/_ctypes/libffi_osx/include/x86-ffitarget.h @@ -33,7 +33,7 @@ # define X86 #endif -#if defined(__x86_64__) +#if defined(__x86_64__) # ifndef X86_64 # define X86_64 # endif diff --git a/Modules/_ctypes/libffi_osx/powerpc/ppc-ffi_darwin.c b/Modules/_ctypes/libffi_osx/powerpc/ppc-ffi_darwin.c index 875412a6766957..8953d5fda35818 100644 --- a/Modules/_ctypes/libffi_osx/powerpc/ppc-ffi_darwin.c +++ b/Modules/_ctypes/libffi_osx/powerpc/ppc-ffi_darwin.c @@ -891,7 +891,7 @@ ffi_closure_helper_DARWIN( 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); @@ -1479,7 +1479,7 @@ ffi64_struct_to_reg_form( memcpy(&outGPRs[destGMarker], &inStruct[srcMarker], inType->size); } - + srcMarker += inType->size; destGMarker += inType->size; i += inType->size - 1; @@ -1561,7 +1561,7 @@ ffi64_struct_to_reg_form( 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; diff --git a/Modules/_ctypes/libffi_osx/types.c b/Modules/_ctypes/libffi_osx/types.c index 761d223ff1498c..44806aeeb75d37 100644 --- a/Modules/_ctypes/libffi_osx/types.c +++ b/Modules/_ctypes/libffi_osx/types.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- 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 @@ -85,7 +85,7 @@ FFI_INTEGRAL_TYPEDEF(sint64, 8, 8, FFI_TYPE_SINT64); 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 diff --git a/Modules/_ctypes/libffi_osx/x86/x86-ffi64.c b/Modules/_ctypes/libffi_osx/x86/x86-ffi64.c index b8ae6e80231ece..8e7d016488029f 100644 --- a/Modules/_ctypes/libffi_osx/x86/x86-ffi64.c +++ b/Modules/_ctypes/libffi_osx/x86/x86-ffi64.c @@ -2,8 +2,8 @@ /* ----------------------------------------------------------------------- x86-ffi64.c - Copyright (c) 2002 Bo Thorsen - - 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 @@ -208,7 +208,7 @@ classify_argument( 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; diff --git a/Modules/_ctypes/libffi_osx/x86/x86-ffi_darwin.c b/Modules/_ctypes/libffi_osx/x86/x86-ffi_darwin.c index 59e36158067394..706ea0f51206dc 100644 --- a/Modules/_ctypes/libffi_osx/x86/x86-ffi_darwin.c +++ b/Modules/_ctypes/libffi_osx/x86/x86-ffi_darwin.c @@ -4,8 +4,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 @@ -43,27 +43,27 @@ void ffi_prep_args(char *stack, extended_cif *ecif) 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)) { @@ -73,31 +73,31 @@ void ffi_prep_args(char *stack, extended_cif *ecif) 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); } @@ -109,7 +109,7 @@ void ffi_prep_args(char *stack, extended_cif *ecif) p_argv++; argp += z; } - + return; } @@ -127,18 +127,18 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif) 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) @@ -163,16 +163,16 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif) } break; #endif - + default: cif->flags = FFI_TYPE_INT; break; } - + #ifdef X86_DARWIN cif->bytes = (cif->bytes + 15) & ~0xF; #endif - + return FFI_OK; } @@ -188,23 +188,23 @@ extern void ffi_call_STDCALL(void (*)(char *, extended_cif *), extended_cif *, 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, @@ -245,20 +245,20 @@ void *args; // 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; } @@ -270,35 +270,35 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue, 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; } @@ -325,15 +325,15 @@ ffi_prep_closure (ffi_closure* closure, { 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; } @@ -349,32 +349,32 @@ ffi_prep_raw_closure_loc (ffi_raw_closure* closure, 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); @@ -386,7 +386,7 @@ ffi_prep_args_raw(char *stack, extended_cif *ecif) */ 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 @@ -400,23 +400,23 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(), void *rvalue, ffi_raw *fake_avalue) { 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, diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index aa877174417cdd..a7b2e984310d18 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -59,7 +59,7 @@ PyDoc_STRVAR(module_doc, " I/O classes. open() uses the file's blksize (as obtained by os.stat) if\n" " possible.\n" ); - + /* * The main open() function @@ -512,7 +512,7 @@ _io_open_code_impl(PyObject *module, PyObject *path) { return PyFile_OpenCodeObject(path); } - + /* * Private helpers for the io module. */ diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 4b94ed42dcf4b6..4a4a1992dbbb7a 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -1740,7 +1740,7 @@ _bufferedreader_peek_unlocked(buffered *self) self->pos = 0; return PyBytes_FromStringAndSize(self->buffer, r); } - + /* @@ -2047,7 +2047,7 @@ _io_BufferedWriter_write_impl(buffered *self, Py_buffer *buffer) LEAVE_BUFFERED(self) return res; } - + /* @@ -2253,7 +2253,7 @@ bufferedrwpair_closed_get(rwpair *self, void *context) } return PyObject_GetAttr((PyObject *) self->writer, &_Py_ID(closed)); } - + /* diff --git a/Modules/termios.c b/Modules/termios.c index 3900a6f0b89860..fcc8f042679870 100644 --- a/Modules/termios.c +++ b/Modules/termios.c @@ -85,7 +85,7 @@ termios_tcgetattr_impl(PyObject *module, int fd) 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); @@ -372,7 +372,7 @@ termios_tcgetwinsize_impl(PyObject *module, int fd) #if defined(TIOCGWINSZ) termiosmodulestate *state = PyModule_GetState(module); struct winsize w; - int r; + int r; Py_BEGIN_ALLOW_THREADS r = ioctl(fd, TIOCGWINSZ, &w); diff --git a/PC/winreg.c b/PC/winreg.c index 940278194f4cf5..f668cf3c19cab5 100644 --- a/PC/winreg.c +++ b/PC/winreg.c @@ -564,7 +564,7 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) { Py_ssize_t i,j; switch (typ) { - case REG_DWORD: + case REG_DWORD: { if (value != Py_None && !PyLong_Check(value)) { return FALSE; @@ -588,7 +588,7 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) *retDataSize = sizeof(DWORD); break; } - case REG_QWORD: + case REG_QWORD: { if (value != Py_None && !PyLong_Check(value)) { return FALSE; diff --git a/Tools/i18n/pygettext.py b/Tools/i18n/pygettext.py index f38b8569328900..7ada79105db1ca 100755 --- a/Tools/i18n/pygettext.py +++ b/Tools/i18n/pygettext.py @@ -174,7 +174,7 @@ EMPTYSTRING = '' - + # The normal pot-file header. msgmerge and Emacs's po-mode work better if it's # there. pot_header = _('''\ @@ -196,7 +196,7 @@ ''') - + def usage(code, msg=''): print(__doc__ % globals(), file=sys.stderr) if msg: @@ -204,7 +204,7 @@ def usage(code, msg=''): sys.exit(code) - + def make_escapes(pass_nonascii): global escapes, escape if pass_nonascii: @@ -258,7 +258,7 @@ def normalize(s, encoding): s = '""\n"' + lineterm.join(lines) + '"' return s - + def containsAny(str, set): """Check whether 'str' contains ANY of the chars in 'set'""" return 1 in [c in str for c in set] @@ -307,7 +307,7 @@ def getFilesForName(name): return [] - + class TokenEater: def __init__(self, options): self.__options = options @@ -515,7 +515,7 @@ def write(self, fp): print('msgstr ""\n', file=fp) - + def main(): global default_keywords try: @@ -675,7 +675,7 @@ class Options: if closep: fp.close() - + if __name__ == '__main__': main() # some more test strings diff --git a/Tools/msi/bundle/bootstrap/pch.h b/Tools/msi/bundle/bootstrap/pch.h index 6d0974b34c61e7..b0aa5111dabd0d 100644 --- a/Tools/msi/bundle/bootstrap/pch.h +++ b/Tools/msi/bundle/bootstrap/pch.h @@ -5,7 +5,7 @@ // The license and further copyright text can be found in the file // LICENSE.TXT at the root directory of the distribution. // -// +// // // Precompiled header for standard bootstrapper application. // diff --git a/Tools/msi/bundle/bootstrap/resource.h b/Tools/msi/bundle/bootstrap/resource.h index d951e651f6d20d..53c03c319f091f 100644 --- a/Tools/msi/bundle/bootstrap/resource.h +++ b/Tools/msi/bundle/bootstrap/resource.h @@ -14,7 +14,7 @@ // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 102 From 7cbfc5f1a79c762a36469b890c6325466fd826a6 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 22 Aug 2023 11:56:49 +0300 Subject: [PATCH 6/7] Trim the trailing whitespace --- Lib/test/test_asyncio/test_runners.py | 2 +- Lib/test/test_isinstance.py | 10 +- Modules/_blake2/blake2module.h | 2 +- Modules/_blake2/impl/blake2b-round.h | 4 +- Modules/_blake2/impl/blake2s-load-xop.h | 2 +- Modules/_blake2/impl/blake2s-round.h | 2 +- Modules/_ctypes/darwin/dlfcn.h | 2 +- Modules/_ctypes/libffi_osx/ffi.c | 12 +- Modules/_ctypes/libffi_osx/include/ffi.h | 28 ++-- .../_ctypes/libffi_osx/include/ffi_common.h | 4 +- .../_ctypes/libffi_osx/include/fficonfig.h | 6 +- .../libffi_osx/include/x86-ffitarget.h | 2 +- .../libffi_osx/powerpc/ppc-ffi_darwin.c | 6 +- Modules/_ctypes/libffi_osx/types.c | 4 +- Modules/_ctypes/libffi_osx/x86/x86-ffi64.c | 6 +- .../_ctypes/libffi_osx/x86/x86-ffi_darwin.c | 130 +++++++++--------- Modules/_io/_iomodule.c | 4 +- Modules/termios.c | 4 +- PC/winreg.c | 4 +- Tools/msi/bundle/bootstrap/pch.h | 2 +- Tools/msi/bundle/bootstrap/resource.h | 2 +- 21 files changed, 119 insertions(+), 119 deletions(-) diff --git a/Lib/test/test_asyncio/test_runners.py b/Lib/test/test_asyncio/test_runners.py index 8a4aba6d470bac..ae823cc7bec33e 100644 --- a/Lib/test/test_asyncio/test_runners.py +++ b/Lib/test/test_asyncio/test_runners.py @@ -441,7 +441,7 @@ async def coro(): 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() diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py index a0974640bc1146..e7508d9b1d5d19 100644 --- a/Lib/test/test_isinstance.py +++ b/Lib/test/test_isinstance.py @@ -8,7 +8,7 @@ from test import support - + 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 @@ -97,7 +97,7 @@ def getclass(self): class D: pass self.assertRaises(RuntimeError, isinstance, c, D) - + # These tests are similar to above, but tickle certain code paths in # issubclass() instead of isinstance() -- really PyObject_IsSubclass() # vs. PyObject_IsInstance(). @@ -147,7 +147,7 @@ def getbases(self): self.assertRaises(TypeError, issubclass, B, C()) - + # meta classes for creating abstract classes and instances class AbstractClass(object): def __init__(self, bases): @@ -179,7 +179,7 @@ class Super: class Child(Super): pass - + class TestIsInstanceIsSubclass(unittest.TestCase): # Tests to ensure that isinstance and issubclass work on abstract # classes and instances. Before the 2.2 release, TypeErrors were @@ -357,6 +357,6 @@ def blowstack(fxn, arg, compare_to): tuple_arg = (tuple_arg,) fxn(arg, tuple_arg) - + if __name__ == '__main__': unittest.main() diff --git a/Modules/_blake2/blake2module.h b/Modules/_blake2/blake2module.h index aa8f281178eadc..c8144ec9d48d29 100644 --- a/Modules/_blake2/blake2module.h +++ b/Modules/_blake2/blake2module.h @@ -38,6 +38,6 @@ #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 diff --git a/Modules/_blake2/impl/blake2b-round.h b/Modules/_blake2/impl/blake2b-round.h index cebc22550da4cd..5b452c4d63babe 100644 --- a/Modules/_blake2/impl/blake2b-round.h +++ b/Modules/_blake2/impl/blake2b-round.h @@ -62,7 +62,7 @@ \ 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); \ @@ -81,7 +81,7 @@ \ 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); \ diff --git a/Modules/_blake2/impl/blake2s-load-xop.h b/Modules/_blake2/impl/blake2s-load-xop.h index ac591a77d191a7..14d9e7f7640672 100644 --- a/Modules/_blake2/impl/blake2s-load-xop.h +++ b/Modules/_blake2/impl/blake2s-load-xop.h @@ -166,7 +166,7 @@ buf = _mm_perm_epi8(t1, m3, _mm_set_epi32(TOB(3),TOB(2),TOB(1),TOB(7)) ); #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)) ); diff --git a/Modules/_blake2/impl/blake2s-round.h b/Modules/_blake2/impl/blake2s-round.h index 1e2f2b7f59bd6c..3af4be35bee5d4 100644 --- a/Modules/_blake2/impl/blake2s-round.h +++ b/Modules/_blake2/impl/blake2s-round.h @@ -86,6 +86,6 @@ LOAD_MSG_ ##r ##_4(buf4); \ G2(row1,row2,row3,row4,buf4); \ UNDIAGONALIZE(row1,row2,row3,row4); \ - + #endif diff --git a/Modules/_ctypes/darwin/dlfcn.h b/Modules/_ctypes/darwin/dlfcn.h index a2afc3eeb84794..a9915c3115ceb6 100644 --- a/Modules/_ctypes/darwin/dlfcn.h +++ b/Modules/_ctypes/darwin/dlfcn.h @@ -1,7 +1,7 @@ /* Copyright (c) 2002 Jorge Acereda & Peter O'Gorman - + Portions may be copyright others, see the AUTHORS file included with this distribution. diff --git a/Modules/_ctypes/libffi_osx/ffi.c b/Modules/_ctypes/libffi_osx/ffi.c index 1776b795e2f83d..e16423aef19fc0 100644 --- a/Modules/_ctypes/libffi_osx/ffi.c +++ b/Modules/_ctypes/libffi_osx/ffi.c @@ -65,12 +65,12 @@ initialize_aggregate( 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 @@ -130,10 +130,10 @@ struct_on_stack( // 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; @@ -184,7 +184,7 @@ ffi_prep_cif( 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); diff --git a/Modules/_ctypes/libffi_osx/include/ffi.h b/Modules/_ctypes/libffi_osx/include/ffi.h index c104a5c89350b6..88c58fc43deb6b 100644 --- a/Modules/_ctypes/libffi_osx/include/ffi.h +++ b/Modules/_ctypes/libffi_osx/include/ffi.h @@ -199,9 +199,9 @@ typedef union { 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 @@ -225,9 +225,9 @@ ffi_raw_size( 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 @@ -272,8 +272,8 @@ typedef struct ffi_raw_closure { 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; @@ -303,17 +303,17 @@ ffi_prep_java_raw_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 */ diff --git a/Modules/_ctypes/libffi_osx/include/ffi_common.h b/Modules/_ctypes/libffi_osx/include/ffi_common.h index 685a3580f4fe05..02b53c8600e012 100644 --- a/Modules/_ctypes/libffi_osx/include/ffi_common.h +++ b/Modules/_ctypes/libffi_osx/include/ffi_common.h @@ -41,7 +41,7 @@ char* alloca(); # endif #endif -/*#if defined(FFI_DEBUG) +/*#if defined(FFI_DEBUG) #include #endif*/ @@ -65,7 +65,7 @@ ffi_type_test( # 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 diff --git a/Modules/_ctypes/libffi_osx/include/fficonfig.h b/Modules/_ctypes/libffi_osx/include/fficonfig.h index 217249071dcf48..dc0f4ecb26ee0b 100644 --- a/Modules/_ctypes/libffi_osx/include/fficonfig.h +++ b/Modules/_ctypes/libffi_osx/include/fficonfig.h @@ -1,4 +1,4 @@ -/* 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. @@ -33,10 +33,10 @@ # 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__) diff --git a/Modules/_ctypes/libffi_osx/include/x86-ffitarget.h b/Modules/_ctypes/libffi_osx/include/x86-ffitarget.h index 55c2b6c50cd90c..df149eb14d78c7 100644 --- a/Modules/_ctypes/libffi_osx/include/x86-ffitarget.h +++ b/Modules/_ctypes/libffi_osx/include/x86-ffitarget.h @@ -33,7 +33,7 @@ # define X86 #endif -#if defined(__x86_64__) +#if defined(__x86_64__) # ifndef X86_64 # define X86_64 # endif diff --git a/Modules/_ctypes/libffi_osx/powerpc/ppc-ffi_darwin.c b/Modules/_ctypes/libffi_osx/powerpc/ppc-ffi_darwin.c index 8953d5fda35818..875412a6766957 100644 --- a/Modules/_ctypes/libffi_osx/powerpc/ppc-ffi_darwin.c +++ b/Modules/_ctypes/libffi_osx/powerpc/ppc-ffi_darwin.c @@ -891,7 +891,7 @@ ffi_closure_helper_DARWIN( 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); @@ -1479,7 +1479,7 @@ ffi64_struct_to_reg_form( memcpy(&outGPRs[destGMarker], &inStruct[srcMarker], inType->size); } - + srcMarker += inType->size; destGMarker += inType->size; i += inType->size - 1; @@ -1561,7 +1561,7 @@ ffi64_struct_to_reg_form( 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; diff --git a/Modules/_ctypes/libffi_osx/types.c b/Modules/_ctypes/libffi_osx/types.c index 44806aeeb75d37..761d223ff1498c 100644 --- a/Modules/_ctypes/libffi_osx/types.c +++ b/Modules/_ctypes/libffi_osx/types.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- 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 @@ -85,7 +85,7 @@ FFI_INTEGRAL_TYPEDEF(sint64, 8, 8, FFI_TYPE_SINT64); 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 diff --git a/Modules/_ctypes/libffi_osx/x86/x86-ffi64.c b/Modules/_ctypes/libffi_osx/x86/x86-ffi64.c index 8e7d016488029f..b8ae6e80231ece 100644 --- a/Modules/_ctypes/libffi_osx/x86/x86-ffi64.c +++ b/Modules/_ctypes/libffi_osx/x86/x86-ffi64.c @@ -2,8 +2,8 @@ /* ----------------------------------------------------------------------- x86-ffi64.c - Copyright (c) 2002 Bo Thorsen - - 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 @@ -208,7 +208,7 @@ classify_argument( 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; diff --git a/Modules/_ctypes/libffi_osx/x86/x86-ffi_darwin.c b/Modules/_ctypes/libffi_osx/x86/x86-ffi_darwin.c index 706ea0f51206dc..59e36158067394 100644 --- a/Modules/_ctypes/libffi_osx/x86/x86-ffi_darwin.c +++ b/Modules/_ctypes/libffi_osx/x86/x86-ffi_darwin.c @@ -4,8 +4,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 @@ -43,27 +43,27 @@ void ffi_prep_args(char *stack, extended_cif *ecif) 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)) { @@ -73,31 +73,31 @@ void ffi_prep_args(char *stack, extended_cif *ecif) 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); } @@ -109,7 +109,7 @@ void ffi_prep_args(char *stack, extended_cif *ecif) p_argv++; argp += z; } - + return; } @@ -127,18 +127,18 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif) 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) @@ -163,16 +163,16 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif) } break; #endif - + default: cif->flags = FFI_TYPE_INT; break; } - + #ifdef X86_DARWIN cif->bytes = (cif->bytes + 15) & ~0xF; #endif - + return FFI_OK; } @@ -188,23 +188,23 @@ extern void ffi_call_STDCALL(void (*)(char *, extended_cif *), extended_cif *, 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, @@ -245,20 +245,20 @@ void *args; // 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; } @@ -270,35 +270,35 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue, 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; } @@ -325,15 +325,15 @@ ffi_prep_closure (ffi_closure* closure, { 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; } @@ -349,32 +349,32 @@ ffi_prep_raw_closure_loc (ffi_raw_closure* closure, 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); @@ -386,7 +386,7 @@ ffi_prep_args_raw(char *stack, extended_cif *ecif) */ 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 @@ -400,23 +400,23 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(), void *rvalue, ffi_raw *fake_avalue) { 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, diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index a7b2e984310d18..aa877174417cdd 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -59,7 +59,7 @@ PyDoc_STRVAR(module_doc, " I/O classes. open() uses the file's blksize (as obtained by os.stat) if\n" " possible.\n" ); - + /* * The main open() function @@ -512,7 +512,7 @@ _io_open_code_impl(PyObject *module, PyObject *path) { return PyFile_OpenCodeObject(path); } - + /* * Private helpers for the io module. */ diff --git a/Modules/termios.c b/Modules/termios.c index fcc8f042679870..3900a6f0b89860 100644 --- a/Modules/termios.c +++ b/Modules/termios.c @@ -85,7 +85,7 @@ termios_tcgetattr_impl(PyObject *module, int fd) 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); @@ -372,7 +372,7 @@ termios_tcgetwinsize_impl(PyObject *module, int fd) #if defined(TIOCGWINSZ) termiosmodulestate *state = PyModule_GetState(module); struct winsize w; - int r; + int r; Py_BEGIN_ALLOW_THREADS r = ioctl(fd, TIOCGWINSZ, &w); diff --git a/PC/winreg.c b/PC/winreg.c index f668cf3c19cab5..940278194f4cf5 100644 --- a/PC/winreg.c +++ b/PC/winreg.c @@ -564,7 +564,7 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) { Py_ssize_t i,j; switch (typ) { - case REG_DWORD: + case REG_DWORD: { if (value != Py_None && !PyLong_Check(value)) { return FALSE; @@ -588,7 +588,7 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) *retDataSize = sizeof(DWORD); break; } - case REG_QWORD: + case REG_QWORD: { if (value != Py_None && !PyLong_Check(value)) { return FALSE; diff --git a/Tools/msi/bundle/bootstrap/pch.h b/Tools/msi/bundle/bootstrap/pch.h index b0aa5111dabd0d..6d0974b34c61e7 100644 --- a/Tools/msi/bundle/bootstrap/pch.h +++ b/Tools/msi/bundle/bootstrap/pch.h @@ -5,7 +5,7 @@ // The license and further copyright text can be found in the file // LICENSE.TXT at the root directory of the distribution. // -// +// // // Precompiled header for standard bootstrapper application. // diff --git a/Tools/msi/bundle/bootstrap/resource.h b/Tools/msi/bundle/bootstrap/resource.h index 53c03c319f091f..d951e651f6d20d 100644 --- a/Tools/msi/bundle/bootstrap/resource.h +++ b/Tools/msi/bundle/bootstrap/resource.h @@ -14,7 +14,7 @@ // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 102 From b0f574bcebcc3469397842249dd0eee40444765b Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 22 Aug 2023 11:58:24 +0300 Subject: [PATCH 7/7] Apply suggestions from code review Co-authored-by: Alex Waygood --- Lib/test/test_isinstance.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py index e7508d9b1d5d19..a8315a4a9123d9 100644 --- a/Lib/test/test_isinstance.py +++ b/Lib/test/test_isinstance.py @@ -8,7 +8,6 @@ from test import support - 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 @@ -147,7 +146,6 @@ def getbases(self): self.assertRaises(TypeError, issubclass, B, C()) - # meta classes for creating abstract classes and instances class AbstractClass(object): def __init__(self, bases):