homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: modulefinder uses wrong CodeType signature in .replace_paths_in_code()
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: berker.peksag Nosy List: berker.peksag, lemburg, python-dev, r.david.murray
Priority: normal Keywords: 3.4regression, patch

Created on 2014年06月10日 16:59 by lemburg, last changed 2022年04月11日 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue21707.diff berker.peksag, 2014年06月12日 07:02 review
Messages (5)
msg220174 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2014年06月10日 16:59
Here's the code:
 def replace_paths_in_code(self, co):
 ...
 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)
Compare this to the code_new() C API doc string (and code):
code(argcount, kwonlyargcount, nlocals, stacksize, flags, codestring,\n\
 constants, names, varnames, filename, name, firstlineno,\n\
 lnotab[, freevars[, cellvars]])
The kwonlyargcount is missing in the call used in .replace_paths_in_code().
The bug surfaces when trying to use the "-r" option of the freeze.py tool:
Traceback (most recent call last):
 File "freeze.py", line 504, in <module>
 main()
 File "freeze.py", line 357, in main
 mf.import_hook(mod)
 File "/home/lemburg/egenix/projects/PyRun/tmp-3.4-ucs2/lib/python3.4/modulefinder.py", line 123, in import_hook
 q, tail = self.find_head_package(parent, name)
 File "/home/lemburg/egenix/projects/PyRun/tmp-3.4-ucs2/lib/python3.4/modulefinder.py", line 179, in find_head_package
 q = self.import_module(head, qname, parent)
 File "/home/lemburg/egenix/projects/PyRun/tmp-3.4-ucs2/lib/python3.4/modulefinder.py", line 272, in import_module
 m = self.load_module(fqname, fp, pathname, stuff)
 File "/home/lemburg/egenix/projects/PyRun/tmp-3.4-ucs2/lib/python3.4/modulefinder.py", line 303, in load_module
 co = self.replace_paths_in_code(co)
 File "/home/lemburg/egenix/projects/PyRun/tmp-3.4-ucs2/lib/python3.4/modulefinder.py", line 569, in replace_paths_in_code
 consts[i] = self.replace_paths_in_code(consts[i])
 File "/home/lemburg/egenix/projects/PyRun/tmp-3.4-ucs2/lib/python3.4/modulefinder.py", line 575, in replace_paths_in_code
 co.co_freevars, co.co_cellvars)
TypeError: an integer is required (got type bytes)
msg220176 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2014年06月10日 17:06
The fix is easy. Simply change the call to:
 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)
(ie. add the missing argument)
msg220334 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2014年06月12日 07:02
Here's a patch with a test.
msg222451 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014年07月07日 11:59
New changeset 59921d2f023c by Berker Peksag in branch '3.4':
Issue #21707: Add missing kwonlyargcount argument to ModuleFinder.replace_paths_in_code().
http://hg.python.org/cpython/rev/59921d2f023c
New changeset 4b6798e74dcf by Berker Peksag in branch 'default':
Issue #21707: Merge with 3.4.
http://hg.python.org/cpython/rev/4b6798e74dcf 
msg222495 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014年07月07日 18:30
New changeset f8deaac44ed4 by Berker Peksag in branch '3.4':
Issue #21707: Fix tests on Windows.
http://hg.python.org/cpython/rev/f8deaac44ed4
New changeset e66c387da81b by Berker Peksag in branch 'default':
Issue #21707: Merge with 3.4.
http://hg.python.org/cpython/rev/e66c387da81b 
History
Date User Action Args
2022年04月11日 14:58:04adminsetgithub: 65906
2014年07月07日 18:30:44python-devsetmessages: + msg222495
2014年07月07日 12:11:27berker.peksagsetnosy: + r.david.murray
2014年07月07日 12:00:51berker.peksagsetstatus: open -> closed
assignee: berker.peksag
resolution: fixed
stage: patch review -> resolved
2014年07月07日 11:59:39python-devsetnosy: + python-dev
messages: + msg222451
2014年06月12日 07:02:57berker.peksagsetfiles: + issue21707.diff

type: behavior

keywords: + patch
nosy: + berker.peksag
messages: + msg220334
stage: patch review
2014年06月10日 17:06:24lemburgsetmessages: + msg220176
2014年06月10日 16:59:48lemburgcreate

AltStyle によって変換されたページ (->オリジナル) /