summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-07-07 12:18:22 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-07-07 12:18:22 (GMT)
commit11116da935760bb5ff02a450708f56d3b36b7556 (patch)
tree9584d5e72bf5b180863437c459b4f84dd21b1cf1
parent6f1435c939f1c2a2a1a835d8c48e085be1d82682 (diff)
parent0a0d1da987118e11bc9c28937817facdcc9801cb (diff)
downloadcpython-11116da935760bb5ff02a450708f56d3b36b7556.zip
cpython-11116da935760bb5ff02a450708f56d3b36b7556.tar.gz
cpython-11116da935760bb5ff02a450708f56d3b36b7556.tar.bz2
Merge heads
-rw-r--r--Lib/modulefinder.py11
-rw-r--r--Lib/test/test_modulefinder.py16
-rw-r--r--Misc/NEWS3
3 files changed, 21 insertions, 9 deletions
diff --git a/Lib/modulefinder.py b/Lib/modulefinder.py
index cc5b8cc..b778e60 100644
--- a/Lib/modulefinder.py
+++ b/Lib/modulefinder.py
@@ -568,11 +568,12 @@ class ModuleFinder:
if isinstance(consts[i], type(co)):
consts[i] = self.replace_paths_in_code(consts[i])
- return types.CodeType(co.co_argcount, co.co_nlocals, co.co_stacksize,
- co.co_flags, co.co_code, tuple(consts), co.co_names,
- co.co_varnames, new_filename, co.co_name,
- co.co_firstlineno, co.co_lnotab,
- co.co_freevars, co.co_cellvars)
+ return types.CodeType(co.co_argcount, co.co_kwonlyargcount,
+ co.co_nlocals, co.co_stacksize, co.co_flags,
+ co.co_code, tuple(consts), co.co_names,
+ co.co_varnames, new_filename, co.co_name,
+ co.co_firstlineno, co.co_lnotab, co.co_freevars,
+ co.co_cellvars)
def test():
diff --git a/Lib/test/test_modulefinder.py b/Lib/test/test_modulefinder.py
index ed30d6f..b5fdcc8 100644
--- a/Lib/test/test_modulefinder.py
+++ b/Lib/test/test_modulefinder.py
@@ -245,11 +245,12 @@ def create_package(source):
class ModuleFinderTest(unittest.TestCase):
- def _do_test(self, info, report=False):
+ def _do_test(self, info, report=False, debug=0, replace_paths=[]):
import_this, modules, missing, maybe_missing, source = info
create_package(source)
try:
- mf = modulefinder.ModuleFinder(path=TEST_PATH)
+ mf = modulefinder.ModuleFinder(path=TEST_PATH, debug=debug,
+ replace_paths=replace_paths)
mf.import_hook(import_this)
if report:
mf.report()
@@ -308,9 +309,16 @@ class ModuleFinderTest(unittest.TestCase):
os.remove(source_path)
self._do_test(bytecode_test)
+ def test_replace_paths(self):
+ old_path = os.path.join(TEST_DIR, 'a', 'module.py')
+ new_path = os.path.join(TEST_DIR, 'a', 'spam.py')
+ with support.captured_stdout() as output:
+ self._do_test(maybe_test, debug=2,
+ replace_paths=[(old_path, new_path)])
+ output = output.getvalue()
+ expected = "co_filename '%s' changed to '%s'" % (old_path, new_path)
+ self.assertIn(expected, output)
-def test_main():
- support.run_unittest(ModuleFinderTest)
if __name__ == "__main__":
unittest.main()
diff --git a/Misc/NEWS b/Misc/NEWS
index 37d16eb..caa30ed 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -27,6 +27,9 @@ Core and Builtins
Library
-------
+- Issue #21707: Add missing kwonlyargcount argument to
+ ModuleFinder.replace_paths_in_code().
+
- Issue #20639: calling Path.with_suffix('') allows removing the suffix
again. Patch by July Tikhonov.