Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
103f17ef
Commit
103f17ef
authored
Nov 16, 2012
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#16478: use floor division in tabnanny and fix a ResourceWarning. Patch by Serhiy Storchaka.
parent
b37ac8ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
Lib/tabnanny.py
Lib/tabnanny.py
+11
-8
No files found.
Lib/tabnanny.py
View file @
103f17ef
...
...
@@ -126,6 +126,9 @@ def check(file):
else
:
print
(
file
,
badline
,
repr
(
line
))
return
finally
:
f
.
close
()
if
verbose
:
print
(
"%r: Clean bill of health."
%
(
file
,))
...
...
@@ -185,21 +188,21 @@ class Whitespace:
# count, il = self.norm
# for i in range(len(count)):
# if count[i]:
# il = il + (i/tabsize + 1)*tabsize * count[i]
# il = il + (i/
/
tabsize + 1)*tabsize * count[i]
# return il
# quicker:
# il = trailing + sum (i/ts + 1)*ts*count[i] =
# trailing + ts * sum (i/ts + 1)*count[i] =
# trailing + ts * sum i/ts*count[i] + count[i] =
# trailing + ts * [(sum i/ts*count[i]) + (sum count[i])] =
# trailing + ts * [(sum i/ts*count[i]) + num_tabs]
# and note that i/ts*count[i] is 0 when i < ts
# il = trailing + sum (i/
/
ts + 1)*ts*count[i] =
# trailing + ts * sum (i/
/
ts + 1)*count[i] =
# trailing + ts * sum i/
/
ts*count[i] + count[i] =
# trailing + ts * [(sum i/
/
ts*count[i]) + (sum count[i])] =
# trailing + ts * [(sum i/
/
ts*count[i]) + num_tabs]
# and note that i/
/
ts*count[i] is 0 when i < ts
count
,
trailing
=
self
.
norm
il
=
0
for
i
in
range
(
tabsize
,
len
(
count
)):
il
=
il
+
i
/
tabsize
*
count
[
i
]
il
=
il
+
i
/
/
tabsize
*
count
[
i
]
return
trailing
+
tabsize
*
(
il
+
self
.
nt
)
# return true iff self.indent_level(t) == other.indent_level(t)
...
...
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