Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
my2to3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
my2to3
Commits
186b2cb6
Commit
186b2cb6
authored
Jul 15, 2020
by
Bryton Lacquement
🚪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
division_support: record when there's no data
parent
f5adf0ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
11 deletions
+16
-11
my2to3/fixes/fix_division_support.py
my2to3/fixes/fix_division_support.py
+16
-11
No files found.
my2to3/fixes/fix_division_support.py
View file @
186b2cb6
...
...
@@ -13,18 +13,21 @@ insert_support = create_table("division_support", "filename", "lineno", "id", "s
def
analyze_data
(
data
):
if
not
data
:
return
False
,
"no data"
try
:
types
=
data2types
(
data
)
except
Exception
as
e
:
# Probably, one type is not a builtins
return
False
,
"unknown"
else
:
if
len
(
types
)
==
1
:
dividend
,
divisor
=
types
[
0
]
if
dividend
is
divisor
is
int
:
return
True
,
"automatic"
return
False
,
"manual"
if
len
(
types
)
==
1
:
dividend
,
divisor
=
types
[
0
]
if
dividend
is
divisor
is
int
:
return
True
,
"automatic"
return
False
,
"manual"
class
FixDivisionSupport
(
BaseFix
):
...
...
@@ -39,11 +42,13 @@ class FixDivisionSupport(BaseFix):
def
transform
(
self
,
node
,
results
):
filename
,
lineno
,
id_
=
[
l
.
value
for
l
in
node
.
children
[
1
].
children
[
1
].
children
[:
-
4
:
2
]]
data
=
get_data
(
"division_trace"
,
[
"dividend_type"
,
"divisor_type"
],
dict
(
filename
=
filename
,
lineno
=
lineno
,
id
=
id_
))
if
not
data
:
return
should_change
,
status
=
analyze_data
(
data
)
should_change
,
status
=
analyze_data
(
get_data
(
"division_trace"
,
[
"dividend_type"
,
"divisor_type"
],
dict
(
filename
=
filename
,
lineno
=
lineno
,
id
=
id_
)
)
)
insert_support
(
filename
,
lineno
,
id_
,
status
)
if
should_change
:
add_future
(
node
,
'division'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment