Raise KeyError when name in name2unicode is not of type str (#733)

* Raise KeyError when name in name2unicode is not of type str

* Add CHANGELOG.md
pull/732/head^2
Pieter Marsman 2022-03-21 19:25:28 +01:00 committed by GitHub
parent e27cd54aff
commit 782368b911
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -6,10 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Fixes
### Fixed
- `TypeError` in encodingdb.py when name of unicode is not
str ([#733](https://github.com/pdfminer/pdfminer.six/pull/733))
- `TypeError` in HTMLConverter when using a bytes fontname ([#734](https://github.com/pdfminer/pdfminer.six/pull/734))
## [20220319]
### Added

View File

@ -25,6 +25,12 @@ def name2unicode(name: str) -> str:
:returns unicode character if name resembles something,
otherwise a KeyError
"""
if not isinstance(name, str):
raise KeyError(
'Could not convert unicode name "%s" to character because '
"it should be of type str but is of type %s" % (name, type(name))
)
name = name.split(".")[0]
components = name.split("_")