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 — bpo-29546: Set path on ImportError for from ... import by Carreau · Pull Request #91 · python/cpython

Conversation

@Carreau

@Carreau Carreau commented Feb 14, 2017

Copy link
Copy Markdown
Contributor

And path as well when existing.

See bpo-29546

This is a step toward providing better error messages in case of
from-import. Barry Warsaw Proposed:

cannot import name {name} from {module} ({path})

But that's probably going to trigger more discussions that filling in
already existing fields.


I'm not familiar with C-internal of CPython, So let me know if I'm doing things wrong.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Feb 14, 2017
brettcannon
brettcannon reviewed Feb 14, 2017
View reviewed changes
Comment thread Python/ceval.c Outdated

@brettcannon brettcannon Feb 14, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a missing space between the final ) and {.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Carreau Carreau Feb 14, 2017

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dang. Fixed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@brettcannon

brettcannon commented Feb 14, 2017

Copy link
Copy Markdown
Member

I have not dug into the surrounding code, but the general approach LGTM.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Carreau
Carreau force-pushed the betterimport branch from bd14cf2 to d3aff79 Compare February 14, 2017 18:27
@brettcannon

brettcannon commented Feb 14, 2017

Copy link
Copy Markdown
Member

I also just realized there's no test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

brettcannon
brettcannon requested changes Feb 14, 2017
View reviewed changes

@brettcannon brettcannon left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Carreau

Carreau commented Feb 14, 2017

Copy link
Copy Markdown
Contributor Author

I also just realized there's no test.

Yes I realized that as well :-) Will do .

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

brettcannon
brettcannon requested changes Feb 14, 2017
View reviewed changes
Comment thread Lib/test/test_import/__init__.py Outdated

@brettcannon brettcannon Feb 14, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't include docstrings on tests (and we PEP 8 doesn't allow starting a docstring with a newline).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_import/__init__.py Outdated

@brettcannon brettcannon Feb 14, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do an assertEqual check using os.__file__?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Carreau Carreau Feb 14, 2017

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_import/__init__.py Outdated

@brettcannon brettcannon Feb 14, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The custom message isn't necessary as what the test is checking is obvious (same goes for all of the other messages).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_import/__init__.py Outdated

@brettcannon brettcannon Feb 14, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you can't use with self.assertRaises()?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Carreau Carreau Feb 14, 2017

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just forgot you could access the exception after the fact with contextmanager.exception so I indeed I can ans should use it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_import/__init__.py Outdated

@brettcannon brettcannon Feb 14, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary blank line.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Carreau
Carreau force-pushed the betterimport branch 2 times, most recently from 3f218f5 to 30a5055 Compare February 14, 2017 21:57
brettcannon
brettcannon requested changes Feb 14, 2017
View reviewed changes
Comment thread Lib/test/test_import/__init__.py Outdated

@brettcannon brettcannon Feb 14, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo" cannonical" -> "canonical"

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Carreau Carreau Feb 14, 2017

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to find a linter that understand both programming and english.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_import/__init__.py Outdated

@brettcannon brettcannon Feb 14, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a test for path, even if it's just checking it isn't None?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Carreau Carreau Feb 14, 2017

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could, but that's taken care of by functions above. Here I'm just checking that it's not os.path.
Anyway while I'm at it I will add an assertIsNotNone.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_import/__init__.py Outdated

@brettcannon brettcannon Feb 14, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment like # _warning has no path as it's a built-in module.? I keep forgetting why this specific case doesn't have a path. 😄

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Carreau Carreau Feb 14, 2017

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too early in the bootstrap process ?
Anyway. Done.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Carreau
Carreau force-pushed the betterimport branch from 30a5055 to 32e42aa Compare February 14, 2017 22:39
@codecov

codecov Bot commented Feb 14, 2017

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@6de2b78). Click here to learn what that means.
The diff coverage is 64.28%.

@@            Coverage Diff            @@
##             master      #91   +/-   ##
=========================================
  Coverage          ?   82.38%           
=========================================
  Files             ?     1428           
  Lines             ?   351163           
  Branches          ?        0           
=========================================
  Hits              ?   289314           
  Misses            ?    61849           
  Partials          ?        0

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6de2b78...32e42aa. Read the comment docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@berkerpeksag

berkerpeksag commented Feb 14, 2017

Copy link
Copy Markdown
Member

BTW, please rebase your branch so we can get rid of these Codecov comments :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Carreau added 2 commits February 14, 2017 14:48
@Carreau
bpo-29546: Set name on ImportError for from ... import
ab2cb0e
And `path` as well when existing.

See bpo-29546

This is a step toward providing better error messages in case of
from-import. Barry Warsaw Proposed:

   cannot import name {name} from {module} ({path})

But that's probably going to trigger more discussions that filling in
already existing fields.
@Carreau
Add test for the from ... import behavior.
7456cfc
Make sure they name and path are set in various case.
@Carreau
Carreau force-pushed the betterimport branch from 32e42aa to 7456cfc Compare February 14, 2017 22:48
@Carreau

Carreau commented Feb 14, 2017

Copy link
Copy Markdown
Contributor Author

BTW, please rebase your branch so we can get rid of these Codecov comments :)

Oh gosh 71 was merged ? Thanks you! and done.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brettcannon brettcannon changed the title bpo-29546: Set name on ImportError for from ... import bpo-29546: Set path on ImportError for from ... import Feb 14, 2017
brettcannon
brettcannon approved these changes Feb 14, 2017
View reviewed changes
@brettcannon

brettcannon commented Feb 14, 2017

Copy link
Copy Markdown
Member

LGTM! Thanks for sticking through it, @Carreau !

Please add yourself to Misc/ACKS if you're not already there and add an entry into Misc/NEWS like:

bpo-29546: Set the 'path' attribute on ImportError for ``from ... import ...``.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Carreau

Carreau commented Feb 14, 2017

Copy link
Copy Markdown
Contributor Author

changed the title from bpo-29546: Set name on ImportError for from ... import to bpo-29546: Set path on ImportError for from ... import

Well actually good point that's setting both name and path. Name was not set either if that matters.

Please add yourself to Misc/ACKS if you're not already there and add an entry into Misc/NEWS like:

Sure !

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Carreau
Add entry into Misc/NEWS
96b967a
@brettcannon

brettcannon commented Feb 14, 2017

Copy link
Copy Markdown
Member

Thanks! As soon as Travis is green I'll merge.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Carreau

Carreau commented Feb 15, 2017

Copy link
Copy Markdown
Contributor Author

Thanks! As soon as Travis is green I'll merge.

Thanks. I don't know how disturbing the migration has been from your end (and other core dev).
From my side being able to use git and PRs was great.

Many kudos for having worked on the migration for so long.

brettcannon reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brettcannon
brettcannon merged commit bc4bed4 into python:master Feb 15, 2017
@brettcannon

brettcannon commented Feb 15, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Merged! Thanks again!

And I'm glad that the new workflow worked out for you! As for me, the new workflow let me review this PR throughout the day when I had time and do it entirely in the browser so I didn't have to remember to commit it when I got home (if I had to cherry-pick that would not have been the case, but I could at least merge now and cherry-pick later if need be).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Carreau
Carreau deleted the betterimport branch February 15, 2017 00:08
@Carreau

Carreau commented Feb 15, 2017

Copy link
Copy Markdown
Contributor Author

if I had to cherry-pick that would not have been the case

Hopping you will get the cherry-pick bot soon. Thanks for the time you've put into this.
I probably owe you a "orange juice, root beer, or Canada Dry," when we meet IRL.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brettcannon

brettcannon commented Feb 15, 2017

Copy link
Copy Markdown
Member

@Carreau the bot would be great, but at worst me or someone else can write a Python script probably to automate it locally if necessary (which reminds me, I should write that idea down over on core-workflow).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Carreau

Carreau commented Feb 15, 2017

Copy link
Copy Markdown
Contributor Author

which reminds me, I should write that idea down over on core-workflow

You did python/core-workflow#8 (Bot to automatically generate cherry-picking PRs)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@warsaw

warsaw commented Feb 15, 2017

Copy link
Copy Markdown
Member

Wow, I'm very pleasantly impressed at how quickly my bug/idea went to (nearly) implemented through the new workflow. Kudos!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Carreau Carreau mentioned this pull request Feb 15, 2017
bpo-29546: Improve from-import error message with location #103
Merged
@Carreau

Carreau commented Feb 15, 2017

Copy link
Copy Markdown
Contributor Author

Wow, I'm very pleasantly impressed at how quickly my bug/idea went to (nearly) implemented through the new workflow. Kudos!

Happy to repay a bit for all the work you did.

It's also much easier to decide to implement if a core dev have pitched in the idea, as it has more chance to be accepted. Thanks both !

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Carreau added a commit to Carreau/cpython that referenced this pull request Feb 20, 2017
@Carreau
bpo-29546: Improve from-import error message with location
a181463
Add location information like canonical module name where identifier
cannot be found and file location if available.

First iteration of this was pythongh-91
akruis pushed a commit to akruis/cpython that referenced this pull request Sep 9, 2017
Anselm Kruis
Stackless issue python#91: unbinding a tasklet does not reset the rec…
b6af5e9
…ursion depth

Reset the recursion depth in PyTasklet_BindEx and add a few asserts.
This fixes issue python#91.
Add a test case for the recursion depth and as test case for an assertion failure caused by this bug.

https://bitbucket.org/stackless-dev/stackless/issues/91
(grafted from 1584a89fca366f66dadf3cf04f0306dd45b1372f and 380b70b1933d)
jaraco pushed a commit that referenced this pull request Dec 2, 2022
@pyup-bot @Mariatta
Update celery from 4.1.0 to 4.1.1 (#91)
8ef6673
@gvanrossum gvanrossum mentioned this pull request Aug 22, 2023
heap-use-after-free in _PyFunction_LookupByVersion #108253
Closed
@ngoldbaum ngoldbaum mentioned this pull request Sep 23, 2024
Crash running PyO3 tests with --test-threads=1000 #124375
Closed
This was referenced Feb 11, 2025
segmentfault when pip installing setuptools #129992
Closed
segmentfault when pip installing setuptools #129993
Closed
@sergey-miryanov sergey-miryanov mentioned this pull request Dec 18, 2025
Observed memory leak in ssl library: Python 3.14 GC issue #142516
Closed
SonicField added a commit to SonicField/cpython that referenced this pull request Apr 23, 2026
@SonicField
W45: bridge-signature drift falsifier script
7feb38b
Implements scripts/w45_bridge_drift_falsifier.sh per
docs/w45-bridge-signature-drift-falsifier.md.

Mutate-Build-Verify-Restore loop:
- Mutates a bridge signature (extern "C" decl in builder.cpp + function
  definition in builder_emit_c.c, in lockstep) by appending a sentinel
  param 'int phx_w45_drift'.
- Verifies the build fails at the C++ dispatch-switch call site (which
  has the OLD arity).
- Restores both files; clean rebuild verifies tree state.

Catches the structural drift class identified by pythia python#90/python#91:
void* args at the bridge crossing erase the type-safety C++ overload
resolution would normally provide. 252+ dispatch sites in builder.cpp
post Phase 1 burndown — manual audit unscalable.

Initial 6 fixtures (per spec §2.2 + §2.6 retro):
- hir_builder_emit_before_with_c (Phase 1 python#6 retro)
- hir_builder_emit_setup_with_c (Phase 1 python#7 retro)
- hir_builder_emit_format_simple_c (Phase 1 python#2 sample)
- hir_builder_emit_copy_free_vars_c (Phase 1 python#4 sample)
- hir_builder_emit_get_yield_from_iter_c (Phase 1 python#4 sample)
- hir_builder_emit_primitive_load_const_c (Phase 1 python#5 sample)

Modes:
- --dry-run: stage mutations, no build (any agent — bypass build lock)
- --strict: exit 1 on FAIL (for gate integration)
- --verbose: show build stderr

Uses perl -0777 multi-line slurp for robust parsing of multi-line
extern decls + function definitions. Mutation marker (phx_w45_drift)
verified post-mutation to guard against silent no-op substitutions.

Build lock: BUILD mode invokes cmake --build --target jit; per CLAUDE.md
Phase 3D Build Lock, only testkeeper / gate_phoenix.sh may invoke with
builds enabled. --dry-run is unrestricted.

Authorization: theologian 21:55:24Z + supervisor 21:55:36Z + 22:33:17Z
DISPOSITION (C). §3.5 fold-into-C derivation falsifier (opcode-constant
shadow class) is deferred — needs W21 golden integration.

Sibling workstreams: W33 (zero-bridge verifier), W42 (refcount
correctness), W44 (DO-NOT-USE caller gate).
SonicField added a commit to SonicField/cpython that referenced this pull request Apr 23, 2026
@SonicField
W45 fix: cmake build dir path (CMAKE_BUILD_DIR=Python/jit_build/build)
5c91add
Per testkeeper 22:44:12Z STRICT VERIFY: BUILD MODE was running
'cmake --build .' from REPO_ROOT, but cmake build dir is
Python/jit_build/build. All 6 fixtures errored with "not a CMake build
directory" → counted as FAIL → false GATE FAIL.

Fix: introduce CMAKE_BUILD_DIR variable + pass to both cmake calls
(per-fixture build at L153, post-restore rebuild at L194).

Concept already EMPIRICALLY VERIFIED by testkeeper manual sanity-test
on hir_builder_emit_format_simple_c — build failed at builder.cpp:2492
with "no matching function" + "candidate function not viable: requires
4 arguments, but 3 were provided". Exact void*-arg-erasure detection
pythia python#90/python#91 named.

Post-fix expected: 6/6 PASS in BUILD MODE.
@alexkats alexkats mentioned this pull request May 18, 2026
gh-149816: Fix UAF in Modules/_pickle.c #150024
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@brettcannon brettcannon brettcannon approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@Carreau @brettcannon @berkerpeksag @warsaw @the-knights-who-say-ni
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.