r/Python • • 14h ago

Discussion More Python projects should test what they actually ship, not just what's in the repository

60 Upvotes

A surprisingly embarrassing category of Python bugs is the stuff that works perfectly in development but breaks after installing the actual wheel.

Missing template files, undeclared dependencies, paths that assume you're running from the project root, etc.

I've become quite fond of having a separate CI job that builds the wheel, installs it into a fresh environment and runs a few basic functionality checks from an unrelated directory.

Nothing elaborate. Just enough to experience the package the way an actual user would.

It's interesting how much attention we give to test coverage while sometimes neglecting to test the very artifact we're distributing.

Editable installs are great for development, but I think they can make us a little too comfortable.


r/Python • • 17h ago

Discussion Python's tar extract filter can still be steered by a link entry.

0 Upvotes

filter="tar" was supposed to keep extractall inside the destination directory. A crafted symlink, including one with an empty or directory-like name, can point a later member outside that directory. The write still depends on the permissions of the process doing the extract. This is the tar filter version of the earlier data filter bypass. If you extract archives with filter="tar", are you pinning a Python build that rejects those link names, or still trusting the filter on its own? https://mail.python.org/archives/list/security-announce@python.org/2026/11/


r/Python • • 19h ago

Discussion PEP 671 – Syntax for late-bound function argument defaults

47 Upvotes

https://peps.python.org/pep-0671/

The PEP was originally proposed in October 2021 but didnt get much traction. Through some discussions on the python discuss the author picked it up again and reproposed it for 3.17

It proposes a new syntax argument => late_bound_default()

def add_item(item, target=>[]):
def bisect_right(a, x, lo=0, hi=>len(a), *, key=None):

for late binding of argument defaults. This would allow avoiding the common mutable default argument trap and would allow for defaults to refer to previous arguments as seen in the biset_right example above.

Discussion can be found here: https://discuss.python.org/t/pep-671-syntax-for-late-bound-function-argument-defaults/110297

Note: I am not the PEP author


r/Python • • 8h ago

Daily Thread Saturday Daily Thread: Resource Request and Sharing! Daily Thread

2 Upvotes

Weekly Thread: Resource Request and Sharing 📚

Stumbled upon a useful Python resource? Or are you looking for a guide on a specific topic? Welcome to the Resource Request and Sharing thread!

How it Works:

  1. Request: Can't find a resource on a particular topic? Ask here!
  2. Share: Found something useful? Share it with the community.
  3. Review: Give or get opinions on Python resources you've used.

Guidelines:

  • Please include the type of resource (e.g., book, video, article) and the topic.
  • Always be respectful when reviewing someone else's shared resource.

Example Shares:

  1. Book: "Fluent Python" - Great for understanding Pythonic idioms.
  2. Video: Python Data Structures - Excellent overview of Python's built-in data structures.
  3. Article: Understanding Python Decorators - A deep dive into decorators.

Example Requests:

  1. Looking for: Video tutorials on web scraping with Python.
  2. Need: Book recommendations for Python machine learning.

Share the knowledge, enrich the community. Happy learning! 🌟