Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erroneous code objects created with PyCode_New #39683

Closed
timmcl mannequin opened this issue Dec 9, 2003 · 3 comments
Closed

Erroneous code objects created with PyCode_New #39683

timmcl mannequin opened this issue Dec 9, 2003 · 3 comments

Comments

@timmcl
Copy link
Mannequin

timmcl mannequin commented Dec 9, 2003

BPO 856623

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2005-12-19.03:45:12.000>
created_at = <Date 2003-12-09.03:15:01.000>
labels = []
title = 'Erroneous code objects created with PyCode_New'
updated_at = <Date 2005-12-19.03:45:12.000>
user = 'https://bugs.python.org/timmcl'

bugs.python.org fields:

activity = <Date 2005-12-19.03:45:12.000>
actor = 'nnorwitz'
assignee = 'nnorwitz'
closed = True
closed_date = None
closer = None
components = ['None']
creation = <Date 2003-12-09.03:15:01.000>
creator = 'timmcl'
dependencies = []
files = []
hgrepos = []
issue_num = 856623
keywords = []
message_count = 3.0
messages = ['19336', '19337', '19338']
nosy_count = 2.0
nosy_names = ['nnorwitz', 'timmcl']
pr_nums = []
priority = 'normal'
resolution = 'works for me'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue856623'
versions = []

@timmcl
Copy link
Mannequin Author

timmcl mannequin commented Dec 9, 2003

If you copy a code object by calling say new.code with
just the members of an existing code object with
free/cell variables - such as the following nested example:

def null():
    return None

def wrapfunc(func):
    def _inner(*args):
       return func(*args)
    return _inner

wrapped = wrapfunc(null)

code_object = wrapped.func_code

new_code_object = new.code(<  code_object  >)

then the new_code_object will not have had its
free/cell vars removed and will thus not disassemble
correctly. Furthermore
if you create a function out of it, then calling the
function will raise -
SystemError:
R:Python23srcPython-2.3.2Objectscellobject.c:
22: bad argument to internal function

Looking at the code in PyCode_New I can't see why this
should happen.

(Bug noticed on Python 2.3.2 on windows)

@timmcl timmcl mannequin closed this as completed Dec 9, 2003
@timmcl timmcl mannequin assigned nnorwitz Dec 9, 2003
@timmcl timmcl mannequin closed this as completed Dec 9, 2003
@timmcl timmcl mannequin assigned nnorwitz Dec 9, 2003
@nnorwitz
Copy link
Mannequin

nnorwitz mannequin commented Oct 2, 2005

Logged In: YES
user_id=33168

I don't think this is still a bug any longer.
new.function() seems to require closure be passed in if the
function has cell variables.

When I disassemble new_code_object, I get the same as the
original.

@nnorwitz
Copy link
Mannequin

nnorwitz mannequin commented Dec 19, 2005

Logged In: YES
user_id=33168

Assuming this is fixed.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants