mirror of https://github.com/python/cpython.git
Compare commits
4 Commits
edf744990e
...
51c68cf466
Author | SHA1 | Date |
---|---|---|
Gregory P. Smith | 51c68cf466 | |
Miss Islington (bot) | bf76d9bd4d | |
Miss Islington (bot) | 72d356e358 | |
Erlend E. Aasland | eac1a63cdb |
|
@ -362,9 +362,9 @@ The :mod:`signal` module defines the following functions:
|
|||
|
||||
.. function:: strsignal(signalnum)
|
||||
|
||||
Return the system description of the signal *signalnum*, such as
|
||||
"Interrupt", "Segmentation fault", etc. Returns :const:`None` if the signal
|
||||
is not recognized.
|
||||
Returns the description of signal *signalnum*, such as "Interrupt"
|
||||
for :const:`SIGINT`. Returns :const:`None` if *signalnum* has no
|
||||
description. Raises :exc:`ValueError` if *signalnum* is invalid.
|
||||
|
||||
.. versionadded:: 3.8
|
||||
|
||||
|
|
|
@ -54,6 +54,15 @@ class X(Structure):
|
|||
x.char = b'a\0b\0'
|
||||
self.assertEqual(bytes(x), b'a\x00###')
|
||||
|
||||
def test_gh99275(self):
|
||||
class BrokenStructure(Structure):
|
||||
def __init_subclass__(cls, **kwargs):
|
||||
cls._fields_ = [] # This line will fail, `stgdict` is not ready
|
||||
|
||||
with self.assertRaisesRegex(TypeError,
|
||||
'ctypes state is not initialized'):
|
||||
class Subclass(BrokenStructure): ...
|
||||
|
||||
# __set__ and __get__ should raise a TypeError in case their self
|
||||
# argument is not a ctype instance.
|
||||
def test___set__(self):
|
||||
|
|
|
@ -668,6 +668,24 @@ def test_attributes_bad_port(self):
|
|||
with self.assertRaises(ValueError):
|
||||
p.port
|
||||
|
||||
def test_attributes_bad_scheme(self):
|
||||
"""Check handling of invalid schemes."""
|
||||
for bytes in (False, True):
|
||||
for parse in (urllib.parse.urlsplit, urllib.parse.urlparse):
|
||||
for scheme in (".", "+", "-", "0", "http&", "६http"):
|
||||
with self.subTest(bytes=bytes, parse=parse, scheme=scheme):
|
||||
url = scheme + "://www.example.net"
|
||||
if bytes:
|
||||
if url.isascii():
|
||||
url = url.encode("ascii")
|
||||
else:
|
||||
continue
|
||||
p = parse(url)
|
||||
if bytes:
|
||||
self.assertEqual(p.scheme, b"")
|
||||
else:
|
||||
self.assertEqual(p.scheme, "")
|
||||
|
||||
def test_attributes_without_netloc(self):
|
||||
# This example is straight from RFC 3261. It looks like it
|
||||
# should allow the username, hostname, and port to be filled
|
||||
|
|
|
@ -460,7 +460,7 @@ def urlsplit(url, scheme='', allow_fragments=True):
|
|||
allow_fragments = bool(allow_fragments)
|
||||
netloc = query = fragment = ''
|
||||
i = url.find(':')
|
||||
if i > 0:
|
||||
if i > 0 and url[0].isascii() and url[0].isalpha():
|
||||
for c in url[:i]:
|
||||
if c not in scheme_chars:
|
||||
break
|
||||
|
|
|
@ -2528,12 +2528,12 @@ Python/thread.o: @THREADHEADERS@ $(srcdir)/Python/condvar.h
|
|||
|
||||
MODULE_CMATH_DEPS=$(srcdir)/Modules/_math.h
|
||||
MODULE_MATH_DEPS=$(srcdir)/Modules/_math.h
|
||||
MODULE_PYEXPAT_DEPS=$(LIBEXPAT_HEADERS) @LIBEXPAT_INTERNAL@
|
||||
MODULE_PYEXPAT_DEPS=@LIBEXPAT_INTERNAL@
|
||||
MODULE_UNICODEDATA_DEPS=$(srcdir)/Modules/unicodedata_db.h $(srcdir)/Modules/unicodename_db.h
|
||||
MODULE__BLAKE2_DEPS=$(srcdir)/Modules/_blake2/impl/blake2-config.h $(srcdir)/Modules/_blake2/impl/blake2-impl.h $(srcdir)/Modules/_blake2/impl/blake2.h $(srcdir)/Modules/_blake2/impl/blake2b-load-sse2.h $(srcdir)/Modules/_blake2/impl/blake2b-load-sse41.h $(srcdir)/Modules/_blake2/impl/blake2b-ref.c $(srcdir)/Modules/_blake2/impl/blake2b-round.h $(srcdir)/Modules/_blake2/impl/blake2b.c $(srcdir)/Modules/_blake2/impl/blake2s-load-sse2.h $(srcdir)/Modules/_blake2/impl/blake2s-load-sse41.h $(srcdir)/Modules/_blake2/impl/blake2s-load-xop.h $(srcdir)/Modules/_blake2/impl/blake2s-ref.c $(srcdir)/Modules/_blake2/impl/blake2s-round.h $(srcdir)/Modules/_blake2/impl/blake2s.c $(srcdir)/Modules/_blake2/blake2module.h $(srcdir)/Modules/hashlib.h
|
||||
MODULE__CTYPES_DEPS=$(srcdir)/Modules/_ctypes/ctypes.h
|
||||
MODULE__DECIMAL_DEPS=$(srcdir)/Modules/_decimal/docstrings.h $(LIBMPDEC_HEADERS) @LIBMPDEC_INTERNAL@
|
||||
MODULE__ELEMENTTREE_DEPS=$(srcdir)/Modules/pyexpat.c $(LIBEXPAT_HEADERS) @LIBEXPAT_INTERNAL@
|
||||
MODULE__DECIMAL_DEPS=$(srcdir)/Modules/_decimal/docstrings.h @LIBMPDEC_INTERNAL@
|
||||
MODULE__ELEMENTTREE_DEPS=$(srcdir)/Modules/pyexpat.c @LIBEXPAT_INTERNAL@
|
||||
MODULE__HASHLIB_DEPS=$(srcdir)/Modules/hashlib.h
|
||||
MODULE__IO_DEPS=$(srcdir)/Modules/_io/_iomodule.h
|
||||
MODULE__MD5_DEPS=$(srcdir)/Modules/hashlib.h
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Don't use vendored ``libmpdec`` headers if :option:`--with-system-libmpdec`
|
||||
is passed to :program:`configure`.
|
||||
Don't use vendored ``libexpat`` headers if :option:`--with-system-expat`
|
||||
is passed to :program:`!configure`.
|
|
@ -0,0 +1,2 @@
|
|||
Fix ``SystemError`` in :mod:`ctypes` when exception was not set during
|
||||
``__initsubclass__``.
|
|
@ -0,0 +1,2 @@
|
|||
Fix bug in :func:`urllib.parse.urlparse` that causes URL schemes that begin
|
||||
with a digit, a plus sign, or a minus sign to be parsed incorrectly.
|
|
@ -430,8 +430,11 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
|
|||
}
|
||||
|
||||
stgdict = PyType_stgdict(type);
|
||||
if (!stgdict)
|
||||
if (!stgdict) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"ctypes state is not initialized");
|
||||
return -1;
|
||||
}
|
||||
/* If this structure/union is already marked final we cannot assign
|
||||
_fields_ anymore. */
|
||||
|
||||
|
|
|
@ -205,8 +205,9 @@ PyDoc_STRVAR(signal_strsignal__doc__,
|
|||
"\n"
|
||||
"Return the system description of the given signal.\n"
|
||||
"\n"
|
||||
"The return values can be such as \"Interrupt\", \"Segmentation fault\", etc.\n"
|
||||
"Returns None if the signal is not recognized.");
|
||||
"Returns the description of signal *signalnum*, such as \"Interrupt\"\n"
|
||||
"for :const:`SIGINT`. Returns :const:`None` if *signalnum* has no\n"
|
||||
"description. Raises :exc:`ValueError` if *signalnum* is invalid.");
|
||||
|
||||
#define SIGNAL_STRSIGNAL_METHODDEF \
|
||||
{"strsignal", (PyCFunction)signal_strsignal, METH_O, signal_strsignal__doc__},
|
||||
|
@ -698,4 +699,4 @@ exit:
|
|||
#ifndef SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF
|
||||
#define SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF
|
||||
#endif /* !defined(SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF) */
|
||||
/*[clinic end generated code: output=6ca1b70310eecdba input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=9b3f9f1ae2ac2b94 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -627,13 +627,14 @@ signal.strsignal
|
|||
|
||||
Return the system description of the given signal.
|
||||
|
||||
The return values can be such as "Interrupt", "Segmentation fault", etc.
|
||||
Returns None if the signal is not recognized.
|
||||
Returns the description of signal *signalnum*, such as "Interrupt"
|
||||
for :const:`SIGINT`. Returns :const:`None` if *signalnum* has no
|
||||
description. Raises :exc:`ValueError` if *signalnum* is invalid.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
signal_strsignal_impl(PyObject *module, int signalnum)
|
||||
/*[clinic end generated code: output=44e12e1e3b666261 input=b77914b03f856c74]*/
|
||||
/*[clinic end generated code: output=44e12e1e3b666261 input=238b335847778bc0]*/
|
||||
{
|
||||
const char *res;
|
||||
|
||||
|
|
|
@ -12110,7 +12110,7 @@ else
|
|||
|
||||
LIBEXPAT_CFLAGS="-I\$(srcdir)/Modules/expat"
|
||||
LIBEXPAT_LDFLAGS="-lm \$(LIBEXPAT_A)"
|
||||
LIBEXPAT_INTERNAL="\$(LIBEXPAT_A)"
|
||||
LIBEXPAT_INTERNAL="\$(LIBEXPAT_HEADERS) \$(LIBEXPAT_A)"
|
||||
|
||||
fi
|
||||
|
||||
|
@ -12184,7 +12184,7 @@ else
|
|||
|
||||
LIBMPDEC_CFLAGS="-I\$(srcdir)/Modules/_decimal/libmpdec"
|
||||
LIBMPDEC_LDFLAGS="-lm \$(LIBMPDEC_A)"
|
||||
LIBMPDEC_INTERNAL="\$(LIBMPDEC_A)"
|
||||
LIBMPDEC_INTERNAL="\$(LIBMPDEC_HEADERS) \$(LIBMPDEC_A)"
|
||||
|
||||
if test "x$with_pydebug" = xyes; then :
|
||||
|
||||
|
|
|
@ -3610,7 +3610,7 @@ AS_VAR_IF([with_system_expat], [yes], [
|
|||
], [
|
||||
LIBEXPAT_CFLAGS="-I\$(srcdir)/Modules/expat"
|
||||
LIBEXPAT_LDFLAGS="-lm \$(LIBEXPAT_A)"
|
||||
LIBEXPAT_INTERNAL="\$(LIBEXPAT_A)"
|
||||
LIBEXPAT_INTERNAL="\$(LIBEXPAT_HEADERS) \$(LIBEXPAT_A)"
|
||||
])
|
||||
|
||||
AC_SUBST([LIBEXPAT_CFLAGS])
|
||||
|
@ -3666,7 +3666,7 @@ AS_VAR_IF([with_system_libmpdec], [yes], [
|
|||
], [
|
||||
LIBMPDEC_CFLAGS="-I\$(srcdir)/Modules/_decimal/libmpdec"
|
||||
LIBMPDEC_LDFLAGS="-lm \$(LIBMPDEC_A)"
|
||||
LIBMPDEC_INTERNAL="\$(LIBMPDEC_A)"
|
||||
LIBMPDEC_INTERNAL="\$(LIBMPDEC_HEADERS) \$(LIBMPDEC_A)"
|
||||
|
||||
dnl Disable forced inlining in debug builds, see GH-94847
|
||||
AS_VAR_IF([with_pydebug], [yes], [
|
||||
|
|
Loading…
Reference in New Issue