refactoringtool: parseerror: bad input: type=22, value='='

  • Last Update :
  • Techknowledgy :

When running your code using Python 2, you'll get the following error:

  File "repo.py", line 5
  print(' ', file = sys.stderr) # this is a line that yields error ^
     SyntaxError: invalid syntax

E.g.

2 to3 - p yourfile.py

Suggestion : 2

This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide.

File a.py:

   -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
print("foo", end = 'bar') # ParseError
   -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

I think the error is caused by arguments in the Python 3 print()
function(e.g.end, sep) that are not ignored by 2 to3, and(possibly) treated like Python 2 code.

Console stuff:

   -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
   $ pip install 2 to3
Requirement already satisfied: 2 to3 in .\python37\ lib\ site - packages(1.0)

$ 2 to3.\a.py
   ...
   RefactoringTool: Can 't parse .\a.py: ParseError: bad input: type=22, value=' = ', context=('
', (1, 16))
...
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
I 'm not sure I understand the report: 2to3 expects a valid Python 2 file as input, and the file a.py isn'
t a valid Python 2 file: the `print`
line is a SyntaxError in the absence of a `from __future__ import print_function`.

So yes, this * is * being treated like Python 2 code, but that 's what 2to3 is designed to do.

Can you say what you expected to happen here ?
I was expecting that like other Python 3 code, since it is already in Python 3, it would not parse it like Python 2.
I 'm still confused: the main purpose of 2to3 is to take Python 2 code and turn it into Python 3 code. The docs[1] are fairly unambiguous here:

   >
   2 to3 is a Python program that reads Python 2. x source code and applies a series of fixers to transform it into valid Python 3. x code.

So expecting 2 to3 * not * to parse code as though it 's Python 2 code seem odd.

[1] https: //docs.python.org/3.7/library/2to3.html
Closing.2 to3 is working as designed here.

Suggestion : 3

Re: Still, not fully compatible with Python3??? From: JIA Pei,Subject: Re:Still, not fully compatible with Python3???,Re: Still, not fully compatible with Python3??? From: Bálint Réczey,Still, not fully compatible with Python3??? From: JIA Pei


Hi!
   Meld 3.17 is a pure python3 application, that expected to be just used with python3 without any conversions
like 2 to3.It doesn 't use compatibility packages like "six" and cannot be used with python2.

Meld 3.16.x from the other hand is a pure python2 application.I don 't think that it is designed to be 
converted with 2 to3, so
if it had somehow launched with python3 after such conversion, it may be extremely
buggy even in common use cases.Meld 3.17 is much better choice
for running under python3.
2._
Even meld 3.17. 0 also give me the following error messages by command "2to3"but, acceptable for both
meld3.17.0 and meld3.16.4, because both are able to run with python3 .... ^_^
As long as it does NOT require me to shift from python3 to python2, that will be OK for me... ^_^

RefactoringTool: There were 13 errors:

RefactoringTool: Can't parse COPYING: ParseError: bad input: type=5, value=u' ', context=(u'', (1, 0))

RefactoringTool: Can't parse MANIFEST.in: ParseError: bad input: type=1, value=u'po', context=(u' ', (1,
18))

RefactoringTool: Can't parse meld/meldapp.py: ParseError: bad input: type=22, value=u'=', context=('',
(214, 48))

RefactoringTool: Can't parse meld/misc.py: ParseError: bad input: type=22, value=u'=', context=('', (204,
62))

RefactoringTool: Can't parse meld/vcview.py: ParseError: bad input: type=22, value=u'=', context=('', (66,
22))

RefactoringTool: Can't parse meld.1: ParseError: bad input: type=1, value=u'TH', context=('', (1, 1))

RefactoringTool: Can't parse meld.doap: ParseError: bad input: type=20, value=u'<', context=(u'', (1, 0)) RefactoringTool: Can't parse NEWS: ParseError: bad input: type=1, value=u'meld', context=(u' ', (2, 11))

RefactoringTool: Can' t parse PKG-INFO: ParseError: bad input: type=11, value=u':', context=('', (1, 16)) RefactoringTool: Can't parse README: ParseError: bad input: type=1, value=u'Meld', context=(u' ', (2, 6))

RefactoringTool: Can' t parse ./meld/misc.py: ParseError: bad input: type=22, value=u'=', context=('', (204, 
62))

RefactoringTool: Can' t parse ./meld/meldapp.py: ParseError: bad input: type=22, value=u'=', context=('', 
(214, 48))

RefactoringTool: Can' t parse ./meld/vcview.py: ParseError: bad input: type=22, value=u'=', context=('', 
(66, 22))

On Mon, Jan 30, 2017 at 10:03 AM, Bálint Réczey <balint balintreczey hu> wrote:
3._
Hi Pei,

Usually it is a good idea to read back some emails from public email

lists before posting questions.

Like this one ;-) :

https://mail.gnome.org/archives/meld-list/2016-December/msg00003.html

Cheers,

Balint

2017-01-30 18:57 GMT+01:00 JIA Pei <jp4work gmail com>:
6._
Hey, Kai:
1._
Even meld 3.17. 0 also give me the following error messages by command "2to3"but, acceptable for both
meld3.17.0 and meld3.16.4, because both are able to run with python3 .... ^_^
As long as it does NOT require me to shift from python3 to python2, that will be OK for me... ^_^

RefactoringTool: There were 13 errors:

RefactoringTool: Can't parse COPYING: ParseError: bad input: type=5, value=u' ', context=(u'', (1, 0))

RefactoringTool: Can't parse MANIFEST.in: ParseError: bad input: type=1, value=u'po', context=(u' ', (1,
18))

RefactoringTool: Can't parse meld/meldapp.py: ParseError: bad input: type=22, value=u'=', context=('',
(214, 48))

RefactoringTool: Can't parse meld/misc.py: ParseError: bad input: type=22, value=u'=', context=('', (204,
62))

RefactoringTool: Can't parse meld/vcview.py: ParseError: bad input: type=22, value=u'=', context=('', (66,
22))

RefactoringTool: Can't parse meld.1: ParseError: bad input: type=1, value=u'TH', context=('', (1, 1))

RefactoringTool: Can't parse meld.doap: ParseError: bad input: type=20, value=u'<', context=(u'', (1, 0)) RefactoringTool: Can't parse NEWS: ParseError: bad input: type=1, value=u'meld', context=(u' ', (2, 11))

RefactoringTool: Can' t parse PKG-INFO: ParseError: bad input: type=11, value=u':', context=('', (1, 16)) RefactoringTool: Can't parse README: ParseError: bad input: type=1, value=u'Meld', context=(u' ', (2, 6))

RefactoringTool: Can' t parse ./meld/misc.py: ParseError: bad input: type=22, value=u'=', context=('', (204, 
62))

RefactoringTool: Can' t parse ./meld/meldapp.py: ParseError: bad input: type=22, value=u'=', context=('', 
(214, 48))

RefactoringTool: Can' t parse ./meld/vcview.py: ParseError: bad input: type=22, value=u'=', context=('', 
(66, 22))

On Mon, Jan 30, 2017 at 10:03 AM, Bálint Réczey <balint balintreczey hu> wrote:
2._
Hey, Kai:
6._
1._
3._
Hey, Kai:
5._
7._
I downloaded meld 3.16 .4.when I tried to convert all.py files using 2 to3,
Hey, Kai:
I downloaded meld 3.16 .4.when I tried to convert all.py files using 2 to3,

Suggestion : 4

Apache server search for directory instead of route,(Flutter, dart) How to select specific Card in in Listview and toggle an icon color from white to green,Getting the values of an object before adding it to csv,Error tokenizing data. C error: Expected 1 fields in line 7, saw 2

I tried running 2to3 on a python file anycodings_python-2to3 however it is failing with following error, anycodings_python-2to3 i am not able to understand where exactly in anycodings_python-2to3 the problem any help is appreciated.

[adsf @localhost direct] $ 2 to3. / views / statusformatter.py
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
RefactoringTool: Can 't parse ./views/statusformatter.py: ParseError:
bad input: type = 22, value = u '=', context = ('', (338, 31))
RefactoringTool: No files need to be modified.
RefactoringTool: There was 1 error:
   RefactoringTool: Can 't parse ./views/statusformatter.py:
ParseError: bad input: type = 22, value = u '=', context = ('', (338, 31))