Skip to content
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

pyo3_runtime.PanicException: assertion failed: self.is_char_boundary(new_len) #618

Closed
maingoh opened this issue Oct 25, 2024 · 4 comments · Fixed by #619
Closed

pyo3_runtime.PanicException: assertion failed: self.is_char_boundary(new_len) #618

maingoh opened this issue Oct 25, 2024 · 4 comments · Fixed by #619

Comments

@maingoh
Copy link

maingoh commented Oct 25, 2024

This schema seem to raise a PanicException:

>>> Draft202012Validator({'type': 'string', 'pattern': 'aaaaaaaèaaéaaaaéè'})
thread '<unnamed>' panicked at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/alloc/src/string.rs:1410:13:
assertion failed: self.is_char_boundary(new_len)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pyo3_runtime.PanicException: assertion failed: self.is_char_boundary(new_len)

It seem more or less related to the accents/non-ascii chars but in some other configuration it works.

Not working:

Draft202012Validator({'type': 'string', 'pattern': 'èééaaaaaaaaaaaaaè'})

Working:

Draft202012Validator({'type': 'string', 'pattern': 'èééaè'})
@Stranger6667
Copy link
Owner

Thank you for reporting this! I am going to take a look at it today

@Stranger6667
Copy link
Owner

The cause is that I've put the limit in bytes rather than in characters on the schema representation inside __repr__. I wanted to drop it anyway as it is a performance foot gun (the whole schema is serialized to json first). Will issue a new release soon

@maingoh
Copy link
Author

maingoh commented Oct 25, 2024

Thank you @Stranger6667 for the reactivity !

@Stranger6667
Copy link
Owner

Fixed in 0.25.1 (will be released as soon as the build is done)

You are very welcome :)

Please, don't hesitate to reach out if something won't work as expected with jsonschema :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants