[Python.NET] exception from a contructor

xtian xtian at toysinabag.com
Mon Dec 8 00:12:01 EST 2003


Hi -

Something odd is happening when I create a DateTime object with invalid 
contructor parameters:

 >>> import CLR
 >>> import CLR.System as System
 >>> d = System.DateTime(2003, 2, 30)
 >>> d
<CLR.System.DateTime object at 0x0127AC90>
 >>> d.ToString()

Traceback (most recent call last):
   File "<pyshell#34>", line 1, in -toplevel-
     d.ToString()
<CLR.System.Reflection.TargetException object at 0x0127AC70>: Object 
does not match target type.
 >>> d.Month

Traceback (most recent call last):
   File "<pyshell#35>", line 1, in -toplevel-
     d.Month
TypeError: Object does not match target type.
 >>>

The docs say the call to DateTime() should throw an 
ArgumentOutOfRangeException. Instead, I get something that thinks it's a 
DateTime, until I try to do anything with it.

Is this something that people have seen already?

I'm using Python 2.3.2, PythonNet 1.0b2

Thanks,
xtian




More information about the PythonDotNet mailing list