[cffLib] fix "TypeError: cannot use a string pattern on a bytes-like object"

This is just to make the tests pass, otherwise the following re.sub call fails with TypeError on Python 3.

However, I wonder why we need to replace all newlines with spaces in 'Notice' and 'Copyright' fields?

```
if name in ['Notice', 'Copyright']:
    value = re.sub(r"[\r\n]\s+", " ", value)
```

We shall ask Read about this.
This commit is contained in:
Cosimo Lupo 2017-03-05 23:11:41 +00:00
parent 0fc9313e79
commit ca235ea8a1
No known key found for this signature in database
GPG Key ID: B61AAAD0B53A6419

View File

@ -1031,9 +1031,10 @@ class Latin1Converter(SimpleConverter):
def write(self, parent, value):
return tobytes(value, encoding='latin1')
def xmlWrite(self, xmlWriter, name, value, progress):
value = tounicode(value, encoding="latin1")
if name in ['Notice', 'Copyright']:
value = re.sub(r"[\r\n]\s+", " ", value)
xmlWriter.simpletag(name, value=tounicode(value, encoding="latin1"))
xmlWriter.simpletag(name, value=value)
xmlWriter.newline()
def xmlRead(self, name, attrs, content, parent):
return tobytes(attrs["value"], encoding=("latin1"))