pytest-dev / iniconfig

MIT License
58 stars 31 forks source link

Occurred 'cp949' error in IniConfig class #36

Closed melemo2 closed 2 years ago

melemo2 commented 2 years ago

@RonnyPfannschmidt image

I solved that issue #37

f = open(self.path) -> f = open(self.path, encoding='utf-8')
RonnyPfannschmidt commented 2 years ago

@melemo2 please elaborate on the python version involved

im happy to add a sane or configriuable default, but im slightly hesitant to just put that in as is (we have had issues with people using their native language encoding instead of utf8 before)

melemo2 commented 2 years ago

@RonnyPfannschmidt python version is 3.9.7 Detailed error msg and call stack is here https://github.com/scikit-learn/scikit-learn/issues/21933 I don't know why error occurred.. should I close this issue?

RonnyPfannschmidt commented 2 years ago

i believe this needs addressing, based on the links i'm also under the impression this happened to youu by accident as your editor use utf8 and your system encoding isnt

i should ensure we open files more safely later on

melemo2 commented 2 years ago

@RonnyPfannschmidt thanks for your comment I think you're right :) It would be better to support both none and utf-8. by handling an 'UnicodeDecodeError' Exception

Fengjun-Wang commented 2 years ago

Hi @RonnyPfannschmidt and @melemo2 ,

If we can provide options on the encoding format, it could resolve problems for developer who are using Windows as development os. For example, as melemo2 mentioned, the scikit-learn has a "setup.cfg" file which is encoded as "utf8", however, some Windows os has default encoding cp936.

My idea is we can provide an additional param whose default value is utf-8, at https://github.com/pytest-dev/iniconfig/blob/master/src/iniconfig/__init__.py#L48 What do you think?

@melemo2 are you still working on MRG #37 ?

melemo2 commented 2 years ago

@Fengjun-Wang

nope. I'll close it I mentioned problem already had been solved by just reinstall a project, so I'm not interested this issue.

but I think it's easier to handle exceptions than using parameter cuz If we add a parameter then another huge projects need to be modified :)