Esempio n. 1
0
        internal static void CheckNewArgs(CodeContext context, IDictionary <object, object> dict, object[] args, PythonType pt)
        {
            if ((args != null && args.Length > 0) || (dict != null && dict.Count > 0))
            {
                bool hasObjectInit = pt.HasObjectInit(context);
                bool hasObjectNew  = pt.HasObjectNew(context);

                if (hasObjectInit || !hasObjectNew && !hasObjectInit)
                {
                    throw PythonOps.TypeError(ObjectNewNoParameters);
                }
            }
        }
Esempio n. 2
0
        internal static void CheckInitArgs(CodeContext context, IDictionary <object, object> dict, object[] args, object self)
        {
            if (((args != null && args.Length > 0) || (dict != null && dict.Count > 0)))
            {
                PythonType pt            = DynamicHelpers.GetPythonType(self);
                bool       hasObjectInit = pt.HasObjectInit(context);
                bool       hasObjectNew  = pt.HasObjectNew(context);

                // NoneType seems to get some special treatment (None.__init__('abc') works)
                if (hasObjectNew && self != null)
                {
                    throw PythonOps.TypeError("object.__init__() takes no parameters");
                }
            }
        }