[issue45736] 2to3 does not support integer division fixing

2021-11-06 Thread theeshallnotknowethme


New submission from theeshallnotknowethme :

Right now, 2to3 does not support integer division fixing. Supposing `test.py` 
is a file with these contents:
x = 2 ** 8 / 5 / 7

Here's an example:
C:\Users\admin> py -m lib2to3 test.py
RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: No files need to be modified.

--
components: 2to3 (2.x to 3.x conversion tool), Library (Lib)
messages: 405857
nosy: February291948
priority: normal
severity: normal
status: open
title: 2to3 does not support integer division fixing
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45736] 2to3 does not support integer division fixing

2021-11-06 Thread theeshallnotknowethme


Change by theeshallnotknowethme :


--
keywords: +patch
pull_requests: +27694
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29440

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45736] 2to3 does not support integer division fixing

2021-11-06 Thread theeshallnotknowethme


Change by theeshallnotknowethme :


--
type:  -> enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45736] 2to3 does not support integer division fixing

2021-11-06 Thread theeshallnotknowethme


theeshallnotknowethme  added the comment:

When 2to3 supports integer division fixing, there would be this behaviour:

- x = 2 ** 8 / 5 / 7
+ x = 2 ** 8 // 5 // 7

Basically convert any integer division to floor division. The PR I made only 
works for constant integers, and any improvement would be appreciated.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45736] 2to3 does not support integer division fixing

2021-11-06 Thread Eric V. Smith


Eric V. Smith  added the comment:

I think knowing that that's integer division is beyond what 2to3 can 
accomplish. Plus, with lib2to3 being deprecated, I don't think anyone's going 
to put any effort into this.

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45736] 2to3 does not support integer division fixing

2021-11-06 Thread theeshallnotknowethme


theeshallnotknowethme  added the comment:

I have put some effort to make it work for constant integers. So this

x = a ** 3 / 7

would not be changed, since it refers to a name whose value is not known.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45736] 2to3 does not support integer division fixing

2021-11-06 Thread theeshallnotknowethme


theeshallnotknowethme  added the comment:

A correction to the discussion: The PR I made only fixes CONSTANT integer 
division, not any other. The left and right operands are checked for 
non-constants and then are checked for integerness (specifically checks for 
`NOT A FLOAT`s). After both checks have passed, the division operator is turned 
into a floor division operator.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45736] 2to3 does not support integer division fixing

2021-11-06 Thread theeshallnotknowethme


Change by theeshallnotknowethme :


--
versions: +Python 3.11, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45736] 2to3 does not support integer division fixing

2021-11-06 Thread theeshallnotknowethme


Change by theeshallnotknowethme :


--
versions:  -Python 3.11, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45736] 2to3 does not support integer division fixing

2021-11-18 Thread Łukasz Langa

Łukasz Langa  added the comment:

We don't accept new features for 3.10 anymore, and since 2to3 is deprecated, we 
won't be updating it with new fixers and so on. It is pending removal in Python 
3.13.

Sorry, I understand this is a bummer but this part of Python hasn't seen 
serious development for the past few years and its parser is incompatible with 
modern 3.9+ code.

--
nosy: +lukasz.langa
resolution:  -> wont fix
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com