Skip to content
This repository has been archived by the owner on Sep 14, 2018. It is now read-only.

metaclass interferes with property/partial #1102

Open
ironpythonbot opened this issue Dec 9, 2014 · 2 comments
Open

metaclass interferes with property/partial #1102

ironpythonbot opened this issue Dec 9, 2014 · 2 comments

Comments

@ironpythonbot
Copy link

Adding a metaclass causes partial properties to fail due to not passing all
arguments to property using the partial. Same functionality without even a
dummy metaclass works.

In the attached file contains a metaclass which controls which attributes are
available. Normally read from an external configuration file thus the use of
metaclasses to enforce the property list.

In the attached code uncommenting line 18 will cause it to fail with the
following error which basically indicates that the function is called but some
of the parameters were not passed along. Works fine in CPython 2.5,2.7,3.3
(with proper metaclass).

Its not clear if it is the property or partial which is the problem. Will try
to further isolate the issue.

Traceback (most recent call last):
  File "test5.py", line 37, in <module>
TypeError: set_basic_attribute() takes exactly 3 non-keyword arguments (1 given)

Work Item Details

Original CodePlex Issue: Issue 34968
Status: Active
Reason Closed: Unassigned
Assigned to: Unassigned
Reported on: Feb 10 at 4:08 AM
Reported by: tfigment
Updated on: Apr 29 at 11:11 PM
Updated by: jdhardy

Plaintext Attachments

CodePlex Issue #34968 Plain Text Attachments

@ironpythonbot
Copy link
Author

On 2014-02-10 13:29:04 UTC, tfigment commented:

After addtional testing it looks like its a problem with partial though I cannot determine what it is from code at the moment.

using the following definition from the python docs instead of "from functools import partial" seems to work better.
def partial(func, _args, *_keywords):
def newfunc(_fargs, *fkeywords):
newkeywords = keywords.copy()
newkeywords.update(fkeywords)
return func(
(args + fargs), *_newkeywords)
newfunc.func = func
newfunc.args = args
newfunc.keywords = keywords
return newfunc

@ironpythonbot
Copy link
Author

On 2014-04-30 06:11:51 UTC, jdhardy commented:

The issue seems to be related to how IronPython is trying to call the partial.Call method. The binding code path for builtin methods (partial is in C#) is complicated and difficult to trace. Why it's different with a metaclass than without I'm not sure.

When running in Debug mode it hits an Assert on L74 of Runtime\Microsoft.Dynamic\Actions\Calls\DefaultOverloadResolver.cs because there aren't the right number of arguments. Eventually it reaches partial.Call with arguments missing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants