[issue1559549] ImportError needs attributes for module and file name

2012-04-12 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
assignee: brian.curtin - brett.cannon

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2012-04-12 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 6825fd9b00ed by Brett Cannon in branch 'default':
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
http://hg.python.org/cpython/rev/6825fd9b00ed

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2012-04-12 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

Patch for the attributes is in (no use by import.c)! I'm going to do a separate 
commit for use by importlib and then fix pydoc in my bootstrap branch.

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2012-04-10 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

This is now officially blocking my importlib bootstrap work (issue #2377), so I 
have assigned this to myself to get done and I hope to get this committed 
within a week *without* updating Python/import.c and the requisite tests or 
pydoc (which I will make part of my merge instead). If Brian beats me to 
getting this checked in that's great, but otherwise I will get to it myself.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2012-02-10 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

The patch looks fine for its current semantics except for the fact that the 
macro doesn't work under clang; ##macro_var is supposed to be used only when 
concatenating parts of a string to create a complete identifier, not 
concatenating two identifiers next to each other (e.g. gooblede##gook is fine, 
but self-##gook isn't because '-' is its own identifier).

But one issue is that for my purposes I need 'name' to be the full name of the 
module, not just the tail of the full name. The reason is that pydoc needs a 
way to tell when a module import failed because the module isn't there vs. when 
a module had an actual error itself. Using the tail end of the name doesn't 
help me because it means I can't tell if an import of a module named 'bunk' 
containing the line 'import test.bunk' fails because the module 'bunk' doesn't 
exist or because the import line failed since in both cases name == 'bunk'. But 
if name == 'test.bunk' there is no ambiguity. Pydoc used to do this by 
inspecting the stack and seeing where the exception was thrown which is just 
nasty and brittle (i.e. doesn't work with importlib since the stack goes much 
farther until ImportError is thrown).

IOW I don't think we should be tossing out valuable data just because 
historically modules that didn't exist only returned the tail end of the full 
module name. Anyone object to switching to using the full name of the module 
triggering the exception? The message wouldn't change to use the full name 
(unfortunately) for backwards-compatibility reasons of course.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2012-02-10 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

And to answer David's joke, I carpool from Toronto to Waterloo four days a week 
so I have an hour each direction to work on stuff.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2012-02-10 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

Oh, and there are no forward declarations for the new functions added to 
errors.c

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2012-02-10 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

Attached is Brian's patch with the macro fix and forward declarations.

--
Added file: http://bugs.python.org/file24476/importerror.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2012-02-10 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

So I just tried to pass fullname in import.c and it didn't work (of course). 
Looks like even when I try to use fullname in find_module_path_list() and 
load_next() it is still leaving out the package name. Ugh. That means either 
refactoring import.c to get the full name in all places, not get the full name 
(and thus I'm still screwed), have importlib do something different than 
import.c in hopes that importlib replaces import.c before this goes public, or 
add a full_name attribute for importlib to fill in with the full details.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2012-02-10 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

However you do it, I'm very much in favor of having the full name available.  I 
either wrote or fixed (I can't remember which) that stack walk in pydoc, and 
you are right, it is very very ugly.  This would also be a big benefit for 
unittest, which currently *doesn't* do the stack walk and therefore generates 
incorrect error messages when sub-imports fail.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2012-02-09 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

On Thu, Feb 9, 2012 at 00:03, Brian Curtin rep...@bugs.python.org wrote:


 Brian Curtin br...@python.org added the comment:

 Yep, I just need to actually make use of the feature. I'll generate a new
 patch shortly.


If you can generate it before 17:30 EST today I can review it or at least
help use it in the codebase.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2012-02-09 Thread Brian Curtin

Brian Curtin br...@python.org added the comment:

Here's an updated patch which creates two convenience functions, 
PyErr_SetFromImportErrorWithName and PyErr_SetFromImportErrorWithNameAndPath. I 
figure the two common cases are that you'll want to set just a name or you'll 
want a name and a path.

*WithName is all that I've applied for now, and I've only done it in import.c 
to allow Brett to continue with his work. I'll come back and make changes 
elsewhere in the code, and I'll apply the *WithNameAndPath function where I 
need it for #10854.

All tests pass and some IRL testing works nicely.

Note: I'm a little rushed at the moment so I have not included docs but I will 
surely update them. I just want to get Brett what he needs by this afternoon.

--
Added file: http://bugs.python.org/file24467/issue1559549_v2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2012-02-09 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

Thanks, Brian! I'll do a review tonight on the drive home (and maybe even write 
the docs up).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2012-02-09 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

On the drive home...are you borrowing one of Google's self driving cars? :)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2012-02-08 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

Brian, what is left for updating your patch? I'm going to need this to fix 
test_pydoc to not fail in my importlib bootstrap work so I can (finally) help 
with this. Is it just actually using the new features of the exception?

--
assignee: brett.cannon - brian.curtin

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2012-02-08 Thread Brian Curtin

Brian Curtin br...@python.org added the comment:

Yep, I just need to actually make use of the feature. I'll generate a new patch 
shortly.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-12-16 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

fullname is technically wrong:

 import logging.bar
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: No module named 'bar'

module_name sounds fine and explicit enough to me. Also, as Eric points out, 
there are many places where an ImportError is raised. You might want to create 
a private helper API.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-12-16 Thread Brian Curtin

Brian Curtin br...@python.org added the comment:

I think I'm going to stick with name unless anyone is super opposed. If we can 
eventually import something else (sausages?), then setting module_name with a 
sausage name will seem weird.

I'll work up a more complete patch. The private helper is a good idea.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-12-15 Thread Eric Snow

Eric Snow ericsnowcurren...@gmail.com added the comment:

Just following up on this ticket.  Anyone have any objections to Brian's patch?

Also, would 'fullname' be more appropriate than 'name', to be more in sync with 
that identifier in importlib?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-12-15 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

The patch doesn't appear to have the necessary mechanics to pass the new 
arguments from the import machinery when an ImportError is raised, is this 
deliberate?

Also, I'm not sure why the new arguments are keyword-only.

--
nosy: +pitrou
stage: test needed - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-12-15 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

The keyword-only idea is a backwards compatibility hack we discussed at the 
PyCon US sprints because ImportError currently accepts an arbitrary number of 
arguments:

 raise ImportError(1, 2, 3)
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: (1, 2, 3)

We don't really want to be claiming that the module name is some strange value 
due to existing code that passes multiple arguments, hence the suggestion to 
make this a keyword-only argument.

Regarding import.c, I think Brian misinterpreted Brett's last message. import.c 
absolutely *should* be modified by this patch, since it's still the default 
import implementation for the moment. Brett's comment was just to say that *he* 
wasn't going to do that part, since his aim with the importlib bootstrapping 
exercise is to nuke most of import.c from orbit :)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-12-15 Thread Eric Snow

Eric Snow ericsnowcurren...@gmail.com added the comment:

I'm guessing that more than just Python/import.c should be updated, and more 
than one spot in import.c.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com




[issue1559549] ImportError needs attributes for module and file name

2011-12-15 Thread Brian Curtin

Brian Curtin br...@python.org added the comment:

If I add back in the import.c change, would this then be alright?

Eric - fullname seems fine, I'll update that.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com




[issue1559549] ImportError needs attributes for module and file name

2011-10-25 Thread Brian Curtin

Brian Curtin br...@python.org added the comment:

Here's an updated patch, plus support for a second attribute that I need for 
#10854. I previously wrote a patch that does this same thing for that issue, 
but this one handles things a lot more nicely :)

I renamed module_name to just be name since I was adding path and didn't 
want to have to name it module_path and have two module_ attributes since I 
think it's clear what they are for. We can go back to module_ names if you 
want - no big deal.

It's really just the same patch as before but updated for a few minor changes 
(the ComplexExtendsException sig changed), and the moving of keyword handling 
in ImportError_init into a macro since we have to do the same initialization 
twice now. I'm not married to that implementation, it just minimized 
duplication and seems to work alright.

Also, this removes the import.c change (see Brett's last message).

--
nosy: +brian.curtin
Added file: http://bugs.python.org/file23522/issue1559549.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-08-16 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

I have a use for this in my bootstrapping for importlib, so I am assigning this 
to myself in order to make sure that at least ImportError grows the needed 
keyboard argument and attribute. I will probably not bother with tweaking 
import.c, though.

--
assignee:  - brett.cannon

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-07-13 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

How about this case:

  from validmodule import name_with_typo

Do we need one keyword argument module_name and one attribute_name?

--
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-07-13 Thread Eric Snow

Changes by Eric Snow ericsnowcurren...@gmail.com:


--
nosy: +ericsnow

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-07-13 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

No, we don't need attribute_name as that is getting too specific. Your example 
is simply importing validmodule.name_with_typo which happens to possibly be an 
attribute on the module instead of another module or subpackage.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-03-18 Thread Filip Gruszczyński

Changes by Filip Gruszczyński grusz...@gmail.com:


Removed file: http://bugs.python.org/file21020/1559549_1.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-03-18 Thread Filip Gruszczyński

Changes by Filip Gruszczyński grusz...@gmail.com:


Removed file: http://bugs.python.org/file21031/1559549_2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-03-18 Thread Filip Gruszczyński

Filip Gruszczyński grusz...@gmail.com added the comment:

Ok, here is a patch created using mq. I have a problem, however. I managed to 
solve following situation:

try:
raise ImportError('failed import' module_name='somemodule')
except ImportError as e:
print(e.module_name)

that would print somemodule.

However, I can't pass kwargs to ImportError_init from load_next. If someone 
could instruct me, how this can be achieved, I'll be happy to do that.

--
Added file: http://bugs.python.org/file21284/1559549_3.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-03-16 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

At the PyCon 2011 sprint we discussed this issue and Nick, myself, and some 
other people agreed that using a keyword-only argument for passing in the 
module name is probably a better solution. While it won't be 
backwards-compatible (BaseException does not accept keyword arguments), it does 
provide a very clean API with an unambiguous way of specifying the module. 
Going another route (e.g., a constructor method) has the same 
backwards-compatibility issue. But a reason to use a solution other than the 
magical handling of the second argument is that it prevents doing the wrong 
thing simply because someone passes two or more arguments to ImportError.

Another nicety of a new API for ImportError is that it can be made such that if 
the keyword-only argument ('module_name'?) is the only thing supplied (e.g., no 
positional arguments) then the message can be auto-generated, which would be a 
nice way to solve issue #8754.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-03-16 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

+1 for providing a way to autogenerate the message.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-03-15 Thread Nick Coghlan

Changes by Nick Coghlan ncogh...@gmail.com:


--
nosy: +ncoghlan

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-03-15 Thread Filip Gruszczyński

Filip Gruszczyński grusz...@gmail.com added the comment:

I didn't know about this mq extension. I will do a proper patch with a test 
after friday.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-03-14 Thread Andreas Stührk

Andreas Stührk andy-pyt...@hammerhartes.de added the comment:

 I am sorry again for those mistakes, it's all completely new to me.

No worries!

I have fixed those issues and created new patch. Using hg export, that now 
spans over two commits. Is it the way those patches should be provided, or 
should I gather all changes into a one commit?

A single patch (where all changesets are flattened into one) is the
preferred way. For general advice, you can read the Developer's Guide
at http://docs.python.org/devguide/ (e.g.
http://docs.python.org/devguide/patch.html).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-03-07 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

The module name is a UTF-8 encoded string yes. It should be documented in 
PyModuleDef structure. I already documented the encoding in PyModule_New().

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-03-07 Thread Filip Gruszczyński

Filip Gruszczyński grusz...@gmail.com added the comment:

I am sorry again for those mistakes, it's all completely new to me. I have 
fixed those issues and created new patch. Using hg export, that now spans over 
two commits. Is it the way those patches should be provided, or should I gather 
all changes into a one commit?

--
Added file: http://bugs.python.org/file21031/1559549_2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-03-06 Thread Filip Gruszczyński

Filip Gruszczyński grusz...@gmail.com added the comment:

This is a draft of a patch. I have only used this new ImportError api in once 
place, so it would work with following code:

 try:
...  import nosuchmodule  
... except ImportError as e:
...  print(e.module)
... 
nosuchmodule

I have literally no experience with Python core, so I would be very grateful 
for comments and advice, so I could make this patch meet all requirements.

--
keywords: +patch
Added file: http://bugs.python.org/file21020/1559549_1.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-03-06 Thread Andreas Stührk

Andreas Stührk andy-pyt...@hammerhartes.de added the comment:

There are some issues with the patch:

- The check for size of `args` in `ImportError_init()` is wrong: You can't 
create an `ImportError` with 3 arguments now (TypeError: ImportError expected 
2 arguments, got 3)
- `ImportError_clear()` doesn't clear ``self-msg``.
- `ImportError_str()` doesn't increase the reference count for ``self-msg`` 
before returning it.
- The code that raises the exception (Python/import.c) doesn't check for error 
return values: All the calls can return NULL which will cause a segfault due to 
the uncoditional Py_DECREFs.
- Using `PyUnicode_DecodeASCII()` for the module name is wrong (IMHO), it 
should rather be something like `PyUnicode_DecodeUTF8()` as module names can 
contain non-ASCII characters in Python 3 and are AFAIK (at least right now) 
always encoded using utf-8.

--
nosy: +Trundle, haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-03-02 Thread Filip Gruszczyński

Changes by Filip Gruszczyński grusz...@gmail.com:


--
nosy: +gruszczy

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-03-01 Thread Ram Rachum

Changes by Ram Rachum cool...@cool-rr.com:


--
nosy: +cool-RR

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-01-07 Thread anatoly techtonik

anatoly techtonik techto...@gmail.com added the comment:

I think we should investigate deeper why this enhancement request didn't get 
into Python 3.

Another user story is: from xxx import yyy, if yyy not found, the args 
message is ('cannot import name yyy',)

Python4?

label:api

--
nosy: +techtonik

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-01-07 Thread Brian Curtin

Changes by Brian Curtin cur...@acm.org:


--
versions: +Python 3.3 -Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-01-07 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

There's no need for any deeper investigation.  The answer is nobody wrote the 
patch.  If someone writes a good patch, it will go in.

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-01-07 Thread Alexander Belopolsky

Alexander Belopolsky belopol...@users.sourceforge.net added the comment:

 I think we should investigate deeper why this enhancement
 request didn't get into Python 3.

There is nothing to investigate here.  This is a request for a marginal 
improvement and OP did not follow up even though a core developer responded on 
the next day after his post.

The only lesson to be learned from this is that Python improvements should be 
discussed on the tracker or appropriate python mailing lists and not on private 
blogs.

--
nosy: +belopolsky

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2011-01-07 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' g.rod...@gmail.com:


--
nosy: +giampaolo.rodola

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2010-08-08 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
versions: +Python 3.2 -Python 2.7, Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2009-03-29 Thread Daniel Diniz

Changes by Daniel Diniz aja...@gmail.com:


--
nosy: +brett.cannon
stage:  - test needed
versions: +Python 2.7, Python 3.1 -Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1559549
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1559549] ImportError needs attributes for module and file name

2008-01-06 Thread Christian Heimes

Changes by Christian Heimes:


--
versions: +Python 2.6

_
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1559549
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com