Skip to content

Support PathLike image and package file inputs#1123

Open
AlexanderWillner wants to merge 1 commit intoscanny:masterfrom
AlexanderWillner:codex/pathlike-file-inputs
Open

Support PathLike image and package file inputs#1123
AlexanderWillner wants to merge 1 commit intoscanny:masterfrom
AlexanderWillner:codex/pathlike-file-inputs

Conversation

@AlexanderWillner
Copy link
Copy Markdown

Summary

  • accept os.PathLike inputs in Image.from_file()
  • accept os.PathLike inputs in Part._blob_from_file()
  • add regression coverage for pathlib.Path file inputs

Why

python-pptx currently treats only str values as file paths in these helpers. Passing pathlib.Path falls through to the file-like branch and raises an AttributeError on .seek/.read assumptions.

Testing

  • PYTHONPATH=src python -m pytest tests/parts/test_image.py -q
  • PYTHONPATH=src python -m pytest -o filterwarnings=ignore::pyparsing.warnings.PyparsingDeprecationWarning tests/opc/test_package.py tests/test_package.py -q
  • smoke-tested slide.shapes.add_picture(Path(...), ...) with a JPEG fixture

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant