You are not logged in Log in Join
You are here: Home » Members » Brian » Python For .NET » Python for .NET Issue Tracker » ClassObject.tp_new can mask constructor exceptions » collector_issue_contents

Log in
Name

Password

 
 
Issue 15 of Python for .NET Issue Tracker [PythonNet]
Title: ClassObject.tp_new can mask constructor exceptions
Status: Pending Security related: No
Description: This: >>> from CLR.System.Drawing import Font >>> Font("Verdana", 0.0) raises a TypeError ("no constructor matches given arguments") even though the...
From: glchapman on: Jul 26, 05 14:47
glchapman Last update: Jul 26, 05 14:47
Topic/class: General/bug Importance: medium
Version info: pythonnet 1.0 rc2, clr 1.1, Python 2.4.1
Issue 15 Transcript
1 entry
= Request - Entry #1 by glchapman on Jul 26, 2005 2:47 pm

This:

>>> from CLR.System.Drawing import Font
>>> Font("Verdana", 0.0)

raises a TypeError ("no constructor matches given arguments") even though there is a Font(String, Single) constructor overload. I believe the problem is in ClassObject.tp_new. It assumes that if the call to binder.InvokeRaw returns null, it means no matching overload was found. However, in the above case, the constructor raises an ArgumentException, which is then lost by the attempt to call the default constructor (since Font doesn't have a default constructor, it raises the TypeError).

(Also, I note that the attempt to call the default constructor is passing in the kw parameter; if keywords are going to be supported in PythonNet method calls, it would probably be better to pass IntPtr.Zero).