Comments (3)
In general, Python does not do type checking just to show special error messages. If you pass in wrong data to something it might fail in weird ways at a weird spot. This filter isn't special in this regard.
from jinja.
@davidism If you look through the code, you have yourself already added a number of FilterArgumentExceptions
—correctly, according to good design—to ensure that failures are graceful. Also, the idea that Python programmers normally don't bother to handle their exceptions and just let things blow up confusingly is .... not true.
from jinja.
Here's the standard library's own indent
function, failing on invalid input without talking about str
. Most other functions result in similar behavior. Convince the cpython maintainers that they should add runtime type checks for the arguments of each function they maintain, and I'll consider adding them all over the place in Jinja too.
>>> import textwrap
>>> textwrap.indent({}, " ")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/textwrap.py", line 488, in indent
return ''.join(prefixed_lines())
File "/usr/local/lib/python3.10/textwrap.py", line 486, in prefixed_lines
for line in text.splitlines(True):
AttributeError: 'dict' object has no attribute 'splitlines'
from jinja.
Related Issues (20)
- Autoescape does not work well across blocks/inheritance
- Test failures with Python 3.13.0a1 HOT 3
- Property Template::is_up_to_date breaks type hint contract HOT 2
- NativeEnvironment casts integer strings to integer -- intended behavior? HOT 2
- Otera, a Better name than jinja.. HOT 1
- Misleading error when attribute in getitem(obj, attr) throws AttributeError HOT 7
- Change github link to ssh in "contributing" docs HOT 3
- Help improve Syntax Highlight for Monaco-Editor HOT 1
- The `int` filter throws `OverflowError` when the incoming string looks like scientific notation HOT 3
- Most basic Jinja function is inconsistent / crashes if the template has `{{ obj.property }}` elements, and `obj` is `None` or property does not exist HOT 2
- Introducing `NeverUndefined` HOT 3
- Leading newline after `trans` block with Jinja trim options results in translation lookup failure HOT 1
- test_striptags regressed with markupsafe 2.1.4 HOT 1
- Is it not possible to utilize a test adorned with the @pass_context decorator in the select function?
- add sort_keys argument to `tojson` filter HOT 2
- `tojson` always do autoescape HOT 2
- Native types in macros works for list but does not work for int HOT 2
- Template globals not visible in {% import %}'ed file when it's {% include %}'ed by another file HOT 2
- Flake8 error B036 reported by updated flake8-bugbear version HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jinja.