From 99f0c09869370d74eb6a27234284b894c33414f4 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Sun, 26 Jul 2020 15:06:04 +0200 Subject: [PATCH] Restore PDFTextExtractionNotAllowed exception (#461) * Restore PDFTextExtractionNotAllowed Restore PDFTextExtractionNotAllowed exception class as an alias of the new PDFTextExtractionNotAllowedError exception that was introduced in https://github.com/pdfminer/pdfminer.six/commit/6a9269b432b861fdd8de6f532759833faf9a9159 Removing PDFTextExtractionNotAllowed is an API breakage that made several tools fail break. Signed-off-by: Philippe Ombredanne * Use PDFTextExtractionNotAllowed and prepare PDFTextExtractionNotAllowedError to be removed in the future * Add line to CHANGELOG.md Co-authored-by: Pieter Marsman --- CHANGELOG.md | 7 ++++++- pdfminer/pdfdocument.py | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4833fcfa..dc433144 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,17 @@ All notable changes in pdfminer.six will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [20200726] + +### Fixed +- Rename PDFTextExtractionNotAllowedError to PDFTextExtractionNotAllowed to revert breaking change ([#461](https://github.com/pdfminer/pdfminer.six/pull/461)) + ## [20200720] ### Added - Support for painting multiple rectangles at once ([#371](https://github.com/pdfminer/pdfminer.six/pull/371)) -## Fixed +### Fixed - Always try to get CMap, not only for identity encodings ([#438](https://github.com/pdfminer/pdfminer.six/pull/438)) - Validate image object in do_EI is a PDFStream ([#451](https://github.com/pdfminer/pdfminer.six/pull/451)) diff --git a/pdfminer/pdfdocument.py b/pdfminer/pdfdocument.py index ba473be8..19187aee 100644 --- a/pdfminer/pdfdocument.py +++ b/pdfminer/pdfdocument.py @@ -46,10 +46,18 @@ class PDFTextExtractionNotAllowedWarning(UserWarning): pass -class PDFTextExtractionNotAllowedError(PDFEncryptionError): +class PDFTextExtractionNotAllowed(PDFEncryptionError): pass +class PDFTextExtractionNotAllowedError(PDFTextExtractionNotAllowed): + def __init__(self, *args): + from warnings import warn + warn('PDFTextExtractionNotAllowedError will be removed in the future. ' + 'Use PDFTextExtractionNotAllowed instead.', DeprecationWarning) + super().__init__(*args) + + # some predefined literals and keywords. LITERAL_OBJSTM = LIT('ObjStm') LITERAL_XREF = LIT('XRef')