Describe the bug
When the python option PYTHONWARNDEFAULTENCODING is set as described on https://docs.python.org/3/library/io.html#opt-in-encodingwarning
/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/application-7pVymVLv-py3.11/lib/python3.11/site-packages/alembic/config.py:204: EncodingWarning: 'encoding' argument not specified
file_config.read([self.config_file_name])
Expected behavior
Alembic will explicitly specify the encoding to use when reading the configuration file. Per https://docs.python.org/3/library/io.html#opt-in-encodingwarning, the recommendation would be to use "utf-8".
To Reproduce
Run an alembic migration with the environment variablePYTHONWARNDEFAULTENCODING set to any value. In my testing, I am using 1 as my value.
Error
/Users/kkirsche/Library/Caches/pypoetry/virtualenvs/application-7pVymVLv-py3.11/lib/python3.11/site-packages/alembic/config.py:204: EncodingWarning: 'encoding' argument not specified
file_config.read([self.config_file_name])
Versions.
- OS:
macOS 13.4.1 (c) (22F770820d)
- Python:
Python 3.11.4
- Alembic:
1.11.1
- SQLAlchemy:
2.0.18[mysql, mypy]
- Database:
mariadb from 11.0.2-MariaDB, client 15.2 for osx10.18 (arm64) using EditLine wrapper
- DBAPI:
mysqlclient 2.2.0
Additional context
The read function passes the encoding to https://docs.python.org/3/library/io.html#io.text_encoding
For me, this returns "locale" which may make sense to use if you are not comfortable with "utf-8". "locale" which, as I understand it, uses https://docs.python.org/3/library/locale.html to detect the encoding settings of the caller's machine.
Thank you for your consideration
Have a nice day!
Describe the bug
When the python option
PYTHONWARNDEFAULTENCODINGis set as described on https://docs.python.org/3/library/io.html#opt-in-encodingwarningExpected behavior
Alembic will explicitly specify the encoding to use when reading the configuration file. Per https://docs.python.org/3/library/io.html#opt-in-encodingwarning, the recommendation would be to use
"utf-8".To Reproduce
Run an alembic migration with the environment variable
PYTHONWARNDEFAULTENCODINGset to any value. In my testing, I am using1as my value.Error
Versions.
macOS 13.4.1 (c) (22F770820d)Python 3.11.41.11.12.0.18[mysql, mypy]mariadb from 11.0.2-MariaDB, client 15.2 for osx10.18 (arm64) using EditLine wrappermysqlclient 2.2.0Additional context
The
readfunction passes the encoding to https://docs.python.org/3/library/io.html#io.text_encodingFor me, this returns
"locale"which may make sense to use if you are not comfortable with"utf-8"."locale"which, as I understand it, uses https://docs.python.org/3/library/locale.html to detect the encoding settings of the caller's machine.Thank you for your consideration
Have a nice day!