-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-132661 8000 : Implement PEP 750 #132662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
gh-132661: Implement PEP 750 #132662
Changes from 1 commit
Commits
Show all changes
104 commits
Select commit
Hold shift + click to select a range
9248287
Implement next version of PEP 750
lysnikolaou 450d771
First fixes; conv and format_spec still not working
lysnikolaou a095a9b
Change BUILD_INTERPOLATION opcode to simplify
lysnikolaou 499d70c
Add templatelib module & clean-up types/objects etc.
lysnikolaou f742d45
Support explicit concatenation of template and str
lysnikolaou 0dda3f9
Avoid folding one node template into its content
lysnikolaou 17014e7
Implement __eq__ for template and interpolation
lysnikolaou 94371bd
Fix debug specifier segfault
lysnikolaou 99184cc
Add __match_args__ to Interpolation
lysnikolaou 4e89c87
Fix syntax error prefix in t-strings
lysnikolaou 6bfb095
Fix test_dis
lysnikolaou 560e957
Fix test_fstring
lysnikolaou 4d172c2
Fix test_embed
lysnikolaou c9362e3
Implement interleaving, hash functions and *args __init__
lysnikolaou d2bd673
Use Argument Clinic for interpolation_new
lysnikolaou 7ae1b60
Revert to using different grammar rules for tstring due to format_spec
lysnikolaou 5e7304f
Fix code generation for when there's many values in tstring
lysnikolaou
10000
Oct 25, 2024
c8f22f0
Remove duplicate parens from template repr
lysnikolaou b0dbe27
Fix conversion converter for interpolation __new__
lysnikolaou b07c419
Merge branch 'main' into tstrings
lysnikolaou 3e84771
Fix test_embed and test_dis -- again
lysnikolaou 9380ab9
Implement implicit concatenation with TemplateStr
lysnikolaou 22f9dc6
Merge branch 'main' into tstrings
lysnikolaou f207637
Implement new specification of template type
lysnikolaou 29b1386
Replace nb_add with sq_concat
lysnikolaou aad5d67
Correctly implement str + tstring
lysnikolaou 77822be
Make changes requested by Steering Council (#57)
Wingysam f3ba0fe
Merge branch 'main' into tstrings
lysnikolaou 422a515
Remove unnecessary _Py_TPFLAGS_MATCH_SELF from Template type (#60)
koxudaxi bb7359a
Fix memory leak in template concat error handling (#59)
koxudaxi 6a7b448
PEP 750 bug and spec fix (#58)
davepeck e6d01ef
Fix for segv in `_PyInterpolation_FromStackRefSteal` (#61)
davepeck 0801f17
More minor fixes after merge with main
lysnikolaou a51e954
Fix JIT build
lysnikolaou 76816a1
Fix Windows build
lysnikolaou 2c53f55
Remove smelly _conversion_converter symbol
lysnikolaou fa4b531
Fix check-c-globals
lysnikolaou 98e5d83
Fix various stuff in the VM
lysnikolaou a7c57fe
Add tests
lysnikolaou d6c470c
Fix Windows build (#64)
AA-Turner 101abe3
Merge branch 'main' into tstrings
lysnikolaou 7573346
Fix lint
lysnikolaou 4f91ea3
Skip test_tstring.py from ruff
lysnikolaou 14d9fa4
Fix parser bug and implement ast_unparse in Python
lysnikolaou bf89325
Modify CODEOWNERS
lysnikolaou b7edcd6
Do not use _PyAST_ExprAsUnicode (unparse) for interpolation expression
lysnikolaou 99c3bf4
Remove interpolation_compare() and interpolation_hash() (#65)
davepeck f09d99f
Add type check macros (#67)
AA-Turner 878eb69
t-strings: cosmetics (#66)
AA-Turner 7ed73fa
Implement GC protocol for template and interpolation types
lysnikolaou e88d111
Fix test_unparse again!
lysnikolaou 92fd148
Remove unnecessary tp_flag from interpolation type
lysnikolaou c833f6d
Merge branch 'main' into tstrings
lysnikolaou 8f8a414
Minor fixes (mostly cosmetic)
lysnikolaou 6bfc888
Add test for interleaving
lysnikolaou 0ee90f9
Merge branch 'main' into tstrings
terryjreedy e6da757
t-strings: Add more syntax tests (#68)
AA-Turner 58b7e5c
Move string.templatelib specific tests to test_string/test_templatlib…
AA-Turner 4c6cb47
Add more concatenation tests (#71)
AA-Turner 5782897
t-strings: Reduce undefined behaviour and general improvements (#72)
AA-Turner fb68d60
Add ``assertTStringEqual()`` helper (#73)
AA-Turner 174b045
Add a what's new entry (#69)
pauleveritt 62ace68
Fix repr
lysnikolaou 4f6c5df
Fix syntax errors in grammar
lysnikolaou e84778a
Rename f helper to fstring
lysnikolaou 8b24ff3
Use Py_BuildValue and add error checking for _PyType_GetDict
lysnikolaou 23444df
Return a strong ref from _PyInterpolation_GetValue
lysnikolaou 19aad93
Remove unnecessary function for template concatenation
lysnikolaou adbc109
Formatting
lysnikolaou a5e3bde
Add versionadded directive to TSTRING_START docs
lysnikolaou c8a9482
Add TOK_GET_STRING_PREFIX macro and change tstring field to enum
lysnikolaou 4e32db6
Merge branch 'main' into tstrings
lysnikolaou a78c082
Minor fixes to lexer and Makefile
lysnikolaou 173e456
Rename fields in tokenizer mode to not be f-string specific
lysnikolaou a595ccc
Nit: return result instead of -1
lysnikolaou 2282ccc
Move AST test to test_ast
lysnikolaou 53fc995
Fix unparsing implicit concat of t-strings with f-strings
lysnikolaou 58da4e0
Update CODEOWNERS
lysnikolaou 3e10c49
Clean up test_tstring
lysnikolaou 2addef7
Add new tokens TSTRING_MIDDLE & TSTRING_END
lysnikolaou 550fd07
Merge branch 'main' into tstrings
lysnikolaou 06c15de
Make Interpolation.conversion an int and change bytecode def
lysnikolaou f57647e
Fix ast_unparse and token generator
lysnikolaou a21391a
Let compiler build template tuples
lysnikolaou 1dca604
Add tp_clear slot and remove UB casts
lysnikolaou 011ca83
Apply Hugo's suggestions from code review
lysnikolaou 1379756
Add empty line to CODEOWNERS
lysnikolaou 4d1f2a5
Add news blurb
lysnikolaou 8842739
t-strings: Various changes (#74)
AA-Turner cf56234
Merge branch 'main' into tstrings
lysnikolaou 280e90e
Merge branch 'main' into tstrings
AA-Turner 051e8eb
Add pickle support for tstrings (#75)
sobolevn aa7c603
Merge branch 'main' into tstrings
lysnikolaou ce78496
Address feedback; fix template_values_get and conversion
lysnikolaou 8468e10
Merge branch 'main' into tstrings
lysnikolaou 9cee9ff
Merge branch 'main' into tstrings
lysnikolaou 0303c25
Add snippets to Lib/test/test_ast/snippets.py
lysnikolaou 6edaba0
Merge branch 'main' into tstrings
sobolevn ab9026f
Remove _templatelib extension
lysnikolaou 48f771b
Change __reduce__ flags to METH_NOARGS
lysnikolaou 0b1aef9
Merge branch 'main' into tstrings
lysnikolaou 8b0c132
Fix docs for TSTRING_MIDDLE
lysnikolaou b35ba13
Merge branch 'main' into tstrings
lysnikolaou 44749c7
Fix ERROR_IF
lysnikolaou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add templatelib module & clean-up types/objects etc.
- Loading branch information
commit 499d70caaa9ee94a6462a3740fbfe9322c285699
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from _templatelib import Template, Interpolation | ||
|
||
__all__ = ['Template', 'Interpolation'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* interpreter-internal types for templatelib */ | ||
|
||
#ifndef Py_BUILD_CORE | ||
#define Py_BUILD_CORE | ||
#endif | ||
|
||
#include "Python.h" | ||
#include "pycore_template.h" | ||
#include "pycore_interpolation.h" | ||
|
||
static int | ||
_templatelib_exec(PyObject *m) | ||
{ | ||
if (PyModule_AddObjectRef(m, "Template", (PyObject *)&_PyTemplate_Type) < 0) { | ||
return -1; | ||
} | ||
if (PyModule_AddObjectRef(m, "Interpolation", (PyObject *)&_PyInterpolation_Type) < 0) { | ||
return -1; | ||
} | ||
return 0; | ||
} | ||
|
||
PyDoc_STRVAR(_templatelib_doc, | ||
"Interpreter-internal types for t-string templates.\n"); | ||
|
||
static struct PyModuleDef_Slot _templatelib_slots[] = { | ||
{Py_mod_exec, _templatelib_exec}, | ||
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED}, | ||
{Py_mod_gil, Py_MOD_GIL_NOT_USED}, | ||
{0, NULL} | ||
}; | ||
|
||
static struct PyModuleDef _templatemodule = { | ||
PyModuleDef_HEAD_INIT, | ||
"_templatelib", | ||
_templatelib_doc, | ||
0, | ||
NULL, | ||
_templatelib_slots, | ||
NULL, | ||
NULL, | ||
NULL | ||
}; | ||
|
||
PyMODINIT_FUNC | ||
PyInit__templatelib(void) | ||
{ | ||
return PyModuleDef_Init(&_templatemodule); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.