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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

- Correct stringified name of ParserError exception.

## [0.1.0a6] - 2024-11-05

- Render dates in YYYY-MM-DD format.
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ use unic_langid::LanguageIdentifier;

use pyo3::create_exception;

create_exception!(rustfluent, PyParserError, pyo3::exceptions::PyException);
create_exception!(rustfluent, ParserError, pyo3::exceptions::PyException);

#[pymodule]
fn rustfluent(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<Bundle>()?;
m.add("ParserError", m.py().get_type_bound::<PyParserError>())?;
m.add("ParserError", m.py().get_type_bound::<ParserError>())?;
Ok(())
}

Expand Down Expand Up @@ -43,7 +43,7 @@ impl Bundle {
Ok(resource) => resource,
Err(error) => {
if strict {
return Err(PyParserError::new_err(format!(
return Err(ParserError::new_err(format!(
"Error when parsing {}.",
file_path
)));
Expand Down
4 changes: 4 additions & 0 deletions tests/test_python_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,7 @@ def test_raises_parser_error_on_file_that_contains_errors_in_strict_mode():
filename = str(data_dir / "errors.ftl")
with pytest.raises(fluent.ParserError, match=re.escape(f"Error when parsing {filename}.")):
fluent.Bundle("fr", [filename], strict=True)


def test_parser_error_str():
assert str(fluent.ParserError) == "<class 'rustfluent.ParserError'>"