GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `__future__` imports allow dots before them · Issue #118216 · python/cpython

__future__ imports allow dots before them #118216

New issue
Copy link
New issue
Copy link
Closed
Closed
__future__ imports allow dots before them#118216
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@thatbirdguythatuknownot
thatbirdguythatuknownot
opened on Apr 24, 2024
Issue body actions

Bug report

Bug description:

__future__ imports don't check the amount of dots while checking from-import nodes for the module name, so they are still valid even if dots are put before the module name.

>>> from .__future__ import barry_as_FLUFL
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    from .__future__ import barry_as_FLUFL
ImportError: attempted relative import with no known parent package
>>> 1 <> 2
True

Is this intended? Allowing dots before the module name seems improper considering __future__ is supposed to be part of the stdlib.

CPython versions tested on:

3.12, 3.13

Operating systems tested on:

Windows

Linked PRs

  • gh-118216: Don't consider dotted __future__ imports #118267

Activity

  1. thatbirdguythatuknownot
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Apr 24, 2024
  2. terryjreedy
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Apr 24, 2024
  3. terryjreedy commented on Apr 24, 2024

    @terryjreedy
    terryjreedy
    on Apr 24, 2024
    Member
    More actions

    What is weird is both raising an error and doing the pseudoimport anyway.

    Reacted by Alex Waygood and Gouvernathor
  4. JelleZijlstra
    added a commit that references this issue on May 2, 2024

    gh-118216: Don't consider dotted `__future__` imports (#118267)

    7c97dc8
  5. JelleZijlstra commented on May 2, 2024

    @JelleZijlstra
    JelleZijlstra
    on May 2, 2024
    Member
    More actions

    Thanks @thatbirdguythatuknownot!

    I merged the fix into main (3.13), so I'm closing this.

    Arguably this is a bug that could also be fixed in 3.12, but I'd prefer to leave 3.12 unchanged, as the bug is rather harmless in practice and I feel core language behavior shouldn't change in a bugfix release.

    Reacted by Alex Waygood and CoolCat467
  6. JelleZijlstra
    closed this as completedon May 2, 2024
  7. SonicField
    added a commit that references this issue on May 8, 2024

    pythongh-118216: Don't consider dotted `__future__` imports (python#1…

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.