Exemplo n.º 1
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");
                }
                else if ((!hasObjectNew && !hasObjectInit) || self == null)
                {
                    PythonOps.Warn(context, PythonExceptions.DeprecationWarning, "object.__init__() takes no parameters");
                }
            }
        }
Exemplo n.º 2
0
 static void Warn(CodeContext context, object result)
 {
     PythonOps.Warn(context, PythonExceptions.DeprecationWarning, $"__int__ returned non-int (type {PythonTypeOps.GetName(result)}).  The ability to return an instance of a strict subclass of int is deprecated, and may be removed in a future version of Python.");
 }