-
Notifications
You must be signed in to change notification settings - Fork 638
Closed
Labels
Fixed in next releaseenhancementfix developedrelease schedule to be determinedrelease schedule to be determined
Description
Description of the bug
What happened?
If one installs the latest version of PyMuPDF, and they initialize a Pixmap
object using Python bytes
, they will see a log message in the process' stdout:
__init__: using mupdf.python_buffer_data()
(note, this applies only to the new fitz
module, not fitz_old
)
The underlying cause is that PyMuPDF has the following logging function:
Lines 31 to 37 in 0a6f26d
def log( text, caller=1): | |
frame_record = inspect.stack( context=0)[ caller] | |
filename = os.path.relpath(frame_record.filename) | |
line = frame_record.lineno | |
function = frame_record.function | |
print( f'{filename}:{line}:{function}: {text}', file=sys.stdout) | |
sys.stdout.flush() |
This function does not employ regular Python logging, but simply writes to stdout. The stdout of a process though is not the place to write warnings, since it may interfere with binary data.
How to reproduce the bug
What I expected to happen?
Initializing a Pixmap
object should not write anything to stdout.
How to reproduce it?
- Import the
fitz_new
module - Initialize a
Pixmap
class using abytes
object for thesamples
argument (seePixmap
constructor)
Or simply run:
import fitz
fitz.Pixmap(fitz.Colorspace(fitz.CS_RGB), 10, 10, b'a' * 100 * 3, False)
PyMuPDF version
1.23.14
Operating system
Linux
Python version
3.11
Metadata
Metadata
Assignees
Labels
Fixed in next releaseenhancementfix developedrelease schedule to be determinedrelease schedule to be determined