Closed Mukei closed 6 months ago
I found out that in Python 3.13 imghdr
was removed.
Important deprecations, removals or restrictions: PEP 594: The remaining 19 “dead batteries” have been removed from the standard library: aifc, audioop, cgi, cgitb, chunk, crypt, imghdr, mailcap, msilib, nis, nntplib, ossaudiodev, pipes, sndhdr, spwd, sunau, telnetlib, uu and xdrlib.
And PEP 594 gives the below advice:
imghdr: use the projects filetype, puremagic, or python-magic instead. (Contributed by Victor Stinner in gh-104773.)
I will switch to Python 3.12, but you might want to update the library to support future version of Python!
Thank you!
Hi @Mukei. First, thank you for your bug report. I take currency seriously - but haven't seen benefits in 3.12 or 3.13 for this project. Nevertheless it needs to run.
I discovered an issue with 3.12 - which I aim to get a fix out for soon. Another deprecated behaviour going away, of course.
I actually had trouble getting a 3.12 install to find python-pptx - but obviously I need to fix that.
What I think the current use of imghdr
is to recognise the dimensions (really proportions) of an image and its type. I'll have to see how I can replicate that function - preferably not creating another dependency (that might go away).
Anyhow, please do test on 3.12. I think you'll find it breaks there, too.
It looks like Pillow at a high enough level could do. (9.5.0 for 3.12?) We already make it an optional prereq. Probably have to make it a mandatory one.
I was wrong. imghdr is apparently just picking up the filetype for a graphic. Will have to think about how to do that differently. (Pillow is used for something else and can remain optional.)
This Stack Overflow article poses the idea that one could use the file extension:
filename.lower().endswith(('.png', '.jpg', '.jpeg', '.tiff', '.bmp', '.gif'))
I'm not wowed by this but maybe imghdr was doing little more than that.
Built not using imghdr but testing filename extensions. Please try the latest md2pptx file out. On 3.12 if you like. Or maybe 3.13. Let me know how it goes. I want to publish a release that says it supports 3.12.
My initial tests with 3.12.2 and 3.13.0a5 show md2pptx continuing to work. (Installed both via pyenv and installed python-pptx into each environment.)
Thanks to your opening this issue @Mukei I now know how to test with newer versions. That should help keep this (and mdpre) current. mdpre is part of my make-driven presentation build toolchain and it worked fine with 3.12 and 3.13.
Fixed and shipped in v4.4.
Closing. Please reopen if you don't consider it fixed.
After installing python-pptx and cloning the directory, I tried running my first markdown file conversion. Unfortunately, I ran into the below error.
Input
Output
Did I miss any steps?
I am using python 3.13, on OSX 14.3 (23D56).