[syntax error] Fix a crash when the line and column can't be retrieved#7097
Conversation
DanielNoord
left a comment
There was a problem hiding this comment.
One of the issues with SyntaxErrors is that their messages changes across versions and implementations. They don't really lend themselves well for our functional test framework.
Perhaps an unittest would work better here?
865b1b8 to
9266868
Compare
This comment has been minimized.
This comment has been minimized.
Pull Request Test Coverage Report for Build 2765124596
💛 - Coveralls |
dede3cc to
319a5c9
Compare
|
I'm back with a new machine with python 3.10 / ubuntu 22.04 😄 everything is nicer, there's progress bars in pip ! |
This comment has been minimized.
This comment has been minimized.
|
@Pierre-Sassoulas Do we understand the primer results? |
|
No idea, I think it's a primer cache bug ? |
|
It's weird as you don't have a |
|
It seems I was already based on b9419a2 which is the latest commit from main so I don't know what I can do. |
|
See #7156 (comment). |
This comment has been minimized.
This comment has been minimized.
b652f93 to
dbaa36c
Compare
This comment has been minimized.
This comment has been minimized.
|
We can't reproduce the syntax error with functional tests, will need to create a unit test with a mock, but this can wait 2.15.0 |
This comment has been minimized.
This comment has been minimized.
| from unittest.mock import patch | ||
|
|
||
| import pytest | ||
| from astroid import PY310_PLUS |
There was a problem hiding this comment.
Good catch, I imported the wrong one 😄
| @pytest.mark.skipif( | ||
| PY310_PLUS, reason="Not a syntax error for python 3.10 or superior" | ||
| ) | ||
| def test_astroid_syntax_error(self, tmp_path) -> None: |
There was a problem hiding this comment.
| def test_astroid_syntax_error(self, tmp_path) -> None: | |
| def test_astroid_syntax_error(self, tmp_path: TempPathFixture?) -> None: |
There was a problem hiding this comment.
@Pierre-Sassoulas this was a question. Sorry should have been clearer.
There was a problem hiding this comment.
Hurgh, no that's my bad. It's a pathlib.Path.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
0a15815 to
15c3d9f
Compare
|
This is the same error than we have on other branches... I wonder if we should deactivate the tests for pypy. It's likely we'll never think of reactivating it if we do that. |
This comment has been minimized.
This comment has been minimized.
| line=getattr(ex.error, "lineno", 0), | ||
| col_offset=getattr(ex.error, "offset", None), | ||
| args=str(ex.error), | ||
| args=f"Parsing Python code failed:\n{ex.error}", |
There was a problem hiding this comment.
This seems unnecessary? The message is already called syntax-error?
There was a problem hiding this comment.
There's other syntax error for example when there's a syntax error in something we want to import. I think it does not hurt to be explicit.
There was a problem hiding this comment.
I don't mind too much, but I don't really understand what it adds. Seems like it just adds unnecessary verbosity. In IDEs that might actually reduce usability.
But if you think this is better please go ahead!
There was a problem hiding this comment.
I removed the line break that could be problematic in IDE.
This comment has been minimized.
This comment has been minimized.
39953bf to
1af2c02
Compare
|
🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉 This comment was generated for commit 1af2c02 |
Type of Changes
Description
Closes #3860