chunk_id stringlengths 36 36 | source stringclasses 35
values | source_url stringlengths 0 290 | upstream_license stringclasses 1
value | document_id stringlengths 36 36 | chunk_index int64 0 324k | retrieved_at stringclasses 2
values | chunker_version stringclasses 4
values | content_hash stringlengths 15 64 | content stringlengths 50 44.7k | namespace stringclasses 9
values | source_name stringclasses 35
values | raw_text stringlengths 50 44.7k | cleaned_text stringlengths 50 44.7k | tags stringclasses 49
values | collection_name stringclasses 11
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
aa1d9a07-d166-4e5a-b004-0588c832c0ac | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,478 | supabase-export-v2 | b5ea9fa38727ee89 | .. currentmodule:: re
Compilation flags let you modify some aspects of how regular expressions work. Flags are available in the :mod:`re` module under two names, a long name such as
:const:`IGNORECASE` and a short, one-letter form such as :const:`I`. (If you're
familiar with Perl's pattern modifiers, the one-letter for... | trusted_official_docs | CPython Docs | .. currentmodule:: re
Compilation flags let you modify some aspects of how regular expressions work. Flags are available in the :mod:`re` module under two names, a long name such as
:const:`IGNORECASE` and a short, one-letter form such as :const:`I`. (If you're
familiar with Perl's pattern modifiers, the one-letter for... | .. currentmodule:: re
Compilation flags let you modify some aspects of how regular expressions work. Flags are available in the :mod:`re` module under two names, a long name such as
:const:`IGNORECASE` and a short, one-letter form such as :const:`I`. (If you're
familiar with Perl's pattern modifiers, the one-letter for... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ab81f987-cd28-42e7-b14e-c4cabf6d5d85 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,591 | supabase-export-v2 | 58d22f2666185c98 | you can split by; string :meth:`!split` only supports splitting by whitespace or by a fixed string. As you'd expect, there's a module-level :func:`re.split` function, too.
.. method:: .split(string [, maxsplit=0])
:noindex: | trusted_official_docs | CPython Docs | you can split by; string :meth:`!split` only supports splitting by whitespace or by a fixed string. As you'd expect, there's a module-level :func:`re.split` function, too.
.. method:: .split(string [, maxsplit=0])
:noindex: | you can split by; string :meth:`!split` only supports splitting by whitespace or by a fixed string. As you'd expect, there's a module-level :func:`re.split` function, too.
.. method:: .split(string [, maxsplit=0])
:noindex: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
aba69392-82fc-4655-8984-2a77e5dfd986 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,394 | supabase-export-v2 | 5ac8cc93fb09471e | Matching characters -------------------
Most letters and characters will simply match themselves. For example, the
regular expression ``test`` will match the string ``test`` exactly. (You can
enable a case-insensitive mode that would let this RE match ``Test`` or ``TEST``
as well; more about this later.) | trusted_official_docs | CPython Docs | Matching characters -------------------
Most letters and characters will simply match themselves. For example, the
regular expression ``test`` will match the string ``test`` exactly. (You can
enable a case-insensitive mode that would let this RE match ``Test`` or ``TEST``
as well; more about this later.) | Matching characters -------------------
Most letters and characters will simply match themselves. For example, the
regular expression ``test`` will match the string ``test`` exactly. (You can
enable a case-insensitive mode that would let this RE match ``Test`` or ``TEST``
as well; more about this later.) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ac59e7f6-4d8f-41b1-b73c-7dd2fa874b39 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,614 | supabase-export-v2 | 0dd985b01c3f9315 | to group 2 followed by the literal character ``'0'``.) The following substitutions are all equivalent, but use all three variations of the replacement string. ::
>>> p = re.compile('section{ (?P<name> [^}]* ) }', re.VERBOSE)
>>> p.sub(r'subsection{\1}','section{First}')
'subsection{First}'
>>> p.sub(r'subsection{\g<... | trusted_official_docs | CPython Docs | to group 2 followed by the literal character ``'0'``.) The following substitutions are all equivalent, but use all three variations of the replacement string. ::
>>> p = re.compile('section{ (?P<name> [^}]* ) }', re.VERBOSE)
>>> p.sub(r'subsection{\1}','section{First}')
'subsection{First}'
>>> p.sub(r'subsection{\g<... | to group 2 followed by the literal character ``'0'``.) The following substitutions are all equivalent, but use all three variations of the replacement string. ::
>>> p = re.compile('section{ (?P<name> [^}]* ) }', re.VERBOSE)
>>> p.sub(r'subsection{\1}','section{First}')
'subsection{First}'
>>> p.sub(r'subsection{\g<... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ac77f67a-aca6-46a5-83af-a5584fb5c8e0 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,604 | supabase-export-v2 | f0a3447005ca7744 | the maximum number of pattern occurrences to be replaced; *count* must be a non-negative integer. The default value of 0 means to replace all occurrences.
Here's a simple example of using the :meth:`~re.Pattern.sub` method. It replaces colour
names with the word ``colour``:: | trusted_official_docs | CPython Docs | the maximum number of pattern occurrences to be replaced; *count* must be a non-negative integer. The default value of 0 means to replace all occurrences.
Here's a simple example of using the :meth:`~re.Pattern.sub` method. It replaces colour
names with the word ``colour``:: | the maximum number of pattern occurrences to be replaced; *count* must be a non-negative integer. The default value of 0 means to replace all occurrences.
Here's a simple example of using the :meth:`~re.Pattern.sub` method. It replaces colour
names with the word ``colour``:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ad956740-df4c-4150-965b-afab2c79fd85 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,501 | supabase-export-v2 | f89881c8edce5138 | charref = re.compile("&#(0[0-7]+" "|[0-9]+" "|x[0-9a-fA-F]+);")
In the above example, Python's automatic concatenation of string literals has
been used to break up the RE into smaller pieces, but it's still more difficult
to understand than the version using :const:`re.VERBOSE`. | trusted_official_docs | CPython Docs | charref = re.compile("&#(0[0-7]+" "|[0-9]+" "|x[0-9a-fA-F]+);")
In the above example, Python's automatic concatenation of string literals has
been used to break up the RE into smaller pieces, but it's still more difficult
to understand than the version using :const:`re.VERBOSE`. | charref = re.compile("&#(0[0-7]+" "|[0-9]+" "|x[0-9a-fA-F]+);")
In the above example, Python's automatic concatenation of string literals has
been used to break up the RE into smaller pieces, but it's still more difficult
to understand than the version using :const:`re.VERBOSE`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b0f596d0-48a4-43bb-a951-091baf5670fe | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,401 | supabase-export-v2 | 41e85b8bca38e665 | the caret appears elsewhere in a character class, it does not have special meaning. For example: ``[5^]`` will match either a ``'5'`` or a ``'^'``.
Perhaps the most important metacharacter is the backslash, ``\``. As in Python
string literals, the backslash can be followed by various characters to signal
various specia... | trusted_official_docs | CPython Docs | the caret appears elsewhere in a character class, it does not have special meaning. For example: ``[5^]`` will match either a ``'5'`` or a ``'^'``.
Perhaps the most important metacharacter is the backslash, ``\``. As in Python
string literals, the backslash can be followed by various characters to signal
various specia... | the caret appears elsewhere in a character class, it does not have special meaning. For example: ``[5^]`` will match either a ``'5'`` or a ``'^'``.
Perhaps the most important metacharacter is the backslash, ``\``. As in Python
string literals, the backslash can be followed by various characters to signal
various specia... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b13d7704-f62d-4573-b9a6-102f45237594 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,460 | supabase-export-v2 | ac8b19d5151400d2 | position of the match | +------------------+--------------------------------------------+ | ``span()`` | Return a tuple containing the (start, end) | | | positions of the match | +------------------+--------------------------------------------+
Trying these methods will soon clarify their meaning:: | trusted_official_docs | CPython Docs | position of the match | +------------------+--------------------------------------------+ | ``span()`` | Return a tuple containing the (start, end) | | | positions of the match | +------------------+--------------------------------------------+
Trying these methods will soon clarify their meaning:: | position of the match | +------------------+--------------------------------------------+ | ``span()`` | Return a tuple containing the (start, end) | | | positions of the match | +------------------+--------------------------------------------+
Trying these methods will soon clarify their meaning:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b218c795-f55c-41c5-b9ae-2449c242e462 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,518 | supabase-export-v2 | 2c69ed66aa5b0789 | ``\A`` still matches only at the beginning of the string, but ``^`` may match at any location inside the string that follows a newline character.
``\z``
Matches only at the end of the string. | trusted_official_docs | CPython Docs | ``\A`` still matches only at the beginning of the string, but ``^`` may match at any location inside the string that follows a newline character.
``\z``
Matches only at the end of the string. | ``\A`` still matches only at the beginning of the string, but ``^`` may match at any location inside the string that follows a newline character.
``\z``
Matches only at the end of the string. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b59874e3-b6c2-4507-a308-76baff4d87aa | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,454 | supabase-export-v2 | d11b0a55979a84cb | >>> import re >>> p = re.compile('[a-z]+') >>> p re.compile('[a-z]+')
Now, you can try matching various strings against the RE ``[a-z]+``. An empty
string shouldn't match at all, since ``+`` means 'one or more repetitions'. :meth:`~re.Pattern.search` should return ``None`` in this case, which will cause the
interpreter... | trusted_official_docs | CPython Docs | >>> import re >>> p = re.compile('[a-z]+') >>> p re.compile('[a-z]+')
Now, you can try matching various strings against the RE ``[a-z]+``. An empty
string shouldn't match at all, since ``+`` means 'one or more repetitions'. :meth:`~re.Pattern.search` should return ``None`` in this case, which will cause the
interpreter... | >>> import re >>> p = re.compile('[a-z]+') >>> p re.compile('[a-z]+')
Now, you can try matching various strings against the RE ``[a-z]+``. An empty
string shouldn't match at all, since ``+`` means 'one or more repetitions'. :meth:`~re.Pattern.search` should return ``None`` in this case, which will cause the
interpreter... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b59bfe67-5293-4d54-9dbe-36c502e47bf3 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,532 | supabase-export-v2 | 483d0ed16d3268b2 | regular expression which matches an entire header line, and has one group which matches the header name, and another group which matches the header's value.
Groups are marked by the ``'('``, ``')'`` metacharacters. ``'('`` and ``')'``
have much the same meaning as they do in mathematical expressions; they group
togethe... | trusted_official_docs | CPython Docs | regular expression which matches an entire header line, and has one group which matches the header name, and another group which matches the header's value.
Groups are marked by the ``'('``, ``')'`` metacharacters. ``'('`` and ``')'``
have much the same meaning as they do in mathematical expressions; they group
togethe... | regular expression which matches an entire header line, and has one group which matches the header name, and another group which matches the header's value.
Groups are marked by the ``'('``, ``')'`` metacharacters. ``'('`` and ``')'``
have much the same meaning as they do in mathematical expressions; they group
togethe... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b6070a72-f490-4487-acb7-a542680f2a40 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,561 | supabase-export-v2 | bba0c49bf330461d | groups are handy because they let you use easily remembered names, instead of having to remember numbers. Here's an example RE from the :mod:`imaplib` module::
InternalDate = re.compile(r'INTERNALDATE "'
r'(?P<day>[ 123][0-9])-(?P<mon>[A-Z][a-z][a-z])-'
r'(?P<year>[0-9][0-9][0-9][0-9])'
r' (?P<hour>[0-9][0-9]):(?P<m... | trusted_official_docs | CPython Docs | groups are handy because they let you use easily remembered names, instead of having to remember numbers. Here's an example RE from the :mod:`imaplib` module::
InternalDate = re.compile(r'INTERNALDATE "'
r'(?P<day>[ 123][0-9])-(?P<mon>[A-Z][a-z][a-z])-'
r'(?P<year>[0-9][0-9][0-9][0-9])'
r' (?P<hour>[0-9][0-9]):(?P<m... | groups are handy because they let you use easily remembered names, instead of having to remember numbers. Here's an example RE from the :mod:`imaplib` module::
InternalDate = re.compile(r'INTERNALDATE "'
r'(?P<day>[ 123][0-9])-(?P<mon>[A-Z][a-z][a-z])-'
r'(?P<year>[0-9][0-9][0-9][0-9])'
r' (?P<hour>[0-9][0-9]):(?P<m... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b77b452f-3ea7-41fc-884b-f0c42df3b076 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,637 | supabase-export-v2 | d49c61033f13c9f6 | >>> s = '<html><head><title>Title</title>' >>> len(s) 32 >>> print(re.prefixmatch('<.*>', s).span()) (0, 32) >>> print(re.prefixmatch('<.*>', s).group()) <html><head><title>Title</title>
The RE matches the ``'<'`` in ``'<html>'``, and the ``.*`` consumes the rest of
the string. There's still more left in the RE, though... | trusted_official_docs | CPython Docs | >>> s = '<html><head><title>Title</title>' >>> len(s) 32 >>> print(re.prefixmatch('<.*>', s).span()) (0, 32) >>> print(re.prefixmatch('<.*>', s).group()) <html><head><title>Title</title>
The RE matches the ``'<'`` in ``'<html>'``, and the ``.*`` consumes the rest of
the string. There's still more left in the RE, though... | >>> s = '<html><head><title>Title</title>' >>> len(s) 32 >>> print(re.prefixmatch('<.*>', s).span()) (0, 32) >>> print(re.prefixmatch('<.*>', s).group()) <html><head><title>Title</title>
The RE matches the ``'<'`` in ``'<html>'``, and the ``.*`` consumes the rest of
the string. There's still more left in the RE, though... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b7e0b7f0-3bf8-4bfd-8706-c2847a41843d | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,453 | supabase-export-v2 | e7b5475a9934234d | This HOWTO uses the standard Python interpreter for its examples. First, run the Python interpreter, import the :mod:`re` module, and compile a RE::
>>> import re
>>> p = re.compile('[a-z]+')
>>> p
re.compile('[a-z]+') | trusted_official_docs | CPython Docs | This HOWTO uses the standard Python interpreter for its examples. First, run the Python interpreter, import the :mod:`re` module, and compile a RE::
>>> import re
>>> p = re.compile('[a-z]+')
>>> p
re.compile('[a-z]+') | This HOWTO uses the standard Python interpreter for its examples. First, run the Python interpreter, import the :mod:`re` module, and compile a RE::
>>> import re
>>> p = re.compile('[a-z]+')
>>> p
re.compile('[a-z]+') | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bd57e3d4-e574-41b1-a075-8d9294eb265d | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,389 | supabase-export-v2 | e692b267d8714909 | produce bytecode that runs faster. Optimization isn't covered in this document, because it requires that you have a good understanding of the matching engine's internals.
The regular expression language is relatively small and restricted, so not all
possible string processing tasks can be done using regular expressions... | trusted_official_docs | CPython Docs | produce bytecode that runs faster. Optimization isn't covered in this document, because it requires that you have a good understanding of the matching engine's internals.
The regular expression language is relatively small and restricted, so not all
possible string processing tasks can be done using regular expressions... | produce bytecode that runs faster. Optimization isn't covered in this document, because it requires that you have a good understanding of the matching engine's internals.
The regular expression language is relatively small and restricted, so not all
possible string processing tasks can be done using regular expressions... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bde04a0a-6691-48e5-aa33-233c3cc8469e | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,547 | supabase-export-v2 | aaec7f02227e68c1 | Non-capturing and named groups ------------------------------
Elaborate REs may use many groups, both to capture substrings of interest, and
to group and structure the RE itself. In complex REs, it becomes difficult to
keep track of the group numbers. There are two features which help with this
problem. Both of them us... | trusted_official_docs | CPython Docs | Non-capturing and named groups ------------------------------
Elaborate REs may use many groups, both to capture substrings of interest, and
to group and structure the RE itself. In complex REs, it becomes difficult to
keep track of the group numbers. There are two features which help with this
problem. Both of them us... | Non-capturing and named groups ------------------------------
Elaborate REs may use many groups, both to capture substrings of interest, and
to group and structure the RE itself. In complex REs, it becomes difficult to
keep track of the group numbers. There are two features which help with this
problem. Both of them us... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bfd4f6b7-8fac-482b-8658-f18252c1d967 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,580 | supabase-export-v2 | 568fb8be44045778 | the third attempt, the second and third letters are all made optional in order to allow matching extensions shorter than three characters, such as ``sendmail.cf``.
The pattern's getting really complicated now, which makes it hard to read and
understand. Worse, if the problem changes and you want to exclude both ``bat``... | trusted_official_docs | CPython Docs | the third attempt, the second and third letters are all made optional in order to allow matching extensions shorter than three characters, such as ``sendmail.cf``.
The pattern's getting really complicated now, which makes it hard to read and
understand. Worse, if the problem changes and you want to exclude both ``bat``... | the third attempt, the second and third letters are all made optional in order to allow matching extensions shorter than three characters, such as ``sendmail.cf``.
The pattern's getting really complicated now, which makes it hard to read and
understand. Worse, if the problem changes and you want to exclude both ``bat``... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c143f726-9adb-4b88-96b6-dbb96a32a115 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,383 | supabase-export-v2 | abe7b2afca2ec84c | :Author: A.M. Kuchling <amk@amk.ca>
.. TODO:
Document lookbehind assertions
Better way of displaying a RE, a string, and what it matches
Mention optional argument to match.groups()
Unicode (at least a reference) | trusted_official_docs | CPython Docs | :Author: A.M. Kuchling <amk@amk.ca>
.. TODO:
Document lookbehind assertions
Better way of displaying a RE, a string, and what it matches
Mention optional argument to match.groups()
Unicode (at least a reference) | :Author: A.M. Kuchling <amk@amk.ca>
.. TODO:
Document lookbehind assertions
Better way of displaying a RE, a string, and what it matches
Mention optional argument to match.groups()
Unicode (at least a reference) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c19c880d-2ebf-4eb0-a457-bc37bdca3bd8 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,486 | supabase-export-v2 | 247a7153391e8b77 | Make ``\w``, ``\W``, ``\b``, ``\B`` and case-insensitive matching dependent on the current locale instead of the Unicode database.
Locales are a feature of the C library intended to help in writing programs
that take account of language differences. For example, if you're
processing encoded French text, you'd want to... | trusted_official_docs | CPython Docs | Make ``\w``, ``\W``, ``\b``, ``\B`` and case-insensitive matching dependent on the current locale instead of the Unicode database.
Locales are a feature of the C library intended to help in writing programs
that take account of language differences. For example, if you're
processing encoded French text, you'd want to... | Make ``\w``, ``\W``, ``\b``, ``\B`` and case-insensitive matching dependent on the current locale instead of the Unicode database.
Locales are a feature of the C library intended to help in writing programs
that take account of language differences. For example, if you're
processing encoded French text, you'd want to... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c1b54b60-df97-4294-8f9e-0610c7ae6dfa | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,605 | supabase-export-v2 | 578e70ed47f86987 | Here's a simple example of using the :meth:`~re.Pattern.sub` method. It replaces colour names with the word ``colour``::
>>> p = re.compile('(blue|white|red)')
>>> p.sub('colour', 'blue socks and red shoes')
'colour socks and colour shoes'
>>> p.sub('colour', 'blue socks and red shoes', count=1)
'colour socks and r... | trusted_official_docs | CPython Docs | Here's a simple example of using the :meth:`~re.Pattern.sub` method. It replaces colour names with the word ``colour``::
>>> p = re.compile('(blue|white|red)')
>>> p.sub('colour', 'blue socks and red shoes')
'colour socks and colour shoes'
>>> p.sub('colour', 'blue socks and red shoes', count=1)
'colour socks and r... | Here's a simple example of using the :meth:`~re.Pattern.sub` method. It replaces colour names with the word ``colour``::
>>> p = re.compile('(blue|white|red)')
>>> p.sub('colour', 'blue socks and red shoes')
'colour socks and colour shoes'
>>> p.sub('colour', 'blue socks and red shoes', count=1)
'colour socks and r... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c268e9a5-8a3e-4be2-80cd-ec4bfecd3111 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,412 | supabase-export-v2 | fde28d61bb69aba3 | sequences can be included inside a character class. For example, ``[\s,.]`` is a character class that will match any whitespace character, or ``','`` or ``'.'``.
The final metacharacter in this section is ``.``. It matches anything except a
newline character, and there's an alternate mode (:const:`re.DOTALL`) where it ... | trusted_official_docs | CPython Docs | sequences can be included inside a character class. For example, ``[\s,.]`` is a character class that will match any whitespace character, or ``','`` or ``'.'``.
The final metacharacter in this section is ``.``. It matches anything except a
newline character, and there's an alternate mode (:const:`re.DOTALL`) where it ... | sequences can be included inside a character class. For example, ``[\s,.]`` is a character class that will match any whitespace character, or ``','`` or ``'.'``.
The final metacharacter in this section is ``.``. It matches anything except a
newline character, and there's an alternate mode (:const:`re.DOTALL`) where it ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c3147f32-9ed3-4ef3-8a9a-89510c9e767c | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,398 | supabase-export-v2 | ecf42826178d6c4f | . ^ $ * + ? { } [ ] \ | ( )
The first metacharacters we'll look at are ``[`` and ``]``. They're used for
specifying a character class, which is a set of characters that you wish to
match. Characters can be listed individually, or a range of characters can be
indicated by giving two characters and separating them by a `... | trusted_official_docs | CPython Docs | . ^ $ * + ? { } [ ] \ | ( )
The first metacharacters we'll look at are ``[`` and ``]``. They're used for
specifying a character class, which is a set of characters that you wish to
match. Characters can be listed individually, or a range of characters can be
indicated by giving two characters and separating them by a `... | . ^ $ * + ? { } [ ] \ | ( )
The first metacharacters we'll look at are ``[`` and ``]``. They're used for
specifying a character class, which is a set of characters that you wish to
match. Characters can be listed individually, or a range of characters can be
indicated by giving two characters and separating them by a `... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c41325a8-c682-4a4b-acf4-e85ceec66790 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,588 | supabase-export-v2 | 500ad8a9400a57f7 | we've simply performed searches against a static string. Regular expressions are also commonly used to modify strings in various ways, using the following pattern methods:
+------------------+-----------------------------------------------+
| Method/Attribute | Purpose |
+==================+============================... | trusted_official_docs | CPython Docs | we've simply performed searches against a static string. Regular expressions are also commonly used to modify strings in various ways, using the following pattern methods:
+------------------+-----------------------------------------------+
| Method/Attribute | Purpose |
+==================+============================... | we've simply performed searches against a static string. Regular expressions are also commonly used to modify strings in various ways, using the following pattern methods:
+------------------+-----------------------------------------------+
| Method/Attribute | Purpose |
+==================+============================... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c992f882-ce11-411a-9e21-e0cd7a647578 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,569 | supabase-export-v2 | b865c58e686f835f | lookahead assertion. This is the opposite of the positive assertion; it succeeds if the contained expression *doesn't* match at the current position in the string.
To make this concrete, let's look at a case where a lookahead is useful. Consider a simple pattern to match a filename and split it apart into a base
name a... | trusted_official_docs | CPython Docs | lookahead assertion. This is the opposite of the positive assertion; it succeeds if the contained expression *doesn't* match at the current position in the string.
To make this concrete, let's look at a case where a lookahead is useful. Consider a simple pattern to match a filename and split it apart into a base
name a... | lookahead assertion. This is the opposite of the positive assertion; it succeeds if the contained expression *doesn't* match at the current position in the string.
To make this concrete, let's look at a case where a lookahead is useful. Consider a simple pattern to match a filename and split it apart into a base
name a... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cae0e8cc-3969-4664-807b-069f8f932053 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,555 | supabase-export-v2 | 56c4855d4936bfaa | numbered. It should be mentioned that there's no performance difference in searching between capturing and non-capturing groups; neither form is any faster than the other.
A more significant feature is named groups: instead of referring to them by
numbers, groups can be referenced by a name. | trusted_official_docs | CPython Docs | numbered. It should be mentioned that there's no performance difference in searching between capturing and non-capturing groups; neither form is any faster than the other.
A more significant feature is named groups: instead of referring to them by
numbers, groups can be referenced by a name. | numbered. It should be mentioned that there's no performance difference in searching between capturing and non-capturing groups; neither form is any faster than the other.
A more significant feature is named groups: instead of referring to them by
numbers, groups can be referenced by a name. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cbf4ac5b-7c81-439b-a2eb-029b35ef2d33 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,622 | supabase-export-v2 | a48e9329aee8096f | Use string methods ------------------
Sometimes using the :mod:`re` module is a mistake. If you're matching a fixed
string, or a single character class, and you're not using any :mod:`re` features
such as the :const:`~re.IGNORECASE` flag, then the full power of regular expressions
may not be required. Strings have seve... | trusted_official_docs | CPython Docs | Use string methods ------------------
Sometimes using the :mod:`re` module is a mistake. If you're matching a fixed
string, or a single character class, and you're not using any :mod:`re` features
such as the :const:`~re.IGNORECASE` flag, then the full power of regular expressions
may not be required. Strings have seve... | Use string methods ------------------
Sometimes using the :mod:`re` module is a mistake. If you're matching a fixed
string, or a single character class, and you're not using any :mod:`re` features
such as the :const:`~re.IGNORECASE` flag, then the full power of regular expressions
may not be required. Strings have seve... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cd0eb72c-bf00-47cc-ac73-d0288cca3900 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,525 | supabase-export-v2 | 08d32f71036d790d | >>> p = re.compile('\bclass\b') >>> print(p.search('no class at all')) None >>> print(p.search('\b' + 'class' + '\b')) <re.Match object; span=(0, 7), match='\x08class\x08'>
Second, inside a character class, where there's no use for this assertion,
``\b`` represents the backspace character, for compatibility with Pytho... | trusted_official_docs | CPython Docs | >>> p = re.compile('\bclass\b') >>> print(p.search('no class at all')) None >>> print(p.search('\b' + 'class' + '\b')) <re.Match object; span=(0, 7), match='\x08class\x08'>
Second, inside a character class, where there's no use for this assertion,
``\b`` represents the backspace character, for compatibility with Pytho... | >>> p = re.compile('\bclass\b') >>> print(p.search('no class at all')) None >>> print(p.search('\b' + 'class' + '\b')) <re.Match object; span=(0, 7), match='\x08class\x08'>
Second, inside a character class, where there's no use for this assertion,
``\b`` represents the backspace character, for compatibility with Pytho... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cd273deb-6450-4fbc-844e-d35a433a829f | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,523 | supabase-export-v2 | 438dc72534734cd3 | >>> p = re.compile(r'\bclass\b') >>> print(p.search('no class at all')) <re.Match object; span=(3, 8), match='class'> >>> print(p.search('the declassified algorithm')) None >>> print(p.search('one subclass is')) None
There are two subtleties you should remember when using this special sequence. First, this is the worst... | trusted_official_docs | CPython Docs | >>> p = re.compile(r'\bclass\b') >>> print(p.search('no class at all')) <re.Match object; span=(3, 8), match='class'> >>> print(p.search('the declassified algorithm')) None >>> print(p.search('one subclass is')) None
There are two subtleties you should remember when using this special sequence. First, this is the worst... | >>> p = re.compile(r'\bclass\b') >>> print(p.search('no class at all')) <re.Match object; span=(3, 8), match='class'> >>> print(p.search('the declassified algorithm')) None >>> print(p.search('one subclass is')) None
There are two subtleties you should remember when using this special sequence. First, this is the worst... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cda63017-7528-46a2-a7fb-88e7b4f1b921 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,516 | supabase-export-v2 | 6ab05767f9b5beb9 | >>> print(re.search('}$', '{block}')) #doctest: +ELLIPSIS <re.Match object; span=(6, 7), match='}'> >>> print(re.search('}$', '{block} ')) None >>> print(re.search('}$', '{block}\n')) #doctest: +ELLIPSIS <re.Match object; span=(6, 7), match='}'>
To match a literal ``'$'``, use ``\$`` or enclose it inside a character cl... | trusted_official_docs | CPython Docs | >>> print(re.search('}$', '{block}')) #doctest: +ELLIPSIS <re.Match object; span=(6, 7), match='}'> >>> print(re.search('}$', '{block} ')) None >>> print(re.search('}$', '{block}\n')) #doctest: +ELLIPSIS <re.Match object; span=(6, 7), match='}'>
To match a literal ``'$'``, use ``\$`` or enclose it inside a character cl... | >>> print(re.search('}$', '{block}')) #doctest: +ELLIPSIS <re.Match object; span=(6, 7), match='}'> >>> print(re.search('}$', '{block} ')) None >>> print(re.search('}$', '{block}\n')) #doctest: +ELLIPSIS <re.Match object; span=(6, 7), match='}'>
To match a literal ``'$'``, use ``\$`` or enclose it inside a character cl... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ce439fb2-ccd2-4b79-9f44-498968d83df5 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,524 | supabase-export-v2 | e131a6a460a50758 | you expect it to. The following example looks the same as our previous RE, but omits the ``'r'`` in front of the RE string. ::
>>> p = re.compile('\bclass\b')
>>> print(p.search('no class at all'))
None
>>> print(p.search('\b' + 'class' + '\b'))
<re.Match object; span=(0, 7), match='\x08class\x08'> | trusted_official_docs | CPython Docs | you expect it to. The following example looks the same as our previous RE, but omits the ``'r'`` in front of the RE string. ::
>>> p = re.compile('\bclass\b')
>>> print(p.search('no class at all'))
None
>>> print(p.search('\b' + 'class' + '\b'))
<re.Match object; span=(0, 7), match='\x08class\x08'> | you expect it to. The following example looks the same as our previous RE, but omits the ``'r'`` in front of the RE string. ::
>>> p = re.compile('\bclass\b')
>>> print(p.search('no class at all'))
None
>>> print(p.search('\b' + 'class' + '\b'))
<re.Match object; span=(0, 7), match='\x08class\x08'> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cf27d4c7-b221-47e2-933e-66a21d9d4790 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,644 | supabase-export-v2 | b646ab68e41d6e89 | such REs, specifying the :const:`re.VERBOSE` flag when compiling the regular expression can be helpful, because it allows you to format the regular expression more clearly.
The ``re.VERBOSE`` flag has several effects. Whitespace in the regular
expression that *isn't* inside a character class is ignored. This means that... | trusted_official_docs | CPython Docs | such REs, specifying the :const:`re.VERBOSE` flag when compiling the regular expression can be helpful, because it allows you to format the regular expression more clearly.
The ``re.VERBOSE`` flag has several effects. Whitespace in the regular
expression that *isn't* inside a character class is ignored. This means that... | such REs, specifying the :const:`re.VERBOSE` flag when compiling the regular expression can be helpful, because it allows you to format the regular expression more clearly.
The ``re.VERBOSE`` flag has several effects. Whitespace in the regular
expression that *isn't* inside a character class is ignored. This means that... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d056faed-ec32-4d24-aaa1-8c90cb06e4f1 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,552 | supabase-export-v2 | deb2c5ba0f6613fe | Now that we've looked at the general extension syntax, we can return to the features that simplify working with groups in complex REs.
Sometimes you'll want to use a group to denote a part of a regular expression,
but aren't interested in retrieving the group's contents. You can make this fact
explicit by using a non-c... | trusted_official_docs | CPython Docs | Now that we've looked at the general extension syntax, we can return to the features that simplify working with groups in complex REs.
Sometimes you'll want to use a group to denote a part of a regular expression,
but aren't interested in retrieving the group's contents. You can make this fact
explicit by using a non-c... | Now that we've looked at the general extension syntax, we can return to the features that simplify working with groups in complex REs.
Sometimes you'll want to use a group to denote a part of a regular expression,
but aren't interested in retrieving the group's contents. You can make this fact
explicit by using a non-c... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d25cf9a9-695b-42ea-a60a-e474b12d7703 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,432 | supabase-export-v2 | 6253c76286363cb8 | Regular expressions are compiled into pattern objects, which have methods for various operations such as searching for pattern matches or performing string substitutions. ::
>>> import re
>>> p = re.compile('ab*')
>>> p
re.compile('ab*') | trusted_official_docs | CPython Docs | Regular expressions are compiled into pattern objects, which have methods for various operations such as searching for pattern matches or performing string substitutions. ::
>>> import re
>>> p = re.compile('ab*')
>>> p
re.compile('ab*') | Regular expressions are compiled into pattern objects, which have methods for various operations such as searching for pattern matches or performing string substitutions. ::
>>> import re
>>> p = re.compile('ab*')
>>> p
re.compile('ab*') | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d30c2bf8-cf44-4260-8bf1-cb3e1ffabb91 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,411 | supabase-export-v2 | 6c525e51acb0cb0d | ``\W`` Matches any non-alphanumeric character; this is equivalent to the class ``[^a-zA-Z0-9_]``.
These sequences can be included inside a character class. For example,
``[\s,.]`` is a character class that will match any whitespace character, or
``','`` or ``'.'``. | trusted_official_docs | CPython Docs | ``\W`` Matches any non-alphanumeric character; this is equivalent to the class ``[^a-zA-Z0-9_]``.
These sequences can be included inside a character class. For example,
``[\s,.]`` is a character class that will match any whitespace character, or
``','`` or ``'.'``. | ``\W`` Matches any non-alphanumeric character; this is equivalent to the class ``[^a-zA-Z0-9_]``.
These sequences can be included inside a character class. For example,
``[\s,.]`` is a character class that will match any whitespace character, or
``','`` or ``'.'``. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d4b9a8d5-7ed6-4623-a5a5-4bd4fd277472 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,510 | supabase-export-v2 | 6124a7dde6d57407 | To match a literal ``'|'``, use ``\|``, or enclose it inside a character class, as in ``[|]``.
``^``
Matches at the beginning of lines. Unless the :const:`MULTILINE` flag has been
set, this will only match at the beginning of the string. In :const:`MULTILINE`
mode, this also matches immediately after each newline wi... | trusted_official_docs | CPython Docs | To match a literal ``'|'``, use ``\|``, or enclose it inside a character class, as in ``[|]``.
``^``
Matches at the beginning of lines. Unless the :const:`MULTILINE` flag has been
set, this will only match at the beginning of the string. In :const:`MULTILINE`
mode, this also matches immediately after each newline wi... | To match a literal ``'|'``, use ``\|``, or enclose it inside a character class, as in ``[|]``.
``^``
Matches at the beginning of lines. Unless the :const:`MULTILINE` flag has been
set, this will only match at the beginning of the string. In :const:`MULTILINE`
mode, this also matches immediately after each newline wi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
da4d024a-df93-4ea5-bfec-488d53958a4e | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,514 | supabase-export-v2 | c287737685601e8d | To match a literal ``'^'``, use ``\^``.
``$``
Matches at the end of a line, which is defined as either the end of the string,
or any location followed by a newline character. :: | trusted_official_docs | CPython Docs | To match a literal ``'^'``, use ``\^``.
``$``
Matches at the end of a line, which is defined as either the end of the string,
or any location followed by a newline character. :: | To match a literal ``'^'``, use ``\^``.
``$``
Matches at the end of a line, which is defined as either the end of the string,
or any location followed by a newline character. :: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dd756d50-101b-40f3-a083-95c4bf211c06 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,537 | supabase-export-v2 | aba13cc8a0499e2f | to right, from 1 upward. Groups can be nested; to determine the number, just count the opening parenthesis characters, going from left to right. ::
>>> p = re.compile('(a(b)c)d')
>>> m = p.search('abcd')
>>> m.group(0)
'abcd'
>>> m.group(1)
'abc'
>>> m.group(2)
'b' | trusted_official_docs | CPython Docs | to right, from 1 upward. Groups can be nested; to determine the number, just count the opening parenthesis characters, going from left to right. ::
>>> p = re.compile('(a(b)c)d')
>>> m = p.search('abcd')
>>> m.group(0)
'abcd'
>>> m.group(1)
'abc'
>>> m.group(2)
'b' | to right, from 1 upward. Groups can be nested; to determine the number, just count the opening parenthesis characters, going from left to right. ::
>>> p = re.compile('(a(b)c)d')
>>> m = p.search('abcd')
>>> m.group(0)
'abcd'
>>> m.group(1)
'abc'
>>> m.group(2)
'b' | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
dde0e040-3180-4ece-8221-a6cef04d0861 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,441 | supabase-export-v2 | 8243a5410cbdde21 | string that must be passed to :func:`re.compile` must be ``\\section``. However, to express this as a Python string literal, both backslashes must be escaped *again*.
+-------------------+------------------------------------------+
| Characters | Stage |
+===================+==========================================+
... | trusted_official_docs | CPython Docs | string that must be passed to :func:`re.compile` must be ``\\section``. However, to express this as a Python string literal, both backslashes must be escaped *again*.
+-------------------+------------------------------------------+
| Characters | Stage |
+===================+==========================================+
... | string that must be passed to :func:`re.compile` must be ``\\section``. However, to express this as a Python string literal, both backslashes must be escaped *again*.
+-------------------+------------------------------------------+
| Characters | Stage |
+===================+==========================================+
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
def22504-7654-4c0f-9c64-0331d7b04bd7 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,536 | supabase-export-v2 | fe0914133b95b3c5 | >>> p = re.compile('(a)b') >>> m = p.search('ab') >>> m.group() 'ab' >>> m.group(0) 'ab'
Subgroups are numbered from left to right, from 1 upward. Groups can be nested;
to determine the number, just count the opening parenthesis characters, going
from left to right. :: | trusted_official_docs | CPython Docs | >>> p = re.compile('(a)b') >>> m = p.search('ab') >>> m.group() 'ab' >>> m.group(0) 'ab'
Subgroups are numbered from left to right, from 1 upward. Groups can be nested;
to determine the number, just count the opening parenthesis characters, going
from left to right. :: | >>> p = re.compile('(a)b') >>> m = p.search('ab') >>> m.group() 'ab' >>> m.group(0) 'ab'
Subgroups are numbered from left to right, from 1 upward. Groups can be nested;
to determine the number, just count the opening parenthesis characters, going
from left to right. :: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e89d7f8e-345a-4147-a11a-a18abc14977c | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,474 | supabase-export-v2 | 956d46d15a3da35c | >>> print(re.prefixmatch(r'From\s+', 'Fromage amk')) None >>> re.prefixmatch(r'From\s+', 'From amk Thu May 14 19:12:10 1998') #doctest: +ELLIPSIS <re.Match object; span=(0, 5), match='From '>
Under the hood, these functions simply create a pattern object for you
and call the appropriate method on it. They also store th... | trusted_official_docs | CPython Docs | >>> print(re.prefixmatch(r'From\s+', 'Fromage amk')) None >>> re.prefixmatch(r'From\s+', 'From amk Thu May 14 19:12:10 1998') #doctest: +ELLIPSIS <re.Match object; span=(0, 5), match='From '>
Under the hood, these functions simply create a pattern object for you
and call the appropriate method on it. They also store th... | >>> print(re.prefixmatch(r'From\s+', 'Fromage amk')) None >>> re.prefixmatch(r'From\s+', 'From amk Thu May 14 19:12:10 1998') #doctest: +ELLIPSIS <re.Match object; span=(0, 5), match='From '>
Under the hood, these functions simply create a pattern object for you
and call the appropriate method on it. They also store th... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e9a5c151-0348-41a0-8e2e-dfa8c763fe65 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,439 | supabase-export-v2 | ba25167ba9a63f06 | The backslash plague --------------------
As stated earlier, regular expressions use the backslash character (``'\'``) to
indicate special forms or to allow special characters to be used without
invoking their special meaning. This conflicts with Python's usage of the same
character for the same purpose in string liter... | trusted_official_docs | CPython Docs | The backslash plague --------------------
As stated earlier, regular expressions use the backslash character (``'\'``) to
indicate special forms or to allow special characters to be used without
invoking their special meaning. This conflicts with Python's usage of the same
character for the same purpose in string liter... | The backslash plague --------------------
As stated earlier, regular expressions use the backslash character (``'\'``) to
indicate special forms or to allow special characters to be used without
invoking their special meaning. This conflicts with Python's usage of the same
character for the same purpose in string liter... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e9af7673-0287-4bdd-9df1-12dba10e403c | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,635 | supabase-export-v2 | ca631ac552ac9fed | Greedy versus non-greedy ------------------------
When repeating a regular expression, as in ``a*``, the resulting action is to
consume as much of the pattern as possible. This fact often bites you when
you're trying to match a pair of balanced delimiters, such as the angle brackets
surrounding an HTML tag. The naive p... | trusted_official_docs | CPython Docs | Greedy versus non-greedy ------------------------
When repeating a regular expression, as in ``a*``, the resulting action is to
consume as much of the pattern as possible. This fact often bites you when
you're trying to match a pair of balanced delimiters, such as the angle brackets
surrounding an HTML tag. The naive p... | Greedy versus non-greedy ------------------------
When repeating a regular expression, as in ``a*``, the resulting action is to
consume as much of the pattern as possible. This fact often bites you when
you're trying to match a pair of balanced delimiters, such as the angle brackets
surrounding an HTML tag. The naive p... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e9b0aa2a-e7f7-446c-b7cd-adc003da5a9c | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,554 | supabase-export-v2 | 01bfe266f0ac6087 | >>> m = re.search("([abc])+", "abc") >>> m.groups() ('c',) >>> m = re.search("(?:[abc])+", "abc") >>> m.groups() ()
Except for the fact that you can't retrieve the contents of what the group
matched, a non-capturing group behaves exactly the same as a capturing group;
you can put anything inside it, repeat it with a re... | trusted_official_docs | CPython Docs | >>> m = re.search("([abc])+", "abc") >>> m.groups() ('c',) >>> m = re.search("(?:[abc])+", "abc") >>> m.groups() ()
Except for the fact that you can't retrieve the contents of what the group
matched, a non-capturing group behaves exactly the same as a capturing group;
you can put anything inside it, repeat it with a re... | >>> m = re.search("([abc])+", "abc") >>> m.groups() ('c',) >>> m = re.search("(?:[abc])+", "abc") >>> m.groups() ()
Except for the fact that you can't retrieve the contents of what the group
matched, a non-capturing group behaves exactly the same as a capturing group;
you can put anything inside it, repeat it with a re... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ea10ec4f-37eb-44e9-814e-51b94a64d1c1 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,418 | supabase-export-v2 | a0b1fad5a79c6dc7 | many times as possible. If later portions of the pattern don't match, the matching engine will then back up and try again with fewer repetitions.
A step-by-step example will make this more obvious. Let's consider the
expression ``a[bcd]*b``. This matches the letter ``'a'``, zero or more letters
from the class ``[bcd]``... | trusted_official_docs | CPython Docs | many times as possible. If later portions of the pattern don't match, the matching engine will then back up and try again with fewer repetitions.
A step-by-step example will make this more obvious. Let's consider the
expression ``a[bcd]*b``. This matches the letter ``'a'``, zero or more letters
from the class ``[bcd]``... | many times as possible. If later portions of the pattern don't match, the matching engine will then back up and try again with fewer repetitions.
A step-by-step example will make this more obvious. Let's consider the
expression ``a[bcd]*b``. This matches the letter ``'a'``, zero or more letters
from the class ``[bcd]``... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ec35afff-deef-4bfb-8d04-d00d6c84d17b | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,542 | supabase-export-v2 | feab5dc5f72a4cf6 | >>> m.groups() ('abc', 'b')
Backreferences in a pattern allow you to specify that the contents of an earlier
capturing group must also be found at the current location in the string. For
example, ``\1`` will succeed if the exact contents of group 1 can be found at
the current position, and fails otherwise. Remember tha... | trusted_official_docs | CPython Docs | >>> m.groups() ('abc', 'b')
Backreferences in a pattern allow you to specify that the contents of an earlier
capturing group must also be found at the current location in the string. For
example, ``\1`` will succeed if the exact contents of group 1 can be found at
the current position, and fails otherwise. Remember tha... | >>> m.groups() ('abc', 'b')
Backreferences in a pattern allow you to specify that the contents of an earlier
capturing group must also be found at the current location in the string. For
example, ``\1`` will succeed if the exact contents of group 1 can be found at
the current position, and fails otherwise. Remember tha... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ee1e2e0a-91c7-42a9-a247-41c1314bd80b | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,462 | supabase-export-v2 | 3bb3686d6b877c9b | >>> m.group() 'tempo' >>> m.start(), m.end() (0, 5) >>> m.span() (0, 5)
:meth:`~re.Match.group` returns the substring that was matched by the RE. :meth:`~re.Match.start`
and :meth:`~re.Match.end` return the starting and ending index of the match. :meth:`~re.Match.span`
returns both start and end indexes in a single tup... | trusted_official_docs | CPython Docs | >>> m.group() 'tempo' >>> m.start(), m.end() (0, 5) >>> m.span() (0, 5)
:meth:`~re.Match.group` returns the substring that was matched by the RE. :meth:`~re.Match.start`
and :meth:`~re.Match.end` return the starting and ending index of the match. :meth:`~re.Match.span`
returns both start and end indexes in a single tup... | >>> m.group() 'tempo' >>> m.start(), m.end() (0, 5) >>> m.span() (0, 5)
:meth:`~re.Match.group` returns the substring that was matched by the RE. :meth:`~re.Match.start`
and :meth:`~re.Match.end` return the starting and ending index of the match. :meth:`~re.Match.span`
returns both start and end indexes in a single tup... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f193926f-b54c-4e35-85a8-0c3e08293217 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,457 | supabase-export-v2 | 64415e8dc50b50fb | as ``tempo``. In this case, :meth:`~re.Pattern.search` will return a :ref:`match object <match-objects>`, so you should store the result in a variable for later use. ::
>>> m = p.search('tempo')
>>> m
<re.Match object; span=(0, 5), match='tempo'> | trusted_official_docs | CPython Docs | as ``tempo``. In this case, :meth:`~re.Pattern.search` will return a :ref:`match object <match-objects>`, so you should store the result in a variable for later use. ::
>>> m = p.search('tempo')
>>> m
<re.Match object; span=(0, 5), match='tempo'> | as ``tempo``. In this case, :meth:`~re.Pattern.search` will return a :ref:`match object <match-objects>`, so you should store the result in a variable for later use. ::
>>> m = p.search('tempo')
>>> m
<re.Match object; span=(0, 5), match='tempo'> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f31dc6b9-a10e-4e51-8707-27872b2c5fb7 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,435 | supabase-export-v2 | 921133cee23c9e60 | >>> p = re.compile('ab*', re.IGNORECASE)
The RE is passed to :func:`re.compile` as a string. REs are handled as strings
because regular expressions aren't part of the core Python language, and no
special syntax was created for expressing them. (There are applications that
don't need REs at all, so there's no need to bl... | trusted_official_docs | CPython Docs | >>> p = re.compile('ab*', re.IGNORECASE)
The RE is passed to :func:`re.compile` as a string. REs are handled as strings
because regular expressions aren't part of the core Python language, and no
special syntax was created for expressing them. (There are applications that
don't need REs at all, so there's no need to bl... | >>> p = re.compile('ab*', re.IGNORECASE)
The RE is passed to :func:`re.compile` as a string. REs are handled as strings
because regular expressions aren't part of the core Python language, and no
special syntax was created for expressing them. (There are applications that
don't need REs at all, so there's no need to bl... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f64f87ec-fe95-4154-b71b-f5415c763ca4 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,402 | supabase-export-v2 | e117a2cdb33a44fd | example, if you need to match a ``[`` or ``\``, you can precede them with a backslash to remove their special meaning: ``\[`` or ``\\``.
Some of the special sequences beginning with ``'\'`` represent
predefined sets of characters that are often useful, such as the set
of digits, the set of letters, or the set of anythi... | trusted_official_docs | CPython Docs | example, if you need to match a ``[`` or ``\``, you can precede them with a backslash to remove their special meaning: ``\[`` or ``\\``.
Some of the special sequences beginning with ``'\'`` represent
predefined sets of characters that are often useful, such as the set
of digits, the set of letters, or the set of anythi... | example, if you need to match a ``[`` or ``\``, you can precede them with a backslash to remove their special meaning: ``\[`` or ``\\``.
Some of the special sequences beginning with ``'\'`` represent
predefined sets of characters that are often useful, such as the set
of digits, the set of letters, or the set of anythi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f82efda2-b5e0-4e30-b5f8-8b2d7aef4e02 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,535 | supabase-export-v2 | ca26f487b4e418f2 | have group 0 as their default argument. Later we'll see how to express groups that don't capture the span of text that they match. ::
>>> p = re.compile('(a)b')
>>> m = p.search('ab')
>>> m.group()
'ab'
>>> m.group(0)
'ab' | trusted_official_docs | CPython Docs | have group 0 as their default argument. Later we'll see how to express groups that don't capture the span of text that they match. ::
>>> p = re.compile('(a)b')
>>> m = p.search('ab')
>>> m.group()
'ab'
>>> m.group(0)
'ab' | have group 0 as their default argument. Later we'll see how to express groups that don't capture the span of text that they match. ::
>>> p = re.compile('(a)b')
>>> m = p.search('ab')
>>> m.group()
'ab'
>>> m.group(0)
'ab' | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f92cf7e2-1b7b-4070-ba73-85d324cfd74c | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,487 | supabase-export-v2 | 1f623536aabe7d71 | the resulting compiled object to use these C functions for ``\w``; this is slower, but also enables ``\w+`` to match French words as you'd expect.
The use of this flag is discouraged in Python 3 as the locale mechanism
is very unreliable, it only handles one "culture" at a time, and it only
works with 8-bit locales. ... | trusted_official_docs | CPython Docs | the resulting compiled object to use these C functions for ``\w``; this is slower, but also enables ``\w+`` to match French words as you'd expect.
The use of this flag is discouraged in Python 3 as the locale mechanism
is very unreliable, it only handles one "culture" at a time, and it only
works with 8-bit locales. ... | the resulting compiled object to use these C functions for ``\w``; this is slower, but also enables ``\w+`` to match French words as you'd expect.
The use of this flag is discouraged in Python 3 as the locale mechanism
is very unreliable, it only handles one "culture" at a time, and it only
works with 8-bit locales. ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fa0007e8-df6f-4781-85fa-6de3de93d8b4 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,551 | supabase-export-v2 | 9fd842b6ebdbed44 | to Perl's extension syntax. If the first character after the question mark is a ``P``, you know that it's an extension that's specific to Python.
Now that we've looked at the general extension syntax, we can return
to the features that simplify working with groups in complex REs. | trusted_official_docs | CPython Docs | to Perl's extension syntax. If the first character after the question mark is a ``P``, you know that it's an extension that's specific to Python.
Now that we've looked at the general extension syntax, we can return
to the features that simplify working with groups in complex REs. | to Perl's extension syntax. If the first character after the question mark is a ``P``, you know that it's an extension that's specific to Python.
Now that we've looked at the general extension syntax, we can return
to the features that simplify working with groups in complex REs. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fa565942-065e-427d-a75e-79a6d6beefba | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,396 | supabase-export-v2 | cf097fa83ab69cd7 | portions of the RE by repeating them or changing their meaning. Much of this document is devoted to discussing various metacharacters and what they do.
Here's a complete list of the metacharacters; their meanings will be discussed
in the rest of this HOWTO. | trusted_official_docs | CPython Docs | portions of the RE by repeating them or changing their meaning. Much of this document is devoted to discussing various metacharacters and what they do.
Here's a complete list of the metacharacters; their meanings will be discussed
in the rest of this HOWTO. | portions of the RE by repeating them or changing their meaning. Much of this document is devoted to discussing various metacharacters and what they do.
Here's a complete list of the metacharacters; their meanings will be discussed
in the rest of this HOWTO. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fe124698-31ef-40f6-9c38-a5bf2b552655 | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,391 | supabase-export-v2 | 0f15f7c5d0608425 | Simple patterns ===============
We'll start by learning about the simplest possible regular expressions. Since
regular expressions are used to operate on strings, we'll begin with the most
common task: matching characters. | trusted_official_docs | CPython Docs | Simple patterns ===============
We'll start by learning about the simplest possible regular expressions. Since
regular expressions are used to operate on strings, we'll begin with the most
common task: matching characters. | Simple patterns ===============
We'll start by learning about the simplest possible regular expressions. Since
regular expressions are used to operate on strings, we'll begin with the most
common task: matching characters. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ffe64671-674c-4e3d-a150-2d86c214e91c | CPython Docs | file://datasets/cpython/Doc/howto/regex.rst | unknown | a0410288-0e34-49d0-91b0-b1fbbd428672 | 57,601 | supabase-export-v2 | 7aae2f212d161b48 | a different string. The :meth:`~re.Pattern.sub` method takes a replacement value, which can be either a string or a function, and the string to be processed.
.. method:: .sub(replacement, string[, count=0])
:noindex: | trusted_official_docs | CPython Docs | a different string. The :meth:`~re.Pattern.sub` method takes a replacement value, which can be either a string or a function, and the string to be processed.
.. method:: .sub(replacement, string[, count=0])
:noindex: | a different string. The :meth:`~re.Pattern.sub` method takes a replacement value, which can be either a string or a function, and the string to be processed.
.. method:: .sub(replacement, string[, count=0])
:noindex: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
024661d9-f08b-46af-92a2-7d62f4af961b | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,681 | supabase-export-v2 | 720607d64a9830bb | .. warning::
The execution of the injected script depends on the interpreter reaching a
safe evaluation point. As a result, execution may be delayed depending on
the runtime state of the target process. | trusted_official_docs | CPython Docs | .. warning::
The execution of the injected script depends on the interpreter reaching a
safe evaluation point. As a result, execution may be delayed depending on
the runtime state of the target process. | .. warning::
The execution of the injected script depends on the interpreter reaching a
safe evaluation point. As a result, execution may be delayed depending on
the runtime state of the target process. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0282fece-866d-4d53-98c3-9755114aa284 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,745 | supabase-export-v2 | 3332a0fdbc8289d8 | must be explicitly designed to handle partially updated or inconsistent memory. For most debugger implementations, suspending the process remains the safest and most robust approach.
Locating the interpreter and thread state
========================================= | trusted_official_docs | CPython Docs | must be explicitly designed to handle partially updated or inconsistent memory. For most debugger implementations, suspending the process remains the safest and most robust approach.
Locating the interpreter and thread state
========================================= | must be explicitly designed to handle partially updated or inconsistent memory. For most debugger implementations, suspending the process remains the safest and most robust approach.
Locating the interpreter and thread state
========================================= | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0769b09b-96d6-42dc-befa-05ba17dda246 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,749 | supabase-export-v2 | 02f88355c72b670d | its native thread ID. Once the target thread is chosen, the debugger must locate both the interpreter and the associated thread state structures in memory.
The relevant internal structures are defined as follows: | trusted_official_docs | CPython Docs | its native thread ID. Once the target thread is chosen, the debugger must locate both the interpreter and the associated thread state structures in memory.
The relevant internal structures are defined as follows: | its native thread ID. Once the target thread is chosen, the debugger must locate both the interpreter and the associated thread state structures in memory.
The relevant internal structures are defined as follows: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0cde6a17-4f53-4fa0-95ec-77df67643d07 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,683 | supabase-export-v2 | b5a8fef0f0d9ef24 | next time a safe evaluation point is reached. This approach enables remote execution capabilities without modifying the behavior or structure of the running Python application.
Subsequent sections provide a step-by-step description of the protocol,
including techniques for locating interpreter structures in memory, saf... | trusted_official_docs | CPython Docs | next time a safe evaluation point is reached. This approach enables remote execution capabilities without modifying the behavior or structure of the running Python application.
Subsequent sections provide a step-by-step description of the protocol,
including techniques for locating interpreter structures in memory, saf... | next time a safe evaluation point is reached. This approach enables remote execution capabilities without modifying the behavior or structure of the running Python application.
Subsequent sections provide a step-by-step description of the protocol,
including techniques for locating interpreter structures in memory, saf... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0da313a6-780e-4b89-a2c4-d0f1a3511a48 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,755 | supabase-export-v2 | 564ff6099d26d476 | 2. Use the offset ``interpreter_state.threads_main`` to access the main thread state associated with the selected interpreter. This is typically the most reliable thread to target.
3. Optionally, use the offset ``interpreter_state.threads_head`` to iterate
through the linked list of all thread states. Each ``PyThreadS... | trusted_official_docs | CPython Docs | 2. Use the offset ``interpreter_state.threads_main`` to access the main thread state associated with the selected interpreter. This is typically the most reliable thread to target.
3. Optionally, use the offset ``interpreter_state.threads_head`` to iterate
through the linked list of all thread states. Each ``PyThreadS... | 2. Use the offset ``interpreter_state.threads_main`` to access the main thread state associated with the selected interpreter. This is typically the most reliable thread to target.
3. Optionally, use the offset ``interpreter_state.threads_head`` to iterate
through the linked list of all thread states. Each ``PyThreadS... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1061528a-b30a-426a-a112-83848d414f1d | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,717 | supabase-export-v2 | 06bbc2beb6a83239 | To find the ``PyRuntime`` structure on Windows:
1. Use the ToolHelp API to enumerate all modules loaded in the target process. This is done using functions such as `CreateToolhelp32Snapshot
<https://learn.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot>`_,
`Module32First
<https://... | trusted_official_docs | CPython Docs | To find the ``PyRuntime`` structure on Windows:
1. Use the ToolHelp API to enumerate all modules loaded in the target process. This is done using functions such as `CreateToolhelp32Snapshot
<https://learn.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot>`_,
`Module32First
<https://... | To find the ``PyRuntime`` structure on Windows:
1. Use the ToolHelp API to enumerate all modules loaded in the target process. This is done using functions such as `CreateToolhelp32Snapshot
<https://learn.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot>`_,
`Module32First
<https://... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
10989dd5-bb3d-4135-bbe4-83dfe75b15fd | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,694 | supabase-export-v2 | d6bc431efa9818ba | get the offset of the ``.PyRuntime`` section. 3. Add that offset to the base address from step 1 to get the memory address of ``PyRuntime``.
The following is an example implementation:: | trusted_official_docs | CPython Docs | get the offset of the ``.PyRuntime`` section. 3. Add that offset to the base address from step 1 to get the memory address of ``PyRuntime``.
The following is an example implementation:: | get the offset of the ``.PyRuntime`` section. 3. Add that offset to the base address from step 1 to get the memory address of ``PyRuntime``.
The following is an example implementation:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
11706bdf-159a-4203-ac95-9b69b78ddb59 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,744 | supabase-export-v2 | 81ab8a798385b743 | .. note::
Some tools, such as profilers or sampling-based debuggers, may operate on
a running process without suspension. In such cases, tools must be
explicitly designed to handle partially updated or inconsistent memory. For most debugger implementations, suspending the process remains the
safest and most robust a... | trusted_official_docs | CPython Docs | .. note::
Some tools, such as profilers or sampling-based debuggers, may operate on
a running process without suspension. In such cases, tools must be
explicitly designed to handle partially updated or inconsistent memory. For most debugger implementations, suspending the process remains the
safest and most robust a... | .. note::
Some tools, such as profilers or sampling-based debuggers, may operate on
a running process without suspension. In such cases, tools must be
explicitly designed to handle partially updated or inconsistent memory. For most debugger implementations, suspending the process remains the
safest and most robust a... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1276c420-315e-441a-9ab6-be431fb836ef | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,673 | supabase-export-v2 | 57b1545764361d38 | To attach to another process, you usually need to run your debugging tool with administrative privileges. Start the command prompt or terminal as Administrator.
Some processes may still be inaccessible even with Administrator rights,
unless you have the ``SeDebugPrivilege`` privilege enabled. | trusted_official_docs | CPython Docs | To attach to another process, you usually need to run your debugging tool with administrative privileges. Start the command prompt or terminal as Administrator.
Some processes may still be inaccessible even with Administrator rights,
unless you have the ``SeDebugPrivilege`` privilege enabled. | To attach to another process, you usually need to run your debugging tool with administrative privileges. Start the command prompt or terminal as Administrator.
Some processes may still be inaccessible even with Administrator rights,
unless you have the ``SeDebugPrivilege`` privilege enabled. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
16dda488-3805-40bf-a955-2244d4d31620 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,771 | supabase-export-v2 | 2f3a02a73bb9600d | - ``debugger_pending_call``: An integer flag. Setting this to ``1`` tells the interpreter that a script is ready to be executed.
- ``eval_breaker``: A field checked by the interpreter during execution. Setting bit 5 (``_PY_EVAL_PLEASE_STOP_BIT``, value ``1U << 5``) in this
field causes the interpreter to pause and che... | trusted_official_docs | CPython Docs | - ``debugger_pending_call``: An integer flag. Setting this to ``1`` tells the interpreter that a script is ready to be executed.
- ``eval_breaker``: A field checked by the interpreter during execution. Setting bit 5 (``_PY_EVAL_PLEASE_STOP_BIT``, value ``1U << 5``) in this
field causes the interpreter to pause and che... | - ``debugger_pending_call``: An integer flag. Setting this to ``1`` tells the interpreter that a script is ready to be executed.
- ``eval_breaker``: A field checked by the interpreter during execution. Setting bit 5 (``_PY_EVAL_PLEASE_STOP_BIT``, value ``1U << 5``) in this
field causes the interpreter to pause and che... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
191cf1d1-2d43-4dc2-bbbf-e3ea0efe435e | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,758 | supabase-export-v2 | 9f2ee2ab00ec748d | The following is an example implementation that locates the main thread state::
def find_main_thread_state(
pid: int, py_runtime_addr: int, debug_offsets: DebugOffsets,
) -> int:
# Step 1: Read interpreters_head from PyRuntime
interp_head_ptr = (
py_runtime_addr + debug_offsets.runtime_state.interpreters_head
)
... | trusted_official_docs | CPython Docs | The following is an example implementation that locates the main thread state::
def find_main_thread_state(
pid: int, py_runtime_addr: int, debug_offsets: DebugOffsets,
) -> int:
# Step 1: Read interpreters_head from PyRuntime
interp_head_ptr = (
py_runtime_addr + debug_offsets.runtime_state.interpreters_head
)
... | The following is an example implementation that locates the main thread state::
def find_main_thread_state(
pid: int, py_runtime_addr: int, debug_offsets: DebugOffsets,
) -> int:
# Step 1: Read interpreters_head from PyRuntime
interp_head_ptr = (
py_runtime_addr + debug_offsets.runtime_state.interpreters_head
)
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
19cbd957-283d-4ad8-9b0b-fa7cf5a7ea52 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,722 | supabase-export-v2 | b776e36d73decb51 | # Step 2: Fallback to shared pythonXY.dll if the executable is not # found if binary_path is None: binary_path, base_address = find_loaded_module( pid, name_contains="python3" )
# Step 3: Parse PE section headers to get the RVA of the PyRuntime
# section. The section name appears as "PyRuntim" due to the
# 8-characte... | trusted_official_docs | CPython Docs | # Step 2: Fallback to shared pythonXY.dll if the executable is not # found if binary_path is None: binary_path, base_address = find_loaded_module( pid, name_contains="python3" )
# Step 3: Parse PE section headers to get the RVA of the PyRuntime
# section. The section name appears as "PyRuntim" due to the
# 8-characte... | # Step 2: Fallback to shared pythonXY.dll if the executable is not # found if binary_path is None: binary_path, base_address = find_loaded_module( pid, name_contains="python3" )
# Step 3: Parse PE section headers to get the RVA of the PyRuntime
# section. The section name appears as "PyRuntim" due to the
# 8-characte... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1aee013e-5c0a-4435-a97d-f39f803956d1 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,770 | supabase-export-v2 | dcadff948cf4ec32 | holds the full path to a Python source file (``.py``). This file must be accessible and readable by the target process when execution is triggered.
- ``debugger_pending_call``: An integer flag. Setting this to ``1`` tells the
interpreter that a script is ready to be executed. | trusted_official_docs | CPython Docs | holds the full path to a Python source file (``.py``). This file must be accessible and readable by the target process when execution is triggered.
- ``debugger_pending_call``: An integer flag. Setting this to ``1`` tells the
interpreter that a script is ready to be executed. | holds the full path to a Python source file (``.py``). This file must be accessible and readable by the target process when execution is triggered.
- ``debugger_pending_call``: An integer flag. Setting this to ``1`` tells the
interpreter that a script is ready to be executed. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1d8572ee-31d3-4979-9e4a-cec85cbeb006 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,724 | supabase-export-v2 | a6dd039b0ad6141e | # Step 4: Compute PyRuntime address in memory return base_address + section_rva
On Windows, accessing another process's memory requires using the Windows API
functions like ``CreateToolhelp32Snapshot()`` and ``Module32First()/Module32Next()``
to enumerate loaded modules. The ``OpenProcess()`` function provides a handle... | trusted_official_docs | CPython Docs | # Step 4: Compute PyRuntime address in memory return base_address + section_rva
On Windows, accessing another process's memory requires using the Windows API
functions like ``CreateToolhelp32Snapshot()`` and ``Module32First()/Module32Next()``
to enumerate loaded modules. The ``OpenProcess()`` function provides a handle... | # Step 4: Compute PyRuntime address in memory return base_address + section_rva
On Windows, accessing another process's memory requires using the Windows API
functions like ``CreateToolhelp32Snapshot()`` and ``Module32First()/Module32Next()``
to enumerate loaded modules. The ``OpenProcess()`` function provides a handle... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
21f4012f-f2d0-4658-be3e-15349d388793 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,704 | supabase-export-v2 | f75d8ee0a8e232b6 | To find the ``PyRuntime`` structure on macOS:
1. Call ``task_for_pid()`` to get the ``mach_port_t`` task port for the target
process. This handle is needed to read memory using APIs like
``mach_vm_read_overwrite`` and ``mach_vm_region``. 2. Scan the memory regions to find the one containing the Python executable or
... | trusted_official_docs | CPython Docs | To find the ``PyRuntime`` structure on macOS:
1. Call ``task_for_pid()`` to get the ``mach_port_t`` task port for the target
process. This handle is needed to read memory using APIs like
``mach_vm_read_overwrite`` and ``mach_vm_region``. 2. Scan the memory regions to find the one containing the Python executable or
... | To find the ``PyRuntime`` structure on macOS:
1. Call ``task_for_pid()`` to get the ``mach_port_t`` task port for the target
process. This handle is needed to read memory using APIs like
``mach_vm_read_overwrite`` and ``mach_vm_region``. 2. Scan the memory regions to find the one containing the Python executable or
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
23bca767-a3ac-4265-a5cb-bf6f420485c0 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,693 | supabase-export-v2 | 1e30f4f51fb67df8 | To find the ``PyRuntime`` structure on Linux:
1. Read the process’s memory map (for example, ``/proc/<pid>/maps``) to find
the address where the Python executable or ``libpython`` was loaded. 2. Parse the ELF section headers in the binary to get the offset of the
``.PyRuntime`` section. 3. Add that offset to the base... | trusted_official_docs | CPython Docs | To find the ``PyRuntime`` structure on Linux:
1. Read the process’s memory map (for example, ``/proc/<pid>/maps``) to find
the address where the Python executable or ``libpython`` was loaded. 2. Parse the ELF section headers in the binary to get the offset of the
``.PyRuntime`` section. 3. Add that offset to the base... | To find the ``PyRuntime`` structure on Linux:
1. Read the process’s memory map (for example, ``/proc/<pid>/maps``) to find
the address where the Python executable or ``libpython`` was loaded. 2. Parse the ELF section headers in the binary to get the offset of the
``.PyRuntime`` section. 3. Add that offset to the base... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
23d4c560-c349-488e-adf3-87c671f38953 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,726 | supabase-export-v2 | 9106b3bc4d396159 | by enumerating loaded modules to find the Python binary or DLL. When found, its PE headers need to be parsed to locate the ``PyRuntime`` structure.
The PE format organizes code and data into sections. The ``PyRuntime`` structure
lives in a section named "PyRuntim" (truncated from "PyRuntime" due to PE's
8-character nam... | trusted_official_docs | CPython Docs | by enumerating loaded modules to find the Python binary or DLL. When found, its PE headers need to be parsed to locate the ``PyRuntime`` structure.
The PE format organizes code and data into sections. The ``PyRuntime`` structure
lives in a section named "PyRuntim" (truncated from "PyRuntime" due to PE's
8-character nam... | by enumerating loaded modules to find the Python binary or DLL. When found, its PE headers need to be parsed to locate the ``PyRuntime`` structure.
The PE format organizes code and data into sections. The ``PyRuntime`` structure
lives in a section named "PyRuntim" (truncated from "PyRuntime" due to PE's
8-character nam... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
35ffb37b-4262-422d-8295-44d4f844ec17 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,686 | supabase-export-v2 | d627f3cf87be00b5 | is used on ELF systems, and ``__DATA,__PyRuntime`` is used on macOS. Tools can find the offset of this structure by examining the binary on disk.
The ``PyRuntime`` structure contains CPython’s global interpreter state and
provides access to other internal data, including the list of interpreters,
thread states, and deb... | trusted_official_docs | CPython Docs | is used on ELF systems, and ``__DATA,__PyRuntime`` is used on macOS. Tools can find the offset of this structure by examining the binary on disk.
The ``PyRuntime`` structure contains CPython’s global interpreter state and
provides access to other internal data, including the list of interpreters,
thread states, and deb... | is used on ELF systems, and ``__DATA,__PyRuntime`` is used on macOS. Tools can find the offset of this structure by examining the binary on disk.
The ``PyRuntime`` structure contains CPython’s global interpreter state and
provides access to other internal data, including the list of interpreters,
thread states, and deb... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3a92fd77-2ebc-473b-928b-8e08b2de9bab | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,690 | supabase-export-v2 | 5232619707458af4 | on-disk binary to locate the offset of the ``.PyRuntime`` section. 3. Add the section offset to the base address to compute the address in memory.
The sections below explain how to do this on each supported platform and
include example code. | trusted_official_docs | CPython Docs | on-disk binary to locate the offset of the ``.PyRuntime`` section. 3. Add the section offset to the base address to compute the address in memory.
The sections below explain how to do this on each supported platform and
include example code. | on-disk binary to locate the offset of the ``.PyRuntime`` section. 3. Add the section offset to the base address to compute the address in memory.
The sections below explain how to do this on each supported platform and
include example code. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3c6a6964-999f-4432-9d2b-d0e9235b36b4 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,661 | supabase-export-v2 | 591feead2f3253bf | .. rubric:: Linux
The tracer process must have the ``CAP_SYS_PTRACE`` capability or equivalent
privileges. You can only trace processes you own and can signal. Tracing may
fail if the process is already being traced, or if it is running with
set-user-ID or set-group-ID. Security modules like Yama may further restrict
t... | trusted_official_docs | CPython Docs | .. rubric:: Linux
The tracer process must have the ``CAP_SYS_PTRACE`` capability or equivalent
privileges. You can only trace processes you own and can signal. Tracing may
fail if the process is already being traced, or if it is running with
set-user-ID or set-group-ID. Security modules like Yama may further restrict
t... | .. rubric:: Linux
The tracer process must have the ``CAP_SYS_PTRACE`` capability or equivalent
privileges. You can only trace processes you own and can signal. Tracing may
fail if the process is already being traced, or if it is running with
set-user-ID or set-group-ID. Security modules like Yama may further restrict
t... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
40cfe9ef-759f-482a-8c5d-22014e966100 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,762 | supabase-export-v2 | 2f2a193159deab4b | The following example demonstrates how to locate a thread by its native thread ID::
def find_thread_by_id(
pid: int,
interp_addr: int,
debug_offsets: DebugOffsets,
target_tid: int,
) -> int:
# Start at threads_head and walk the linked list
thread_ptr = read_pointer(
pid,
interp_addr + debug_offsets.interpreter... | trusted_official_docs | CPython Docs | The following example demonstrates how to locate a thread by its native thread ID::
def find_thread_by_id(
pid: int,
interp_addr: int,
debug_offsets: DebugOffsets,
target_tid: int,
) -> int:
# Start at threads_head and walk the linked list
thread_ptr = read_pointer(
pid,
interp_addr + debug_offsets.interpreter... | The following example demonstrates how to locate a thread by its native thread ID::
def find_thread_by_id(
pid: int,
interp_addr: int,
debug_offsets: DebugOffsets,
target_tid: int,
) -> int:
# Start at threads_head and walk the linked list
thread_ptr = read_pointer(
pid,
interp_addr + debug_offsets.interpreter... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4174304d-1d7f-48cd-8baf-145b4fcb8485 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,774 | supabase-export-v2 | 3fc9dcd82f852de5 | Read the current value of ``eval_breaker``, set bit 5 (``_PY_EVAL_PLEASE_STOP_BIT``), and write the updated value back. This signals the interpreter to check for debugger activity.
The following is an example implementation:: | trusted_official_docs | CPython Docs | Read the current value of ``eval_breaker``, set bit 5 (``_PY_EVAL_PLEASE_STOP_BIT``), and write the updated value back. This signals the interpreter to check for debugger activity.
The following is an example implementation:: | Read the current value of ``eval_breaker``, set bit 5 (``_PY_EVAL_PLEASE_STOP_BIT``), and write the updated value back. This signals the interpreter to check for debugger activity.
The following is an example implementation:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
43c7d50d-c7dc-4a30-aa46-cfbf50e462b1 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,767 | supabase-export-v2 | 27881b9f95464c5a | Writing control information ===========================
Once a valid ``PyThreadState`` structure has been identified, the debugger may
modify control fields within it to schedule the execution of a specified Python
script. These control fields are checked periodically by the interpreter, and
when set correctly, they tr... | trusted_official_docs | CPython Docs | Writing control information ===========================
Once a valid ``PyThreadState`` structure has been identified, the debugger may
modify control fields within it to schedule the execution of a specified Python
script. These control fields are checked periodically by the interpreter, and
when set correctly, they tr... | Writing control information ===========================
Once a valid ``PyThreadState`` structure has been identified, the debugger may
modify control fields within it to schedule the execution of a specified Python
script. These control fields are checked periodically by the interpreter, and
when set correctly, they tr... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4a4a3f80-7de7-49bb-a369-e94bb60c8800 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,795 | supabase-export-v2 | 13b9a124dca95a40 | debugging or profiling of the process is expected and reducing attack surface is a priority, even though the OS-level privilege checks already prevent unprivileged access.
Setting this variable does **not** affect other OS-level debugging interfaces
(``ptrace``, ``/proc``, ``task_for_pid``, etc.), which remain availabl... | trusted_official_docs | CPython Docs | debugging or profiling of the process is expected and reducing attack surface is a priority, even though the OS-level privilege checks already prevent unprivileged access.
Setting this variable does **not** affect other OS-level debugging interfaces
(``ptrace``, ``/proc``, ``task_for_pid``, etc.), which remain availabl... | debugging or profiling of the process is expected and reducing attack surface is a priority, even though the OS-level privilege checks already prevent unprivileged access.
Setting this variable does **not** affect other OS-level debugging interfaces
(``ptrace``, ``/proc``, ``task_for_pid``, etc.), which remain availabl... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4ac9baf2-11b0-42c0-9d1d-63da878be2d7 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,712 | supabase-export-v2 | f3cf27bca068e078 | is obtaining a ``task_port`` handle via ``task_for_pid()``, which provides access to the target process's memory space. This handle enables memory operations through APIs like ``mach_vm_read_overwrite()``.
The process memory can be examined using ``mach_vm_region()`` to scan through the
virtual memory space, while ``pr... | trusted_official_docs | CPython Docs | is obtaining a ``task_port`` handle via ``task_for_pid()``, which provides access to the target process's memory space. This handle enables memory operations through APIs like ``mach_vm_read_overwrite()``.
The process memory can be examined using ``mach_vm_region()`` to scan through the
virtual memory space, while ``pr... | is obtaining a ``task_port`` handle via ``task_for_pid()``, which provides access to the target process's memory space. This handle enables memory operations through APIs like ``mach_vm_read_overwrite()``.
The process memory can be examined using ``mach_vm_region()`` to scan through the
virtual memory space, while ``pr... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4c2b05d0-e3e5-44f5-aa8a-780bcbf95e96 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,656 | supabase-export-v2 | 68b69db1bfbb5465 | To disable remote debugging support, use any of the following:
* Set the :envvar:`PYTHON_DISABLE_REMOTE_DEBUG` environment variable to ``1`` before
starting the interpreter. * Use the :option:`-X disable_remote_debug` command-line option. * Compile Python with the :option:`--without-remote-debug` build flag. | trusted_official_docs | CPython Docs | To disable remote debugging support, use any of the following:
* Set the :envvar:`PYTHON_DISABLE_REMOTE_DEBUG` environment variable to ``1`` before
starting the interpreter. * Use the :option:`-X disable_remote_debug` command-line option. * Compile Python with the :option:`--without-remote-debug` build flag. | To disable remote debugging support, use any of the following:
* Set the :envvar:`PYTHON_DISABLE_REMOTE_DEBUG` environment variable to ``1`` before
starting the interpreter. * Use the :option:`-X disable_remote_debug` command-line option. * Compile Python with the :option:`--without-remote-debug` build flag. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4f281414-c4a9-4ce6-affd-39c404611fa9 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,662 | supabase-export-v2 | f76abfd83be3574d | fail if the process is already being traced, or if it is running with set-user-ID or set-group-ID. Security modules like Yama may further restrict tracing.
To temporarily relax ptrace restrictions (until reboot), run: | trusted_official_docs | CPython Docs | fail if the process is already being traced, or if it is running with set-user-ID or set-group-ID. Security modules like Yama may further restrict tracing.
To temporarily relax ptrace restrictions (until reboot), run: | fail if the process is already being traced, or if it is running with set-user-ID or set-group-ID. Security modules like Yama may further restrict tracing.
To temporarily relax ptrace restrictions (until reboot), run: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5016d699-7483-49ae-b3cb-a78a8f1f05ce | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,710 | supabase-export-v2 | 2a58941f7e1c7af1 | # Step 4: Parse Mach-O headers to get __DATA,__PyRuntime section offset section_offset = parse_macho_section_offset( binary_path, "__DATA", "__PyRuntime" )
# Step 5: Compute the PyRuntime address in memory
return base_address + section_offset | trusted_official_docs | CPython Docs | # Step 4: Parse Mach-O headers to get __DATA,__PyRuntime section offset section_offset = parse_macho_section_offset( binary_path, "__DATA", "__PyRuntime" )
# Step 5: Compute the PyRuntime address in memory
return base_address + section_offset | # Step 4: Parse Mach-O headers to get __DATA,__PyRuntime section offset section_offset = parse_macho_section_offset( binary_path, "__DATA", "__PyRuntime" )
# Step 5: Compute the PyRuntime address in memory
return base_address + section_offset | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
54ed9165-a795-4b77-a901-45b22cde43f2 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,780 | supabase-export-v2 | 0b3b8d436605fb39 | process (if it was suspended). The interpreter will process the request at the next safe evaluation point, load the script from disk, and execute it.
It is the responsibility of the debugger to ensure that the script file remains
present and accessible to the target process during execution. | trusted_official_docs | CPython Docs | process (if it was suspended). The interpreter will process the request at the next safe evaluation point, load the script from disk, and execute it.
It is the responsibility of the debugger to ensure that the script file remains
present and accessible to the target process during execution. | process (if it was suspended). The interpreter will process the request at the next safe evaluation point, load the script from disk, and execute it.
It is the responsibility of the debugger to ensure that the script file remains
present and accessible to the target process during execution. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5a7e2ec2-8b63-416a-9fb5-cc0c7f2f9320 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,773 | supabase-export-v2 | f10b823aa504f5c0 | To complete the injection, the debugger must perform the following steps:
1. Write the full script path into the ``debugger_script_path`` buffer. 2. Set ``debugger_pending_call`` to ``1``. 3. Read the current value of ``eval_breaker``, set bit 5
(``_PY_EVAL_PLEASE_STOP_BIT``), and write the updated value back. This
s... | trusted_official_docs | CPython Docs | To complete the injection, the debugger must perform the following steps:
1. Write the full script path into the ``debugger_script_path`` buffer. 2. Set ``debugger_pending_call`` to ``1``. 3. Read the current value of ``eval_breaker``, set bit 5
(``_PY_EVAL_PLEASE_STOP_BIT``), and write the updated value back. This
s... | To complete the injection, the debugger must perform the following steps:
1. Write the full script path into the ``debugger_script_path`` buffer. 2. Set ``debugger_pending_call`` to ``1``. 3. Read the current value of ``eval_breaker``, set bit 5
(``_PY_EVAL_PLEASE_STOP_BIT``), and write the updated value back. This
s... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5b55f5fc-c094-474d-aa48-900055374ea0 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,768 | supabase-export-v2 | e951f0d20c3fa363 | are checked periodically by the interpreter, and when set correctly, they trigger the execution of remote code at a safe point in the evaluation loop.
Each ``PyThreadState`` contains a ``_PyRemoteDebuggerSupport`` structure used
for communication between the debugger and the interpreter. The locations of
its fields are... | trusted_official_docs | CPython Docs | are checked periodically by the interpreter, and when set correctly, they trigger the execution of remote code at a safe point in the evaluation loop.
Each ``PyThreadState`` contains a ``_PyRemoteDebuggerSupport`` structure used
for communication between the debugger and the interpreter. The locations of
its fields are... | are checked periodically by the interpreter, and when set correctly, they trigger the execution of remote code at a safe point in the evaluation loop.
Each ``PyThreadState`` contains a ``_PyRemoteDebuggerSupport`` structure used
for communication between the debugger and the interpreter. The locations of
its fields are... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
606a9347-205c-41e0-b10d-9fd349ead64b | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,725 | supabase-export-v2 | 4d4df39bd592d8ad | ``CreateToolhelp32Snapshot()`` and ``Module32First()/Module32Next()`` to enumerate loaded modules. The ``OpenProcess()`` function provides a handle to access the target process's memory space, enabling memory operations through ``ReadProcessMemory()``.
The process memory can be examined by enumerating loaded modules to... | trusted_official_docs | CPython Docs | ``CreateToolhelp32Snapshot()`` and ``Module32First()/Module32Next()`` to enumerate loaded modules. The ``OpenProcess()`` function provides a handle to access the target process's memory space, enabling memory operations through ``ReadProcessMemory()``.
The process memory can be examined by enumerating loaded modules to... | ``CreateToolhelp32Snapshot()`` and ``Module32First()/Module32Next()`` to enumerate loaded modules. The ``OpenProcess()`` function provides a handle to access the target process's memory space, enabling memory operations through ``ReadProcessMemory()``.
The process memory can be examined by enumerating loaded modules to... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
61ccc88c-a04a-453e-8403-592a2943f972 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,670 | supabase-export-v2 | bba8122c27eecf44 | to another process, you typically need to run your debugging tool with elevated privileges. This can be done by using ``sudo`` or running as root.
Even when attaching to processes you own, macOS may block debugging unless
the debugger is run with root privileges due to system security restrictions. | trusted_official_docs | CPython Docs | to another process, you typically need to run your debugging tool with elevated privileges. This can be done by using ``sudo`` or running as root.
Even when attaching to processes you own, macOS may block debugging unless
the debugger is run with root privileges due to system security restrictions. | to another process, you typically need to run your debugging tool with elevated privileges. This can be done by using ``sudo`` or running as root.
Even when attaching to processes you own, macOS may block debugging unless
the debugger is run with root privileges due to system security restrictions. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
632229dd-88e4-4e71-91c2-376c435c7e1f | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,700 | supabase-export-v2 | c0c5600b9cf36acd | memory, it is significantly slower as it only reads one word at a time and requires multiple context switches between the tracer and tracee processes.
For parsing ELF sections, the process involves reading and interpreting the ELF
file format structures from the binary file on disk. The ELF header contains a
pointer to... | trusted_official_docs | CPython Docs | memory, it is significantly slower as it only reads one word at a time and requires multiple context switches between the tracer and tracee processes.
For parsing ELF sections, the process involves reading and interpreting the ELF
file format structures from the binary file on disk. The ELF header contains a
pointer to... | memory, it is significantly slower as it only reads one word at a time and requires multiple context switches between the tracer and tracee processes.
For parsing ELF sections, the process involves reading and interpreting the ELF
file format structures from the binary file on disk. The ELF header contains a
pointer to... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6386b96c-1cb2-4746-919b-f0add9cbe4d6 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,785 | supabase-export-v2 | 7b81dcf18659b61c | To inject and execute a Python script in a remote process:
1. Locate the ``PyRuntime`` structure in the target process’s memory. 2. Read and validate the ``_Py_DebugOffsets`` structure at the beginning of
``PyRuntime``. 3. Use the offsets to locate a valid ``PyThreadState``. 4. Write the path to a Python script into `... | trusted_official_docs | CPython Docs | To inject and execute a Python script in a remote process:
1. Locate the ``PyRuntime`` structure in the target process’s memory. 2. Read and validate the ``_Py_DebugOffsets`` structure at the beginning of
``PyRuntime``. 3. Use the offsets to locate a valid ``PyThreadState``. 4. Write the path to a Python script into `... | To inject and execute a Python script in a remote process:
1. Locate the ``PyRuntime`` structure in the target process’s memory. 2. Read and validate the ``_Py_DebugOffsets`` structure at the beginning of
``PyRuntime``. 3. Use the offsets to locate a valid ``PyThreadState``. 4. Write the path to a Python script into `... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6418dedb-1fce-40e5-a156-8d590cfb5b90 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,685 | supabase-export-v2 | 1978cfa0b35037cc | Locating the PyRuntime structure ================================
CPython places the ``PyRuntime`` structure in a dedicated binary section to
help external tools find it at runtime. The name and format of this section
vary by platform. For example, ``.PyRuntime`` is used on ELF systems, and
``__DATA,__PyRuntime`` is us... | trusted_official_docs | CPython Docs | Locating the PyRuntime structure ================================
CPython places the ``PyRuntime`` structure in a dedicated binary section to
help external tools find it at runtime. The name and format of this section
vary by platform. For example, ``.PyRuntime`` is used on ELF systems, and
``__DATA,__PyRuntime`` is us... | Locating the PyRuntime structure ================================
CPython places the ``PyRuntime`` structure in a dedicated binary section to
help external tools find it at runtime. The name and format of this section
vary by platform. For example, ``.PyRuntime`` is used on ELF systems, and
``__DATA,__PyRuntime`` is us... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6615a779-33f0-4452-9ace-d60323d22e00 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,697 | supabase-export-v2 | 72ef3dda395a7a54 | # Step 2: Fallback to shared library if executable is not found if binary_path is None: binary_path, base_address = find_mapped_binary( pid, name_contains="libpython" )
# Step 3: Parse ELF headers to get .PyRuntime section offset
section_offset = parse_elf_section_offset(
binary_path, ".PyRuntime"
) | trusted_official_docs | CPython Docs | # Step 2: Fallback to shared library if executable is not found if binary_path is None: binary_path, base_address = find_mapped_binary( pid, name_contains="libpython" )
# Step 3: Parse ELF headers to get .PyRuntime section offset
section_offset = parse_elf_section_offset(
binary_path, ".PyRuntime"
) | # Step 2: Fallback to shared library if executable is not found if binary_path is None: binary_path, base_address = find_mapped_binary( pid, name_contains="libpython" )
# Step 3: Parse ELF headers to get .PyRuntime section offset
section_offset = parse_elf_section_offset(
binary_path, ".PyRuntime"
) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
681a0a5b-0eb2-4fe0-8b88-29cdfb8db61d | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,688 | supabase-export-v2 | a0c8cf11fb32de45 | the target process. This address can’t be hardcoded or calculated from a symbol name, because it depends on where the operating system loaded the binary.
The method for finding ``PyRuntime`` depends on the platform, but the steps are
the same in general: | trusted_official_docs | CPython Docs | the target process. This address can’t be hardcoded or calculated from a symbol name, because it depends on where the operating system loaded the binary.
The method for finding ``PyRuntime`` depends on the platform, but the steps are
the same in general: | the target process. This address can’t be hardcoded or calculated from a symbol name, because it depends on where the operating system loaded the binary.
The method for finding ``PyRuntime`` depends on the platform, but the steps are
the same in general: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6be634e5-1afe-4557-b962-05a3dd45dbc1 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,765 | supabase-export-v2 | a98027921a05e00f | raise RuntimeError("Thread with the given ID was not found")
Once a valid thread state has been located, the debugger can proceed with
modifying its control fields and scheduling execution, as described in the next
section. | trusted_official_docs | CPython Docs | raise RuntimeError("Thread with the given ID was not found")
Once a valid thread state has been located, the debugger can proceed with
modifying its control fields and scheduling execution, as described in the next
section. | raise RuntimeError("Thread with the given ID was not found")
Once a valid thread state has been located, the debugger can proceed with
modifying its control fields and scheduling execution, as described in the next
section. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6f049197-22ff-491f-8cb8-f9856e87f977 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,741 | supabase-export-v2 | b8734df69f416b11 | **Process suspension recommended**
To avoid race conditions and ensure memory consistency, it is strongly
recommended that the target process be suspended before performing any
operations that read or write internal interpreter state. The Python runtime
may concurrently mutate interpreter data structures—such as cre... | trusted_official_docs | CPython Docs | **Process suspension recommended**
To avoid race conditions and ensure memory consistency, it is strongly
recommended that the target process be suspended before performing any
operations that read or write internal interpreter state. The Python runtime
may concurrently mutate interpreter data structures—such as cre... | **Process suspension recommended**
To avoid race conditions and ensure memory consistency, it is strongly
recommended that the target process be suspended before performing any
operations that read or write internal interpreter state. The Python runtime
may concurrently mutate interpreter data structures—such as cre... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
763e9cca-38e6-4d59-8b22-99722009b61c | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,775 | supabase-export-v2 | f305949ebb77ead9 | The following is an example implementation::
def inject_script(
pid: int,
thread_state_addr: int,
debug_offsets: DebugOffsets,
script_path: str
) -> None:
# Compute the base offset of _PyRemoteDebuggerSupport
support_base = (
thread_state_addr +
debug_offsets.debugger_support.remote_debugger_support
) | trusted_official_docs | CPython Docs | The following is an example implementation::
def inject_script(
pid: int,
thread_state_addr: int,
debug_offsets: DebugOffsets,
script_path: str
) -> None:
# Compute the base offset of _PyRemoteDebuggerSupport
support_base = (
thread_state_addr +
debug_offsets.debugger_support.remote_debugger_support
) | The following is an example implementation::
def inject_script(
pid: int,
thread_state_addr: int,
debug_offsets: DebugOffsets,
script_path: str
) -> None:
# Compute the base offset of _PyRemoteDebuggerSupport
support_base = (
thread_state_addr +
debug_offsets.debugger_support.remote_debugger_support
) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7abc0cba-86af-4a7b-93ec-c0e2d55ea86c | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,705 | supabase-export-v2 | 436de5acaa7bfe80 | names are automatically prefixed with an underscore, so the ``PyRuntime`` symbol appears as ``_PyRuntime`` in the symbol table, but the section name is not affected.
The following is an example implementation:: | trusted_official_docs | CPython Docs | names are automatically prefixed with an underscore, so the ``PyRuntime`` symbol appears as ``_PyRuntime`` in the symbol table, but the section name is not affected.
The following is an example implementation:: | names are automatically prefixed with an underscore, so the ``PyRuntime`` symbol appears as ``_PyRuntime`` in the symbol table, but the section name is not affected.
The following is an example implementation:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7b5bd748-ae1f-419f-a708-5e4beebb7feb | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,764 | supabase-export-v2 | 2ebc25f60f41ad3a | native_tid_ptr = ( thread_ptr + debug_offsets.thread_state.native_thread_id ) native_tid = read_int(pid, native_tid_ptr) if native_tid == target_tid: return thread_ptr thread_ptr = read_pointer( pid, thread_ptr + debug_offsets.thread_state.next )
raise RuntimeError("Thread with the given ID was not found") | trusted_official_docs | CPython Docs | native_tid_ptr = ( thread_ptr + debug_offsets.thread_state.native_thread_id ) native_tid = read_int(pid, native_tid_ptr) if native_tid == target_tid: return thread_ptr thread_ptr = read_pointer( pid, thread_ptr + debug_offsets.thread_state.next )
raise RuntimeError("Thread with the given ID was not found") | native_tid_ptr = ( thread_ptr + debug_offsets.thread_state.native_thread_id ) native_tid = read_int(pid, native_tid_ptr) if native_tid == target_tid: return thread_ptr thread_ptr = read_pointer( pid, thread_ptr + debug_offsets.thread_state.next )
raise RuntimeError("Thread with the given ID was not found") | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7c27b651-4dc3-4c14-a0e3-ce7ecf38874f | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,714 | supabase-export-v2 | 66aeb7c7244defaa | ``__DATA`` segment containing our target section. The final address is computed by combining the base address with the appropriate section offsets from the Mach-O headers.
Note that accessing another process's memory on macOS typically requires
elevated privileges - either root access or special security entitlements
g... | trusted_official_docs | CPython Docs | ``__DATA`` segment containing our target section. The final address is computed by combining the base address with the appropriate section offsets from the Mach-O headers.
Note that accessing another process's memory on macOS typically requires
elevated privileges - either root access or special security entitlements
g... | ``__DATA`` segment containing our target section. The final address is computed by combining the base address with the appropriate section offsets from the Mach-O headers.
Note that accessing another process's memory on macOS typically requires
elevated privileges - either root access or special security entitlements
g... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7f82d0d2-ce05-4c0f-b62c-deee46c8d172 | CPython Docs | file://datasets/cpython/Doc/howto/remote_debugging.rst | unknown | d9c2e866-dcc6-4f6c-8ad6-115777f459f9 | 57,782 | supabase-export-v2 | 831db9854a078dff | .. note::
Script execution is asynchronous. The script file cannot be deleted
immediately after injection. The debugger should wait until the injected
script has produced an observable effect before removing the file. This effect depends on what the script is designed to do. For example,
a debugger might wait until ... | trusted_official_docs | CPython Docs | .. note::
Script execution is asynchronous. The script file cannot be deleted
immediately after injection. The debugger should wait until the injected
script has produced an observable effect before removing the file. This effect depends on what the script is designed to do. For example,
a debugger might wait until ... | .. note::
Script execution is asynchronous. The script file cannot be deleted
immediately after injection. The debugger should wait until the injected
script has produced an observable effect before removing the file. This effect depends on what the script is designed to do. For example,
a debugger might wait until ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.