| OLD | NEW |
| 1 /* Generated file, do not modify. See jython/src/templates/gderived.py. */ | 1 /* Generated file, do not modify. See jython/src/templates/gderived.py. */ |
| 2 package org.python.core; | 2 package org.python.core; |
| 3 | 3 |
| 4 public class PyFileDerived extends PyFile implements Slotted { | 4 public class PyFileDerived extends PyFile implements Slotted { |
| 5 | 5 |
| 6 public PyObject getSlot(int index) { | 6 public PyObject getSlot(int index) { |
| 7 return slots[index]; | 7 return slots[index]; |
| 8 } | 8 } |
| 9 | 9 |
| 10 public void setSlot(int index,PyObject value) { | 10 public void setSlot(int index,PyObject value) { |
| (...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 PyType self_type=getType(); | 965 PyType self_type=getType(); |
| 966 PyObject impl=self_type.lookup("__call__"); | 966 PyObject impl=self_type.lookup("__call__"); |
| 967 if (impl!=null) | 967 if (impl!=null) |
| 968 return impl.__get__(this,self_type).__call__(args,keywords); | 968 return impl.__get__(this,self_type).__call__(args,keywords); |
| 969 return super.__call__(args,keywords); | 969 return super.__call__(args,keywords); |
| 970 } finally { | 970 } finally { |
| 971 --ts.recursion_depth; | 971 --ts.recursion_depth; |
| 972 } | 972 } |
| 973 } | 973 } |
| 974 | 974 |
| 975 public PyObject __findattr__(String name) { | 975 public PyObject __findattr_ex__(String name) { |
| 976 PyType self_type=getType(); | 976 PyType self_type=getType(); |
| 977 // TODO: We should speed this up. As the __getattribute__ slot almost ne
ver |
| 978 // changes, it is a good candidate for caching, as PyClass does wi
th |
| 979 // __getattr__. See #1102. |
| 977 PyObject getattribute=self_type.lookup("__getattribute__"); | 980 PyObject getattribute=self_type.lookup("__getattribute__"); |
| 978 PyString py_name=null; | 981 PyString py_name=null; |
| 982 PyException firstAttributeError=null; |
| 979 try { | 983 try { |
| 980 if (getattribute!=null) { | 984 if (getattribute!=null) { |
| 981 return getattribute.__get__(this,self_type).__call__(py_name=PyS
tring.fromInterned(name)); | 985 py_name=PyString.fromInterned(name); |
| 986 return getattribute.__get__(this,self_type).__call__(py_name); |
| 982 } else { | 987 } else { |
| 983 return super.__findattr__(name); | 988 Py.Warning(String.format("__getattribute__ not found on type %s"
,self_type.getName())); |
| 989 PyObject ret=super.__findattr_ex__(name); |
| 990 if (ret!=null) { |
| 991 return ret; |
| 992 } // else: pass through to __getitem__ invocation |
| 984 } | 993 } |
| 985 } catch (PyException e) { | 994 } catch (PyException e) { |
| 986 if (Py.matchException(e,Py.AttributeError)) { | 995 if (!Py.matchException(e,Py.AttributeError)) { |
| 987 PyObject getattr=self_type.lookup("__getattr__"); | 996 throw e; |
| 988 if (getattr!=null) | 997 } else { |
| 989 try { | 998 firstAttributeError=e; // saved to avoid swallowing custom Attri
buteErrors |
| 990 return getattr.__get__(this,self_type).__call__(py_name!
=null?py_name:PyString.fromInterned(name)); | 999 // and pass through to __getattr__ invocation. |
| 991 } catch (PyException e1) { | |
| 992 if (!Py.matchException(e1,Py.AttributeError)) | |
| 993 throw e1; | |
| 994 } | |
| 995 return null; | |
| 996 } | 1000 } |
| 997 throw e; | |
| 998 } | 1001 } |
| 1002 PyObject getattr=self_type.lookup("__getattr__"); |
| 1003 if (getattr!=null) { |
| 1004 if (py_name==null) { |
| 1005 py_name=PyString.fromInterned(name); |
| 1006 } |
| 1007 return getattr.__get__(this,self_type).__call__(py_name); |
| 1008 } |
| 1009 if (firstAttributeError!=null) { |
| 1010 throw firstAttributeError; |
| 1011 } |
| 1012 return null; |
| 999 } | 1013 } |
| 1000 | 1014 |
| 1001 public void __setattr__(String name,PyObject value) { | 1015 public void __setattr__(String name,PyObject value) { |
| 1002 PyType self_type=getType(); | 1016 PyType self_type=getType(); |
| 1003 PyObject impl=self_type.lookup("__setattr__"); | 1017 PyObject impl=self_type.lookup("__setattr__"); |
| 1004 if (impl!=null) { | 1018 if (impl!=null) { |
| 1005 impl.__get__(this,self_type).__call__(PyString.fromInterned(name),va
lue); | 1019 impl.__get__(this,self_type).__call__(PyString.fromInterned(name),va
lue); |
| 1006 return; | 1020 return; |
| 1007 } | 1021 } |
| 1008 super.__setattr__(name,value); | 1022 super.__setattr__(name,value); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1131 if (impl!=null) { | 1145 if (impl!=null) { |
| 1132 PyObject res=impl.__get__(this,self_type).__call__(); | 1146 PyObject res=impl.__get__(this,self_type).__call__(); |
| 1133 if (!(res instanceof PyString)) | 1147 if (!(res instanceof PyString)) |
| 1134 throw Py.TypeError("__repr__ returned non-string (type "+res.get
Type().fastGetName()+")"); | 1148 throw Py.TypeError("__repr__ returned non-string (type "+res.get
Type().fastGetName()+")"); |
| 1135 return((PyString)res).toString(); | 1149 return((PyString)res).toString(); |
| 1136 } | 1150 } |
| 1137 return super.toString(); | 1151 return super.toString(); |
| 1138 } | 1152 } |
| 1139 | 1153 |
| 1140 } | 1154 } |
| OLD | NEW |