public bool __contains__(CodeContext /*!*/ context, object value) { if (value is Extensible <string> ) { return(__contains__(PythonOps.MakeBytes(((Extensible <string>)value).Value.MakeByteArray()))); } if (!context.LanguageContext.PythonOptions.Python30) { throw PythonOps.TypeError("'in <bytes>' requires string or bytes as left operand, not {0}", PythonTypeOps.GetName(value)); } if (value is Extensible <int> ) { return(IndexOf(((Extensible <int>)value).Value.ToByteChecked()) != -1); } else if (value is BigInteger) { return(IndexOf(((BigInteger)value).ToByteChecked()) != -1); } else if (value is Extensible <BigInteger> ) { return(IndexOf(((Extensible <BigInteger>)value).Value.ToByteChecked()) != -1); } // 3.0 error message throw PythonOps.TypeError("Type {0} doesn't support the buffer API", PythonTypeOps.GetOldName(value)); }
public bool __contains__(CodeContext /*!*/ context, object value) { if (value is Extensible <int> ) { return(IndexOf(((Extensible <int>)value).Value.ToByteChecked()) != -1); } else if (value is BigInteger) { return(IndexOf(((BigInteger)value).ToByteChecked()) != -1); } else if (value is Extensible <BigInteger> ) { return(IndexOf(((Extensible <BigInteger>)value).Value.ToByteChecked()) != -1); } throw PythonOps.TypeError("Type {0} doesn't support the buffer API", PythonContext.GetContext(context).PythonOptions.Python30 ? PythonTypeOps.GetOldName(value) : PythonTypeOps.GetName(value)); }
public int seek(CodeContext /*!*/ context, object pos, [DefaultParameterValue(0)] object whence) { EnsureOpen(); if (pos == null || whence == null) { throw PythonOps.TypeError("an integer is required"); } int intPos; if (pos is int) { intPos = (int)pos; } else if (pos is Extensible <int> ) { intPos = ((Extensible <int>)pos).Value; } else if (pos is BigInteger) { intPos = (int)(BigInteger)pos; } else if (pos is Extensible <BigInteger> ) { intPos = (int)(((Extensible <BigInteger>)pos).Value); } else if (pos is double || pos is Extensible <double> ) { throw PythonOps.TypeError("position argument must be an integer"); } else if (PythonContext.GetContext(context).PythonOptions.Python30) { throw PythonOps.TypeError("'{0}' object cannot be interpreted as an integer", PythonTypeOps.GetOldName(pos)); } else { throw PythonOps.TypeError("an integer is required"); } if (whence is int) { return(seek(intPos, (int)whence)); } else if (whence is Extensible <int> ) { return(seek(intPos, ((Extensible <int>)pos).Value)); } else if (whence is BigInteger) { return(seek(intPos, (int)(BigInteger)whence)); } else if (whence is Extensible <BigInteger> ) { return(seek(intPos, (int)(((Extensible <BigInteger>)whence).Value))); } else if (whence is double || whence is Extensible <double> ) { if (PythonContext.GetContext(context).PythonOptions.Python30) { throw PythonOps.TypeError("integer argument expected, got float"); } else { PythonOps.Warn(context, PythonExceptions.DeprecationWarning, "integer argument expected, got float"); return(seek(intPos, Converter.ConvertToInt32(whence))); } } else if (PythonContext.GetContext(context).PythonOptions.Python30) { throw PythonOps.TypeError("'{0}' object cannot be interpreted as an integer", PythonTypeOps.GetOldName(whence)); } else { throw PythonOps.TypeError("an integer is required"); } }