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

UnicodeDecodeError occurs when under windows environment. #205

Closed
auxo86 opened this issue Sep 28, 2019 · 0 comments
Closed

UnicodeDecodeError occurs when under windows environment. #205

auxo86 opened this issue Sep 28, 2019 · 0 comments

Comments

@auxo86
Copy link

auxo86 commented Sep 28, 2019

While under windows 10, I have got this error:

File "J:\測試\venv\lib\site-packages\dotenv\parser.py", line 41, in __init__
    self.string = stream.read()
UnicodeDecodeError: 'cp950' codec can't decode byte 0x98 in position 4: illegal multibyte sequence

I think dotenv try to get project path by

path = os.getcwd()

and under python3, the default encoding is utf-8.

Would you please modify the constructor of DotEnv() for us as below:

def __init__(self, dotenv_path, verbose=False, encoding=None):
	# type: (Union[Text, _PathLike, _StringIO], bool, Union[None, Text]) -> None
	self.dotenv_path = dotenv_path  # type: Union[Text,_PathLike, _StringIO]
	self._dict = None  # type: Optional[Dict[Text, Text]]
	self.verbose = verbose  # type: bool
	# self.encoding = encoding  # type: Union[None, Text] # <------ comment this line as change it as follows.
	if PY2:
		self.encoding = encoding  # type: Union[None, Text]
	else:
		self.encoding = 'utf-8'

Thanks for your help.

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

1 participant