mirror of https://github.com/kivy/kivy.git
fix basestring test in cython
This commit is contained in:
parent
bae94bc3db
commit
72284ff0ec
|
@ -171,6 +171,8 @@ __all__ = ('Property',
|
|||
'OptionProperty', 'ReferenceListProperty', 'AliasProperty',
|
||||
'DictProperty')
|
||||
|
||||
include "graphics/config.pxi"
|
||||
|
||||
from weakref import ref
|
||||
|
||||
cdef float g_dpi = -1
|
||||
|
@ -489,10 +491,16 @@ cdef class StringProperty(Property):
|
|||
cdef check(self, EventDispatcher obj, value):
|
||||
if Property.check(self, obj, value):
|
||||
return True
|
||||
if not isinstance(value, basestring):
|
||||
raise ValueError('%s.%s accept only str/unicode' % (
|
||||
obj.__class__.__name__,
|
||||
self.name))
|
||||
IF PY3:
|
||||
if not isinstance(value, str):
|
||||
raise ValueError('%s.%s accept only str' % (
|
||||
obj.__class__.__name__,
|
||||
self.name))
|
||||
ELSE:
|
||||
if not isinstance(value, basestring):
|
||||
raise ValueError('%s.%s accept only str/unicode' % (
|
||||
obj.__class__.__name__,
|
||||
self.name))
|
||||
|
||||
cdef inline void observable_list_dispatch(object self):
|
||||
cdef Property prop = self.prop
|
||||
|
|
11
setup.py
11
setup.py
|
@ -10,6 +10,12 @@ from os import walk, environ
|
|||
from distutils.core import setup
|
||||
from distutils.extension import Extension
|
||||
|
||||
if sys.version > '3':
|
||||
PY3 = True
|
||||
else:
|
||||
PY3 = False
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Detect options
|
||||
#
|
||||
|
@ -75,14 +81,15 @@ class KivyBuildExt(build_ext):
|
|||
with open(config_h, 'w') as fd:
|
||||
fd.write('// Autogenerated file for Kivy C configuration\n')
|
||||
for k, v in c_options.items():
|
||||
fd.write('#define __%s %d\n' % (k.upper(), int(v)))
|
||||
fd.write('#define __{0} {1}\n'.format(k.upper(), int(v)))
|
||||
|
||||
print('Generate config.pxi')
|
||||
config_pxi = join(dirname(__file__), 'kivy', 'graphics', 'config.pxi')
|
||||
with open(config_pxi, 'w') as fd:
|
||||
fd.write('# Autogenerated file for Kivy Cython configuration\n')
|
||||
for k, v in c_options.items():
|
||||
fd.write('DEF %s = %d\n' % (k.upper(), int(v)))
|
||||
fd.write('DEF {0} = {1}\n'.format(k.upper(), int(v)))
|
||||
fd.write('DEF PY3 = {0}\n'.format(int(PY3)))
|
||||
|
||||
build_ext.build_extensions(self)
|
||||
|
||||
|
|
Loading…
Reference in New Issue