@@ -183,7 +183,9 @@ cdef class Property:
183
183
'''
184
184
if x is None :
185
185
if not obj.__storage[self ._name][' allownone' ]:
186
- raise ValueError (' None is not allowed' )
186
+ raise ValueError (' None is not allowed for %s .%s ' % (
187
+ obj.__class__ .__name__ ,
188
+ self .name))
187
189
else :
188
190
return True
189
191
@@ -206,7 +208,7 @@ cdef class Property:
206
208
cdef class NumericProperty(Property):
207
209
''' Property that represents a numeric value
208
210
209
- The NumericProperty accepts only int or float.
211
+ The NumericProperty accept only int or float.
210
212
211
213
>>> Widget.x = 42
212
214
>>> print Widget.x
@@ -217,13 +219,15 @@ cdef class NumericProperty(Property):
217
219
File "properties.pyx", line 93, in kivy.properties.Property.__set__
218
220
File "properties.pyx", line 111, in kivy.properties.Property.set
219
221
File "properties.pyx", line 159, in kivy.properties.NumericProperty.check
220
- ValueError: NumericProperty accepts only int/float
222
+ ValueError: NumericProperty accept only int/float
221
223
'''
222
224
cdef check(self , obj, value):
223
225
if Property.check(self , obj, value):
224
226
return True
225
227
if type (value) not in (int , float ):
226
- raise ValueError (' NumericProperty<%s > accepts only int/float' % self .name)
228
+ raise ValueError (' %s .%s accept only int/float' % (
229
+ obj.__class__ .__name__ ,
230
+ self .name))
227
231
228
232
229
233
cdef class StringProperty(Property):
@@ -235,8 +239,9 @@ cdef class StringProperty(Property):
235
239
if Property.check(self , obj, value):
236
240
return True
237
241
if not isinstance (value, basestring ):
238
- raise ValueError (' StringProperty<%s > accepts only str/unicode' %
239
- self .name)
242
+ raise ValueError (' %s .%s accept only str/unicode' % (
243
+ obj.__class__ .__name__ ,
244
+ self .name))
240
245
241
246
cdef inline void observable_list_dispatch(object self ):
242
247
cdef Property prop = self .prop
@@ -320,8 +325,9 @@ cdef class ListProperty(Property):
320
325
if Property.check(self , obj, value):
321
326
return True
322
327
if type (value) is not ObservableList:
323
- raise ValueError (' ListProperty<%s > accepts only ObservableList'
324
- ' (should never happen.)' % self .name)
328
+ raise ValueError (' %s .%s accept only ObservableList' % (
329
+ obj.__class__ .__name__ ,
330
+ self .name))
325
331
326
332
cpdef set (self , obj, value):
327
333
value = ObservableList(self , obj, value)
@@ -388,8 +394,9 @@ cdef class DictProperty(Property):
388
394
if Property.check(self , obj, value):
389
395
return True
390
396
if type (value) is not ObservableDict:
391
- raise ValueError (' DictProperty<%s > accepts only ObservableDict'
392
- ' (should never happen.)' % self .name)
397
+ raise ValueError (' %s .%s accept only ObservableDict' % (
398
+ obj.__class__ .__name__ ,
399
+ self .name))
393
400
394
401
cpdef set (self , obj, value):
395
402
value = ObservableDict(self , obj, value)
@@ -407,8 +414,9 @@ cdef class ObjectProperty(Property):
407
414
if Property.check(self , obj, value):
408
415
return True
409
416
if not isinstance (value, object ):
410
- raise ValueError (' ObjectProperty<%s > accepts only Python objects' %
411
- self .name)
417
+ raise ValueError (' %s .%s accept only Python object' % (
418
+ obj.__class__ .__name__ ,
419
+ self .name))
412
420
413
421
cdef class BooleanProperty(Property):
414
422
''' Property that represents only boolean
@@ -417,7 +425,9 @@ cdef class BooleanProperty(Property):
417
425
if Property.check(self , obj, value):
418
426
return True
419
427
if not isinstance (value, object ):
420
- raise ValueError (' BooleanProperty<%s > accepts only bool' % self .name)
428
+ raise ValueError (' %s .%s accept only bool' % (
429
+ obj.__class__ .__name__ ,
430
+ self .name))
421
431
422
432
cdef class BoundedNumericProperty(Property):
423
433
''' Property that represents a numeric value within a minimum bound and/or
@@ -469,13 +479,15 @@ cdef class BoundedNumericProperty(Property):
469
479
if s[' use_min' ]:
470
480
_min = s[' min' ]
471
481
if value < _min:
472
- raise ValueError (' BoundedNumericProperty<%s > is below the '
473
- ' minimum bound (%d )' % (self .name, _min))
482
+ raise ValueError (' %s .%s is below the minimum bound (%d )' % (
483
+ obj.__class__ .__name__ ,
484
+ self .name, _min))
474
485
if s[' use_max' ]:
475
486
_max = s[' max' ]
476
487
if value > _max:
477
- raise ValueError (' BoundedNumericProperty<%s > is above the '
478
- ' maximum bound (%d )' % (self .name, _max))
488
+ raise ValueError (' %s .%s is above the maximum bound (%d )' % (
489
+ obj.__class__ .__name__ ,
490
+ self .name, _max))
479
491
return True
480
492
481
493
property bounds :
@@ -518,8 +530,10 @@ cdef class OptionProperty(Property):
518
530
return True
519
531
valid_options = obj.__storage[self ._name][' options' ]
520
532
if value not in valid_options:
521
- raise ValueError (' OptionProperty<%s > have an invalid option %r . '
522
- ' Must be one of: %s ' % (self .name,
533
+ raise ValueError (' %s .%s is set to an invalid option %r . '
534
+ ' Must be one of: %s ' % (
535
+ obj.__class__ .__name__ ,
536
+ self .name,
523
537
value, valid_options))
524
538
525
539
property options :
@@ -571,14 +585,16 @@ cdef class ReferenceListProperty(Property):
571
585
572
586
cdef convert(self , obj, value):
573
587
if not isinstance (value, (list , tuple )):
574
- raise ValueError (' ReferenceListProperty<%s > must be a list or a '
575
- ' tuple' % self .name)
588
+ raise ValueError (' %s .%s must be a list or a tuple' % (
589
+ obj.__class__ .__name__ ,
590
+ self .name))
576
591
return list (value)
577
592
578
593
cdef check(self , obj, value):
579
594
if len (value) != len (obj.__storage[self ._name][' properties' ]):
580
- raise ValueError (' ReferenceListProperty<%s > value length is '
581
- ' immutable' % self .name)
595
+ raise ValueError (' %s .%s value length is immutable' % (
596
+ obj.__class__ .__name__ ,
597
+ self .name))
582
598
583
599
cpdef set (self , obj, _value):
584
600
cdef int idx
0 commit comments