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
d3af6344
Commit
d3af6344
authored
Apr 05, 2012
by
R David Murray
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#14492: fix some bugs in Tools/scripts/pdeps.py.
Initial patch by Popa Claudiu.
parent
fee3fc74
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
5 deletions
+32
-5
Lib/test/test_tools.py
Lib/test/test_tools.py
+27
-0
Tools/scripts/pdeps.py
Tools/scripts/pdeps.py
+5
-5
No files found.
Lib/test/test_tools.py
View file @
d3af6344
...
@@ -6,8 +6,10 @@ Tools directory of a Python checkout or tarball, such as reindent.py.
...
@@ -6,8 +6,10 @@ Tools directory of a Python checkout or tarball, such as reindent.py.
import
os
import
os
import
sys
import
sys
import
imp
import
unittest
import
unittest
import
sysconfig
import
sysconfig
import
tempfile
from
test
import
support
from
test
import
support
from
test.script_helper
import
assert_python_ok
from
test.script_helper
import
assert_python_ok
...
@@ -72,6 +74,31 @@ class TestSundryScripts(unittest.TestCase):
...
@@ -72,6 +74,31 @@ class TestSundryScripts(unittest.TestCase):
import
analyze_dxp
import
analyze_dxp
class
PdepsTests
(
unittest
.
TestCase
):
@
classmethod
def
setUpClass
(
self
):
path
=
os
.
path
.
join
(
scriptsdir
,
'pdeps.py'
)
self
.
pdeps
=
imp
.
load_source
(
'pdeps'
,
path
)
@
classmethod
def
tearDownClass
(
self
):
if
'pdeps'
in
sys
.
modules
:
del
sys
.
modules
[
'pdeps'
]
def
test_process_errors
(
self
):
# Issue #14492: m_import.match(line) can be None.
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
fn
=
os
.
path
.
join
(
tmpdir
,
'foo'
)
with
open
(
fn
,
'w'
)
as
stream
:
stream
.
write
(
"#!/this/will/fail"
)
self
.
pdeps
.
process
(
fn
,
{})
def
test_inverse_attribute_error
(
self
):
# Issue #14492: this used to fail with an AttributeError.
self
.
pdeps
.
inverse
({
'a'
:
[]})
def
test_main
():
def
test_main
():
support
.
run_unittest
(
*
[
obj
for
obj
in
globals
().
values
()
support
.
run_unittest
(
*
[
obj
for
obj
in
globals
().
values
()
if
isinstance
(
obj
,
type
)])
if
isinstance
(
obj
,
type
)])
...
...
Tools/scripts/pdeps.py
View file @
d3af6344
...
@@ -76,10 +76,9 @@ def process(filename, table):
...
@@ -76,10 +76,9 @@ def process(filename, table):
nextline
=
fp
.
readline
()
nextline
=
fp
.
readline
()
if
not
nextline
:
break
if
not
nextline
:
break
line
=
line
[:
-
1
]
+
nextline
line
=
line
[:
-
1
]
+
nextline
if
m_import
.
match
(
line
)
>=
0
:
m_found
=
m_import
.
match
(
line
)
or
m_from
.
match
(
line
)
(
a
,
b
),
(
a1
,
b1
)
=
m_import
.
regs
[:
2
]
if
m_found
:
elif
m_from
.
match
(
line
)
>=
0
:
(
a
,
b
),
(
a1
,
b1
)
=
m_found
.
regs
[:
2
]
(
a
,
b
),
(
a1
,
b1
)
=
m_from
.
regs
[:
2
]
else
:
continue
else
:
continue
words
=
line
[
a1
:
b1
].
split
(
','
)
words
=
line
[
a1
:
b1
].
split
(
','
)
# print '#', line, words
# print '#', line, words
...
@@ -87,6 +86,7 @@ def process(filename, table):
...
@@ -87,6 +86,7 @@ def process(filename, table):
word
=
word
.
strip
()
word
=
word
.
strip
()
if
word
not
in
list
:
if
word
not
in
list
:
list
.
append
(
word
)
list
.
append
(
word
)
fp
.
close
()
# Compute closure (this is in fact totally general)
# Compute closure (this is in fact totally general)
...
@@ -123,7 +123,7 @@ def closure(table):
...
@@ -123,7 +123,7 @@ def closure(table):
def
inverse
(
table
):
def
inverse
(
table
):
inv
=
{}
inv
=
{}
for
key
in
table
.
keys
():
for
key
in
table
.
keys
():
if
not
inv
.
has_key
(
key
)
:
if
key
not
in
inv
:
inv
[
key
]
=
[]
inv
[
key
]
=
[]
for
item
in
table
[
key
]:
for
item
in
table
[
key
]:
store
(
inv
,
item
,
key
)
store
(
inv
,
item
,
key
)
...
...
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