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

A UnicodeDecodeError happened when install tortoise-orm in non-utf8 environment #180

Closed
zkonge opened this issue Sep 3, 2019 · 5 comments · Fixed by #181
Closed

A UnicodeDecodeError happened when install tortoise-orm in non-utf8 environment #180

zkonge opened this issue Sep 3, 2019 · 5 comments · Fixed by #181

Comments

@zkonge
Copy link

zkonge commented Sep 3, 2019

Describe the bug

>>> verstrline = open("tortoise/__init__.py", "rt").read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9131: illegal multibyte sequence

To Reproduce
In tortoise/__init__.py line 225

...
 and the same output as ``describe_model(…)`` as value:
...

Replace "…" with three dots "..." which are ASCII characters.

Expected behavior
Install successfully

Additional context
None

@grigi
Copy link
Member

grigi commented Sep 3, 2019

Is this a non-unicode environment? (as in ASCII or Latin-x)

@zkonge
Copy link
Author

zkonge commented Sep 3, 2019

I use it in powershell and my Windows system language is Chinese. It use GBK encoding normally.

@grigi
Copy link
Member

grigi commented Sep 3, 2019

I really thought that Windows handles Chinese in unicode... Well, now I have learnt it does not.
Could you please see if any OTHER characters are causing problems for you? I only found the one you referenced when I looked just now.

@grigi
Copy link
Member

grigi commented Sep 3, 2019

Please test if pip install https://github.com/tortoise/tortoise-orm/archive/update_queryset.zip fixes it for you?

@zkonge
Copy link
Author

zkonge commented Sep 3, 2019

It works.

@grigi grigi closed this as completed in #181 Sep 5, 2019
grigi added a commit that referenced this issue Sep 5, 2019
- Fixed installing Tortoise-ORM in non-unicode systems. (#180)
- `queryset.update()` now correctly uses the DB-specific `to_db_value()`
- `fetch_related()` now correctly encodes non-integer keys.
- `ForeignKey` fields of type `UUIDField` are now escaped consistently.
- Pre-generated ForeignKey fields (e.g. UUIDField) is now checked for persistence correctly.
- Duplicate M2M `.add()` now checks using consistent field encoding.
- `source_field` Fields are now handled correctly for ordering.
- `source_field` Fields are now handled correctly for updating.
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