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

UnicodeEncodeError in core.py #299

Closed
milanbalazs opened this issue Jan 16, 2023 · 3 comments
Closed

UnicodeEncodeError in core.py #299

milanbalazs opened this issue Jan 16, 2023 · 3 comments

Comments

@milanbalazs
Copy link
Contributor

milanbalazs commented Jan 16, 2023

I got UnicodeEncodeError exception during the Vulture analysis.

Traceback:

Traceback (most recent call last):
    File "/ws/venv3_x/bin/vulture", line 8, in <module>
      sys.exit(main())
    File "/ws/venv3_x/lib/python3.6/site-packages/vulture/core.py", line 710, in main
      make_whitelist=config["make_whitelist"],
    File "/ws/venv3_x/lib/python3.6/site-packages/vulture/core.py", line 334, in report
      else item.get_report(add_size=sort_by_size)
  UnicodeEncodeError: 'latin-1' codec can't encode characters in position 84-90: ordinal not in range(256)

My command:

vulture "--exclude" "venv2/,venv3_*,*update_repo.py" "."

Used vulture version in requirements.txt file:

  • vulture==2.5

Used Python version:

  • 3.6.6

It's possible that my codebase contains special characters but it's hard to debug it because I analyze ~1000 Python files in the same time (And the provided Exception doesn't contain any reference for the problematic file).

I think it would be nice to improve the Encoding in the core.py or at least handle the exception and throw a more talkative exception (perhaps with the name/path of the problematic file)

Thank you in advance!

@milanbalazs
Copy link
Contributor Author

I have changed the venv3_* pattern to *venv3_* in the --exclude parameter and now the analysis works as expected. I have removed all non-ascii characters from my code-base so in my opinion the faulty file is in the Virtual Environment.

On the other hand, I still think the Exception should me more specific/talkative and the error should be handled.

@jendrikseipp
Copy link
Owner

Thanks for the report! I agree that the error message should include the file name. Would you care to prepare a PR for this?

@milanbalazs
Copy link
Contributor Author

Sure, I will create a PR for it!

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

No branches or pull requests

2 participants