Support PathLike image and package file inputs by AlexanderWillner · Pull Request #1123 · scanny/python-pptx

Skip to content

Navigation Menu

Sign in

Appearance settings

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@AlexanderWillner