diff --git a/Doc/tools/removed-ids.txt b/Doc/tools/removed-ids.txt index 3801e6d31199d69..059cbb9a8465496 100644 --- a/Doc/tools/removed-ids.txt +++ b/Doc/tools/removed-ids.txt @@ -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 diff --git a/Doc/tutorial/modules.rst b/Doc/tutorial/modules.rst index f8105cd5441fec2..46a226be606aeba 100644 --- a/Doc/tutorial/modules.rst +++ b/Doc/tutorial/modules.rst @@ -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 diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index d086fd521e73b59..ff106c1b3415668 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -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(? */ + if (lo == set[0] || up == set[0]) + return ok; + set++; + break; + + case SRE_OP_CATEGORY: + /* */ + if (sre_category(set[0], (int) lo) || + sre_category(set[0], (int) up)) + return ok; + set++; + break; + + case SRE_OP_CHARSET: + /* */ + 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: + /* */ + 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);