Nilesh Patra pushed to branch master at lintian / lintian
Commits:
-
69861ea9
by Louis-Philippe Véronneau at 2024-07-31T14:43:17+00:00
6 changed files:
- lib/Lintian/Check/Languages/Python/StdlibDeprecation.pm
- t/recipes/checks/languages/python/stdlib-deprecation/python-imports-asyncore/build-spec/orig/from.py
- t/recipes/checks/languages/python/stdlib-deprecation/python-imports-asyncore/build-spec/orig/import.py
- t/recipes/checks/languages/python/stdlib-deprecation/python-imports-asyncore/eval/hints
- t/recipes/checks/languages/python/stdlib-deprecation/python-imports-distutils/build-spec/orig/import.py
- t/recipes/checks/languages/python/stdlib-deprecation/python-imports-distutils/eval/hints
Changes:
| ... | ... | @@ -94,7 +94,19 @@ sub visit_patched_files { |
| 94 | 94 | $pointer,
|
| 95 | 95 | $library,
|
| 96 | 96 | "(deprecated in Python $deprecated, removed in Python $removed)"
|
| 97 | - ) if $line =~ m{from $library} || $line =~ m{import $library};
|
|
| 97 | + )
|
|
| 98 | + # from library import foo
|
|
| 99 | + # from library.sub import foo
|
|
| 100 | + # this also won't match "from library2"
|
|
| 101 | + if $line =~ m{^from $library(\s||\..+ import)}
|
|
| 102 | + # import foo, library, bar
|
|
| 103 | + ||$line =~ m{^import.+$library,}
|
|
| 104 | + # import library
|
|
| 105 | + # import library.sub
|
|
| 106 | + # import foo, library
|
|
| 107 | + # import foo, library.sub
|
|
| 108 | + # import foo, library.sub, bar
|
|
| 109 | + ||$line =~ m{^import.+$library(,||\..+)?$};
|
|
| 98 | 110 | }
|
| 99 | 111 | |
| 100 | 112 | }continue {
|
| 1 | 1 | #!/usr/bin/python3
|
| 2 | 2 | |
| 3 | +from asyncore import socket_map
|
|
| 4 | + |
|
| 5 | +# This should not trigger the uses-deprecated-python-stdlib tag
|
|
| 3 | 6 | from ..server.asyncserver import asyncore, RequestHandler, loop, AsyncServer, AsyncServerException
|
| 4 | 7 | from supervisor.medusa import asyncore_25 as asyncore |
| 1 | 1 | #!/usr/bin/python3
|
| 2 | 2 | |
| 3 | 3 | import asyncore
|
| 4 | +import struct, socket, argparse, asyncore
|
|
| 5 | +import struct, asyncore, argparse |
| 1 | +python-imports-asyncore (source): uses-deprecated-python-stdlib asyncore (deprecated in Python 3.6, removed in Python 3.12) [import.py:5]
|
|
| 2 | +python-imports-asyncore (source): uses-deprecated-python-stdlib asyncore (deprecated in Python 3.6, removed in Python 3.12) [import.py:4]
|
|
| 1 | 3 | python-imports-asyncore (source): uses-deprecated-python-stdlib asyncore (deprecated in Python 3.6, removed in Python 3.12) [import.py:3]
|
| 2 | -python-imports-asyncore (source): uses-deprecated-python-stdlib asyncore (deprecated in Python 3.6, removed in Python 3.12) [from.py:4]
|
|
| 3 | 4 | python-imports-asyncore (source): uses-deprecated-python-stdlib asyncore (deprecated in Python 3.6, removed in Python 3.12) [from.py:3] |
| 1 | 1 | #!/usr/bin/python3
|
| 2 | 2 | |
| 3 | 3 | import distutils
|
| 4 | +import foo, bar, distutils.core
|
|
| 5 | +import foo, distutils.core, bara
|
|
| 6 | + |
|
| 7 | +# This should not match the uses-deprecated-python-stdlib tag
|
|
| 8 | +import distutils2 |
| 1 | +python-imports-distutils (source): uses-deprecated-python-stdlib distutils (deprecated in Python 3.10, removed in Python 3.12) [import.py:5]
|
|
| 2 | +python-imports-distutils (source): uses-deprecated-python-stdlib distutils (deprecated in Python 3.10, removed in Python 3.12) [import.py:4]
|
|
| 1 | 3 | python-imports-distutils (source): uses-deprecated-python-stdlib distutils (deprecated in Python 3.10, removed in Python 3.12) [import.py:3]
|
| 2 | 4 | python-imports-distutils (source): uses-deprecated-python-stdlib distutils (deprecated in Python 3.10, removed in Python 3.12) [from.py:7] |