Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Doc/tools/removed-ids.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ deprecations/index.html: pending-removal-in-python-3-16
deprecations/index.html: c-api-pending-removal-in-python-3-15
deprecations/index.html: c-api-pending-removal-in-python-3-16

tutorial/modules.html: packages-in-multiple-directories

# Removed libmpdec
using/configure.html: cmdoption-with-system-libmpdec

Expand Down
14 changes: 0 additions & 14 deletions Doc/tutorial/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -584,20 +584,6 @@ Since the main module does not have a package, modules intended for use
as the main module of a Python application must always use absolute imports.


Packages in Multiple Directories
--------------------------------

Packages support one more special attribute, :attr:`~module.__path__`. This is
initialized to be a :term:`sequence` of strings containing the name of the
directory holding the
package's :file:`__init__.py` before the code in that file is executed. This
variable can be modified; doing so affects future searches for modules and
subpackages contained in the package.

While this feature is not often needed, it can be used to extend the set of
modules found in a package.


.. rubric:: Footnotes

.. [#] In fact function definitions are also 'statements' that are 'executed'; the
Expand Down
22 changes: 22 additions & 0 deletions Lib/test/test_re.py
Original file line number Diff line number Diff line change
Expand Up @@ -2145,6 +2145,28 @@ def test_locale_flag(self):
self.assertRaises(ValueError, re.compile, b'(?a)', re.LOCALE)
self.assertRaises(re.PatternError, re.compile, b'(?aL)')

def test_locale_ignorecase_negated_set(self):
IL = re.LOCALE | re.IGNORECASE
# [bc] matches b'B', so [^bc] must not.
self.assertTrue(re.fullmatch(rb'[bc]', b'B', IL))
self.assertIsNone(re.fullmatch(rb'[^bc]', b'B', IL))
self.assertIsNone(re.fullmatch(rb'[^b-c]', b'C', IL))
self.assertIsNone(re.fullmatch(rb'[^bc]', b'c', IL))
self.assertTrue(re.fullmatch(rb'[^bc]', b'a', IL))
# A one-member set compiles to NOT_LITERAL_LOC_IGNORE.
self.assertIsNone(re.fullmatch(rb'[^b]', b'B', IL))
self.assertTrue(re.fullmatch(rb'[^b]', b'a', IL))
self.assertIsNone(re.fullmatch(rb'[^\wq]', b'Q', IL))
# A sparse set compiles to a bitmap instead of ranges.
self.assertTrue(re.fullmatch(rb'[ace]', b'C', IL))
self.assertIsNone(re.fullmatch(rb'[^ace]', b'C', IL))
self.assertTrue(re.fullmatch(rb'[^ace]', b'b', IL))
# An alternation folded into a set puts NEGATE in the middle of it.
self.assertIsNone(re.fullmatch(rb'(?:a|[^bc])', b'B', IL))
self.assertTrue(re.fullmatch(rb'(?:a|[^bc])', b'A', IL))
self.assertIsNone(re.fullmatch(rb'\w(?<!b)', b'B', IL))
self.assertTrue(re.fullmatch(rb'\w(?<!b)', b'A', IL))

def test_scoped_flags(self):
self.assertTrue(re.match(r'(?i:a)b', 'Ab'))
self.assertIsNone(re.match(r'(?i:a)b', 'aB'))
Expand Down
12 changes: 6 additions & 6 deletions Mac/BuildScript/build-installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ def library_recipes():

result.extend([
dict(
name="OpenSSL 3.5.7",
url="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/openssl/openssl/releases/download/openssl-3.5.7/openssl-3.5.7.tar.gz",
checksum="a8c0d28a529ca480f9f36cf5792e2cd21984552a3c8e4aa11a24aa31aeac98e8",
name="OpenSSL 3.5.8",
url="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/openssl/openssl/releases/download/openssl-3.5.8/openssl-3.5.8.tar.gz",
checksum="a8f84a39918ec6415ce765d9b429d313ba97b8143169c172e734b9514464f5b2",
buildrecipe=build_universal_openssl,
configure=None,
install=None,
Expand Down Expand Up @@ -359,9 +359,9 @@ def library_recipes():
),
),
dict(
name="SQLite 3.53.3",
url="https://www.sqlite.org/2026/sqlite-autoconf-3530300.tar.gz",
checksum="c917d7db16648ec95f714974ace5e5dcf46b7dc70e26600a0a102a3141125db0",
name="SQLite 3.53.4",
url="https://www.sqlite.org/2026/sqlite-autoconf-3530400.tar.gz",
checksum="0e9483900e92cd5de8fd48d16bf9200145a61f7fd5be542a5ac81d8a9516eb9c",
extra_cflags=('-Os '
'-DSQLITE_ENABLE_FTS5 '
'-DSQLITE_ENABLE_FTS4 '
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix matching of a negated character set in a bytes pattern compiled with both
:const:`re.IGNORECASE` and :const:`re.LOCALE`. The case closure is now applied
to the members of the set, so that ``[^bc]`` no longer matches ``b'B'``.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update macOS installer to use OpenSSL 3.5.8.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update macOS installer builds to SQLite 3.53.4.
63 changes: 59 additions & 4 deletions Modules/_sre/sre_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,71 @@ SRE(charset)(SRE_STATE* state, const SRE_CODE* set, SRE_CODE ch)
}
}

/* Like SRE(charset), but matches both locale cases of ch against every set
member. Testing the whole set once per case would complement it before
closing it under case instead of after, so that [^bc] matched b'B'.
BIGCHARSET and RANGE_UNI_IGNORE are not handled: they never occur in a
set of a bytes pattern. */
LOCAL(int)
SRE(charset_loc_ignore)(SRE_STATE* state, const SRE_CODE* set, SRE_CODE ch)
{
SRE_CODE lo, up;
lo = sre_lower_locale(ch);
if (SRE(charset)(state, set, lo))
return 1;
int ok = 1;

lo = sre_lower_locale(ch);
up = sre_upper_locale(ch);
return up != lo && SRE(charset)(state, set, up);
if (up == lo)
return SRE(charset)(state, set, lo);

for (;;) {
switch (*set++) {

case SRE_OP_FAILURE:
return !ok;

case SRE_OP_LITERAL:
/* <LITERAL> <code> */
if (lo == set[0] || up == set[0])
return ok;
set++;
break;

case SRE_OP_CATEGORY:
/* <CATEGORY> <code> */
if (sre_category(set[0], (int) lo) ||
sre_category(set[0], (int) up))
return ok;
set++;
break;

case SRE_OP_CHARSET:
/* <CHARSET> <bitmap> */
if ((lo < 256 && (set[lo/SRE_CODE_BITS]
& (1u << (lo & (SRE_CODE_BITS-1))))) ||
(up < 256 && (set[up/SRE_CODE_BITS]
& (1u << (up & (SRE_CODE_BITS-1))))))
return ok;
set += 256/SRE_CODE_BITS;
break;

case SRE_OP_RANGE:
/* <RANGE> <lower> <upper> */
if ((set[0] <= lo && lo <= set[1]) ||
(set[0] <= up && up <= set[1]))
return ok;
set += 2;
break;

case SRE_OP_NEGATE:
ok = !ok;
break;

default:
/* internal error -- there's not much we can do about it
here, so let's just pretend it didn't match... */
return 0;
}
}
}

LOCAL(Py_ssize_t) SRE(match)(SRE_STATE* state, const SRE_CODE* pattern, int toplevel);
Expand Down
Loading