3

I am converting a legacy codebase to python3 and do some dry runs of 2to3. 2to3 removes the u'' prefix from unicode literals creating a lot of noise in the diffs. Is there a way to disable this (as u'my string' is valid py3 syntax)?

Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361

2 Answers2

2

From the help:

2to3 --help
...
  -x NOFIX, --nofix=NOFIX
                        Prevent a transformation from being run
  -l, --list-fixes      List available transformations
...

With --list-fixes, we find the transformation to ignore, unicode.

Result: 2to3 --nofix=unicode.

Keldorn
  • 1,980
  • 15
  • 25
0

According to https://docs.python.org/2/library/2to3.html, you can exclude certain set of fixers by -x option.

Perhaps the following would do what you want.

2to3 -x unicode example.py
Kota Mori
  • 6,510
  • 1
  • 21
  • 25