facebookarchive / codemod

Codemod is a tool/library to assist you with large-scale codebase refactors that can be partially automated but still require human oversight and occasional intervention. Codemod was developed at Facebook and released as open source.
Apache License 2.0
4.11k stars 198 forks source link

Report filename with invalid encoding #112

Open ezyang opened 4 years ago

ezyang commented 4 years ago

I'm trying to run codemod on my codebase and it is choking with:

Traceback (most recent call last):
  File "/home/ezyang/local/pytorch-tmp-env/bin/codemod", line 8, in <module>
    sys.exit(main())
  File "/home/ezyang/local/pytorch-tmp-env/lib/python3.7/site-packages/codemod/base.py", line 1025, in main
    run_interactive(**options)
  File "/home/ezyang/local/pytorch-tmp-env/lib/python3.7/site-packages/codemod/base.py", line 167, in run_interactive
    for patch in suggestions:
  File "/home/ezyang/local/pytorch-tmp-env/lib/python3.7/site-packages/codemod/base.py", line 442, in generate_patches
    lines = list(open(path))
  File "/home/ezyang/local/pytorch-tmp-env/lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 16: invalid continuation byt

It would be very nice if it told me what file had the bad encoding!

kir0ul commented 3 years ago

I have the exact same problem :slightly_frowning_face:

donnlee commented 3 years ago

As workaround, I did:

   git clone https://github.com/facebook/codemod.git
   cd codemod/
   python setup.py install --user

because there was a patch made in #93 that is not in the PyPi (pip install ...) version.