39 lines
981 B
Python
39 lines
981 B
Python
import icu
|
|
import tempfile
|
|
import pathlib
|
|
|
|
dep = icu.UnicodeSet()
|
|
u = icu.UnicodeSet()
|
|
dep.applyIntPropertyValue(icu.UProperty.DEPRECATED, 1)
|
|
for C in ('L','M','N','P','S','Z','Cf'):
|
|
u.addAll(icu.UnicodeSet(f"[:{C}:]"))
|
|
u.removeAll(dep)
|
|
assert u.contains('∞')
|
|
|
|
tested = 0
|
|
bad_characters = ''
|
|
pathlib_bad_characters = ''
|
|
with tempfile.TemporaryDirectory() as temp:
|
|
temp = pathlib.Path(temp)
|
|
for char in u:
|
|
tested += 1
|
|
try:
|
|
f = temp / f't_{char}_t'
|
|
except Exception:
|
|
pathlib_bad_characters += char
|
|
continue
|
|
try:
|
|
f.touch(exist_ok=False)
|
|
except Exception:
|
|
bad_characters += char
|
|
continue
|
|
finally:
|
|
try:
|
|
f.unlink()
|
|
except Exception:
|
|
...
|
|
|
|
print("pathlib bad characters ", repr(pathlib_bad_characters))
|
|
print("bad characters ", repr(bad_characters))
|
|
print("total characters tested", tested)
|