mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Support for the new in python 3.8 Constant ast node
This commit is contained in:
parent
66a4ec4738
commit
72308168ef
@ -185,6 +185,8 @@ def convert_node(fields, x, names={}, import_data=None):
|
|||||||
elif name == 'BinOp':
|
elif name == 'BinOp':
|
||||||
if x.right.__class__.__name__ == 'Str':
|
if x.right.__class__.__name__ == 'Str':
|
||||||
return x.right.s.decode('utf-8') if isinstance(x.right.s, bytes) else x.right.s
|
return x.right.s.decode('utf-8') if isinstance(x.right.s, bytes) else x.right.s
|
||||||
|
if x.right.__class__.__name__ == 'Constant' and isinstance(x.right.value, str):
|
||||||
|
return x.right.value
|
||||||
elif name == 'Attribute':
|
elif name == 'Attribute':
|
||||||
return conv(getattr(conv(x.value), x.attr))
|
return conv(getattr(conv(x.value), x.attr))
|
||||||
raise TypeError('Unknown datatype %s for fields: %s' % (x, fields))
|
raise TypeError('Unknown datatype %s for fields: %s' % (x, fields))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user