Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 2to3 - do not remove unicode prefixes

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)?

like image 536
Mr_and_Mrs_D Avatar asked Apr 18 '26 17:04

Mr_and_Mrs_D


1 Answers

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.

like image 65
Keldorn Avatar answered Apr 21 '26 09:04

Keldorn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!