Brett Cannon added the comment:
Catching the AttributeError is in case a loader is used that doesn't define
init_module_attrs(). Since it will be new to Python 3.4 I can't guarantee that
it will exist (in case someone doesn't subclass
Brett Cannon added the comment:
If you would prefer to keep using imp in IDLE to make management across
versions easier I'm fine with that, just understand my goal is to deprecate imp
in Python 3.4 (but won't remove it until Python 4 so people can write Python
2/3 compatible code,
New submission from Brett Cannon:
If you import the frozen __phello__ package, you will notice that
__phello__.__path__ == ['__phello__']. While that seems innocuous, that could
potentially lead to incorrect results if there just so happens to be a
directory named __phello__ which
Brett Cannon added the comment:
In the common case of SourceLoader it will set __loader__, __package__,
__file__, and __cached__.
--
___
Python tracker
<http://bugs.python.org/issue17
New submission from Brett Cannon:
importlib.util.module_for_loader (as well as set_package and set_loader) only
set those attributes either when they are not already set or when the module is
new. I realized this is a problem as it means a reload won't work the way one
might expect.
I
New submission from Brett Cannon:
I'm contemplating adding an implementation of
importlib.abc.InspectLoader.get_code() which relies on get_source() (and then
another version in ExecutionLoader which uses get_filename()). The reason I'm
hesitant is get_source() is often an expensive
Changes by Brett Cannon :
--
nosy: +eric.smith
___
Python tracker
<http://bugs.python.org/issue18072>
___
___
Python-bugs-list mailing list
Unsubscribe:
Changes by Brett Cannon :
--
assignee: -> brett.cannon
___
Python tracker
<http://bugs.python.org/issue18070>
___
___
Python-bugs-list mailing list
Unsubscri
Changes by Brett Cannon :
--
assignee: -> brett.cannon
___
Python tracker
<http://bugs.python.org/issue18072>
___
___
Python-bugs-list mailing list
Unsubscri
Brett Cannon added the comment:
So it turns out I will simply have to make the methods not abstract anymore.
Thanks to multiple inheritance I can't implement the method in ExecutionLoader
and keep it abstract in case someone subclasses InspectLoader and then creates
another subcla
New submission from Brett Cannon:
If you run any test that has infinite recursion (test_json test_exceptions
test_sys test_runpy) it will segfault with a fresh checkout under OS X 10.8.3
using Clang. Not sure how widespread this is.
I did check that I am using a clean checkout of the default
Changes by Brett Cannon :
--
resolution: -> fixed
stage: -> committed/rejected
status: open -> closed
___
Python tracker
<http://bugs.python.or
New submission from Brett Cannon:
Right now importlib.abc.SourceLoader implements get_source(), but most of it is
decoding bytes properly. That should probably be abstracted out to
importlib.util so that it's available even for loaders which don't provide
get_data() or ge
Changes by Brett Cannon :
--
assignee: -> brett.cannon
___
Python tracker
<http://bugs.python.org/issue18055>
___
___
Python-bugs-list mailing list
Unsubscri
Brett Cannon added the comment:
LGTM
--
assignee: -> ronaldoussoren
___
Python tracker
<http://bugs.python.org/issue18075>
___
___
Python-bugs-list mai
Brett Cannon added the comment:
Wow, I didn't even know that file existed. It could actually help with some
static analysis of the C code to verify that the refcounts are as expected w/o
actually having to do inter-procedural analysis to figure out all of the
refcount values. I wond
Changes by Brett Cannon :
--
assignee: -> brett.cannon
___
Python tracker
<http://bugs.python.org/issue15767>
___
___
Python-bugs-list mailing list
Unsubscri
Changes by Brett Cannon :
--
resolution: -> fixed
stage: test needed -> committed/rejected
status: open -> closed
___
Python tracker
<http://bugs.python.or
New submission from Brett Cannon:
There is no good reason to have set_loader and set_package separately. There
should just be a single decorator which sets both of those attributes
post-import (with the proper doc note saying use module_for_loader instead when
possible to have the attributes
New submission from Brett Cannon:
There are a bunch of attributes that need to be set on a module, and yet they
are only handled by various decorators in importlib.util. The problem with that
is there is no way in the API to override or expand upon setting those
attributes pre-loading; only
Changes by Brett Cannon :
--
resolution: -> rejected
status: open -> closed
superseder: -> Create importlib.abc.Loader.init_module_attrs()
___
Python tracker
<http://bugs.python.or
Changes by Brett Cannon :
--
dependencies: +Create importlib.abc.Loader.init_module_attrs()
___
Python tracker
<http://bugs.python.org/issue18089>
___
___
Pytho
New submission from Brett Cannon:
--
assignee: brett.cannon
components: Library (Lib)
messages: 190261
nosy: brett.cannon
priority: normal
severity: normal
stage: test needed
status: open
title: Create importlib.abc.InspectLoader.load_module()
type: enhancement
versions: Python 3.4
Brett Cannon added the comment:
New changeset e873f2e67353 by Brett Cannon in branch 'default':
Issues #18088, 18089: Introduce
http://hg.python.org/cpython/rev/e873f2e67353
--
resolution: -> fixed
stage: test needed -> committed/rejected
status
Changes by Brett Cannon :
--
resolution: -> fixed
stage: test needed -> committed/rejected
status: open -> closed
___
Python tracker
<http://bugs.python.or
New submission from Brett Cannon:
_imp.init_frozen is not really necessary; you can implement imports entirely
using the other frozen-related functions. Because of that it's probably better
to simply rewrite PyImport_ImportFrozenModuleObject() to use importlib to make
the code easi
New submission from Brett Cannon:
BuiltinImporter, FrozenImporter, and ExtensionFileLoader all have their own
custom code to manage clearing sys.modules if something goes wrong. Should see
if any of them would break if they used importlib.util.module_to_load. And if
they would break thanks to
Changes by Brett Cannon :
--
resolution: -> fixed
stage: test needed -> committed/rejected
status: open -> closed
___
Python tracker
<http://bugs.python.or
Brett Cannon added the comment:
Turns out BuiltinImporter doesn't like having a pre-existing module, so a new
keyword argument will be necessary to allow for only the cleanup code to run
and not the construction of a new module.
--
___
P
Changes by Brett Cannon :
--
stage: -> patch review
___
Python tracker
<http://bugs.python.org/issue18021>
___
___
Python-bugs-list mailing list
Unsubscri
Changes by Brett Cannon :
--
stage: patch review -> needs patch
___
Python tracker
<http://bugs.python.org/issue18021>
___
___
Python-bugs-list mailing list
Un
Brett Cannon added the comment:
I'm going to toss Armin's request over to core-mentorship since the fix is
easy. Is all you are after, Armin, a ``not os.path.isfile(cfile) or
os.path.islink(cfile)`` check which if true raises an exception?
--
assignee: brett.cannon ->
s
New submission from Brett Cannon:
I have not had test_distutils succeed in ages. It looks like various header
files are not being passed to the compiler properly as all three test failures
stem from PyModuleDef_HEAD_INIT supposedly not existing or some other macro.
Below is an example failure
Brett Cannon added the comment:
Armin: I'm going off of http://bugs.python.org/msg189428 where you say you want
an exception raised. If there is something else you want to suggest that's fine
as long as it's not to revert the semantics since I'm no
Brett Cannon added the comment:
Thanks for the clarification, Armin!
--
___
Python tracker
<http://bugs.python.org/issue17222>
___
___
Python-bugs-list mailin
Brett Cannon added the comment:
OK, so here was what a patch will need:
* Change py_compile to raise an exception when ``not os.path.isfile(cfile) or
os.path.islink(cfile)``; probably raise ValueError and mention that import
itself would replace the file w/o raising an exception
* Add tests
Brett Cannon added the comment:
You use importlib.import_module to do programmatic imports (and FYI dots never
go into the first argument of __import__).
--
___
Python tracker
<http://bugs.python.org/issue17
Brett Cannon added the comment:
I have no clue what is being returned by this function. Any chance of using
types.SimpleNamespace to give meaningful names to the returned values instead
of a tuple?
--
nosy: +brett.cannon
___
Python tracker
<h
Brett Cannon added the comment:
If you look at the importlib source code in 2.7 it's actually really small and
simply translates the call into an __import__ call under the hood. So
__import__ can completely handle relative imports, but you were not using the
level argument to __import_
Brett Cannon added the comment:
I'm going to resolve this issue myself, but "blog" about it on core-mentorship
so others can follow along with how I resolve the bug.
--
assignee: -> brett.cannon
___
Python tracker
<h
Brett Cannon added the comment:
That's better. As long as you use result[1::2] then the tuple is reasonable to
use for the order need and still make sense as an iterable.
--
___
Python tracker
<http://bugs.python.org/is
Changes by Brett Cannon :
--
versions: +Python 2.7, Python 3.4
___
Python tracker
<http://bugs.python.org/issue18145>
___
___
Python-bugs-list mailing list
Unsub
Brett Cannon added the comment:
It's because you have a nested circular import. When you import
package2.subpackage from within package2.subpackage you're in package2
importing package2 and also in package2.subpackage importing
package2.subpackage.
You can solve your problem by do
Brett Cannon added the comment:
It can't. The AttributeError is in the executing module code, not import itself
so there is no reasonable way to tell that the failure was because of a
circular loop in the import and not simply because you tried to get at an
attribute that doesn't
Brett Cannon added the comment:
> echo $CPPFLAGS
-I /Users/bcannon/Developer/include
-I/Users/bcannon/Developer/Cellar/readline/6.2.4/include
> echo $LDFLAGS
-L /Users/bcannon/Developer/lib
-L/Users/bcannon/Developer/Cellar/readline/6.2.4/lib
> echo $CFLAGS
-Wno-unused-value -Wno-e
Brett Cannon added the comment:
I'll change the title to make it more obvious what the problem is.
And yes, Homebrew by default uses /usr/local if I remember correctly.
--
title: test_distutils failing under OS X 10.8 w/ clang -> Put local build paths
before system build
New submission from Brett Cannon:
Much like ImportError now has 'name' and 'path', AttributeError should get an
'attr' attribute that can only be set through a keyword argument or after
creating an instance. That would make the common ``try/except AttributeError``
Changes by Brett Cannon :
--
resolution: -> fixed
stage: patch review -> committed/rejected
status: open -> closed
___
Python tracker
<http://bugs.python.or
Brett Cannon added the comment:
Thanks for the help everyone!
--
resolution: -> fixed
stage: commit review -> committed/rejected
status: open -> closed
___
Python tracker
<http://bugs.python.or
Brett Cannon added the comment:
Current status (with test_imp stripped out):
> ack "imp\.(find|load)_module" Lib
Lib/modulefinder.py
482:return imp.find_module(name, path)
Lib/pkgutil.py
189:file, filename, etc = imp.find_module(subname, path)
251:
Brett Cannon added the comment:
The modulefinder usage is directly exposed in its API as the return value of a
find_module method, which makes removal a pain. Adding Thomas Heller to see
what he has to say.
The pkgutil usage is in classes that have been deprecated, so don't care.
The
New submission from Brett Cannon:
--
assignee: brett.cannon
components: Library (Lib)
messages: 190765
nosy: brett.cannon
priority: normal
severity: normal
stage: needs patch
status: open
title: remove usage of imp.load_module() from pydoc
type: behavior
versions: Python 3.4
New submission from Brett Cannon:
Tests don't serve much of a purpose with test_importlib covering the uses, plus
the tests are old and are not worth updating.
--
assignee: brett.cannon
components: Tests
messages: 190766
nosy: brett.cannon
priority: normal
severity: normal
stage:
Changes by Brett Cannon :
--
dependencies: +Delete test_importhooks
___
Python tracker
<http://bugs.python.org/issue14797>
___
___
Python-bugs-list mailin
Changes by Brett Cannon :
--
dependencies: +remove usage of imp.load_module() from pydoc
___
Python tracker
<http://bugs.python.org/issue14797>
___
___
Python-bug
New submission from Brett Cannon:
Give IndexError an index attribute to store the index it was raised for. Since
it is typically an integer there is no reason to worry about GC and thus using
a regex.
--
components: Interpreter Core
messages: 190777
nosy: brett.cannon
priority: normal
New submission from Brett Cannon:
KeyError could grow a 'key' attribute for the key that triggered the exception.
Since keys are expected to be immutable (in order to be hashable) there is no
GC issue to worry about.
--
components: Interpreter Core
messages: 190778
nosy: br
New submission from Brett Cannon:
A 'value attribute for ValueError could store a weakref to the value which
triggered the exception. It should be a weakref so at to prevent accidental
prevention of GC of the value.
--
components: Interpreter Core
messages: 190781
nosy: brett.c
New submission from Brett Cannon:
TypeError could grow an 'unexpected_type' attribute to store the type of the
argument that was used to trigger the exception. Since types are expected to
not be deleted there is no GC worry.
Having an 'expected' attribute makes no sense in
Brett Cannon added the comment:
So are you arguing it should be a weakref, or just saying you view the
statement as false?
--
___
Python tracker
<http://bugs.python.org/issue18
Brett Cannon added the comment:
And standardizing on an attribute name, of course. =)
--
___
Python tracker
<http://bugs.python.org/issue18156>
___
___
Python-bug
Brett Cannon added the comment:
What Benjamin said.
Adding something like this is mostly about a nicer constructor
(``AttributeError(attr='meth')``) and automatically creating the message for
the exception (although that would require another argument like 'object' or
som
Brett Cannon added the comment:
Hasn't been moved yet. And the __import__ question should probably be rephrased
as "don't do this".
--
___
Python tracker
<http://bug
Changes by Brett Cannon :
--
dependencies: +Document/deprecate imp
___
Python tracker
<http://bugs.python.org/issue18034>
___
___
Python-bugs-list mailin
New submission from Brett Cannon:
This quite possibly won't work because of performance, but I have been
wondering how feasible it would be to define as many core exception types as
possible in pure Python code and then freeze the module for loading. It would
have the benefit of m
Brett Cannon added the comment:
Yes, I mean weakref.
--
___
Python tracker
<http://bugs.python.org/issue18162>
___
___
Python-bugs-list mailing list
Unsubscribe:
Brett Cannon added the comment:
Yeah, that's the tricky bit. =) That's why I was thinking of starting with the
leaf exceptions and then just slowly working down the hierarchy until I hit
exceptions that just had to exist in C code (e.g. BaseException, Exception, and
maybe SyntaxE
Brett Cannon added the comment:
Forgot that PyImport_ImportFrozenModule() uses
PyImport_ImportFrozenModuleObject() and the former is used to load
_frozen_importlib, so can't drop the function. The code could still be updated,
though, to set __package__ before the code object is executed.
Brett Cannon added the comment:
Marking as easy for any C coders.
--
keywords: +easy
___
Python tracker
<http://bugs.python.org/issue18114>
___
___
Python-bug
Changes by Brett Cannon :
--
assignee: -> brett.cannon
___
Python tracker
<http://bugs.python.org/issue17907>
___
___
Python-bugs-list mailing list
Unsubscri
New submission from Brett Cannon:
As part of deprecating imp, need to move imp.get_magic() to importlib where it
now belongs. Will be exposed as an attribute instead of a function, though.
--
components: Library (Lib)
messages: 190981
nosy: brett.cannon
priority: normal
severity
Changes by Brett Cannon :
--
dependencies: +Move imp.get_magic() to importlib
___
Python tracker
<http://bugs.python.org/issue17177>
___
___
Python-bugs-list m
Changes by Brett Cannon :
--
dependencies: +Move imp.reload() to importlib
___
Python tracker
<http://bugs.python.org/issue17177>
___
___
Python-bugs-list mailin
New submission from Brett Cannon:
For convenience it should live directly off of importlib and not importlib.util.
--
components: Library (Lib)
messages: 190982
nosy: brett.cannon
priority: normal
severity: normal
stage: test needed
status: open
title: Move imp.reload() to importlib
New submission from Brett Cannon:
To facilitate deprecating imp, need to move imp.source_from_cache() and
cache_from_source() to importlib.util or as static methods on
importlib.machinery.SourceLoader.
--
components: Library (Lib)
messages: 190983
nosy: brett.cannon
priority: normal
Brett Cannon added the comment:
There should now be issues for each of the required relocations to make imp
redundant.
--
dependencies: +Move imp.source_from_cache/cache_from_source to importlib
___
Python tracker
<http://bugs.python.org/issue17
Changes by Brett Cannon :
--
assignee: brett.cannon ->
___
Python tracker
<http://bugs.python.org/issue17907>
___
___
Python-bugs-list mailing list
Unsubscri
Brett Cannon added the comment:
This could be an attribute on importlib.machinery.SourceLoader instead of an
attribute in importlib.util.
--
___
Python tracker
<http://bugs.python.org/issue18
Changes by Brett Cannon :
--
resolution: -> fixed
stage: needs patch -> committed/rejected
status: open -> closed
___
Python tracker
<http://bugs.python.or
Changes by Brett Cannon :
--
resolution: -> fixed
stage: needs patch -> committed/rejected
status: open -> closed
___
Python tracker
<http://bugs.python.or
Changes by Brett Cannon :
--
resolution: -> fixed
stage: needs patch -> committed/rejected
status: open -> closed
___
Python tracker
<http://bugs.python.or
Brett Cannon added the comment:
What David said. =)
The fact that the key is the first value from args is almost happenstance as
the exception message is customized in __str__() and not in what is passed to
the exception. But what if I had defined __getattr__ or __getattribute__ and
had some
Brett Cannon added the comment:
So what are your arguments to making it more accessible? The typical user won't
need to use it so I don't know if it really requires being off of importlib
directly like find_loader, import_module, or (eventually) reload (which for
convenience-sake wh
Changes by Brett Cannon :
--
title: add ImportNotFoundError -> add ModuleNotFoundError
___
Python tracker
<http://bugs.python.org/issue15767>
___
___
Python-
Changes by Brett Cannon :
--
resolution: -> fixed
stage: test needed -> committed/rejected
status: open -> closed
___
Python tracker
<http://bugs.python.or
New submission from Brett Cannon:
The common idiom::
try:
import something
except ImportError:
pass
should be updated to use ModuleNotFoundError instead to not accidentally
swallow ImportError exceptions which signal actual errors.
--
components: Library (Lib)
keywords: easy
Changes by Brett Cannon :
--
dependencies: +add ModuleNotFoundError
___
Python tracker
<http://bugs.python.org/issue18200>
___
___
Python-bugs-list mailin
Brett Cannon added the comment:
Changeset 84105:281857369a78 and 84106:c4d7228421df have some updates to use
ModuleNotFoundError.
--
___
Python tracker
<http://bugs.python.org/issue18
Changes by Brett Cannon :
--
stage: needs patch -> patch review
___
Python tracker
<http://bugs.python.org/issue18200>
___
___
Python-bugs-list mailing list
Un
Brett Cannon added the comment:
Here is a patch that uses ModuleNotFoundError in the stdlib sans test modules.
--
keywords: +patch
Added file: http://bugs.python.org/file30568/use_ModuleNotFoundError.diff
___
Python tracker
<http://bugs.python.
Changes by Brett Cannon :
--
resolution: -> fixed
stage: patch review -> committed/rejected
status: open -> closed
___
Python tracker
<http://bugs.python.or
Changes by Brett Cannon :
--
assignee: -> brett.cannon
___
Python tracker
<http://bugs.python.org/issue18200>
___
___
Python-bugs-list mailing list
Unsubscri
Brett Cannon added the comment:
Answered Berker's questions from the review. At this point Berker just needs to
tweak one line in the test and it should then be good to go.
--
___
Python tracker
<http://bugs.python.org/is
Brett Cannon added the comment:
With Berker's nice use of TestCase.subTest() I think the patch is good to go! I
should hopefully get this checked in today or tomorrow.
--
resolution: -> fixed
stage: patch review -> commit review
status: open
Brett Cannon added the comment:
Thanks for the patch, Berker!
--
assignee: -> brett.cannon
stage: commit review -> committed/rejected
status: open -> closed
___
Python tracker
<http://bugs.python.or
Changes by Brett Cannon :
--
title: Document/deprecate imp -> Deprecate imp
___
Python tracker
<http://bugs.python.org/issue17177>
___
___
Python-bugs-list mai
Brett Cannon added the comment:
Any chance I could get a response to my questions, Barry, soon? I think I can
finish the rest of the issues related to deprecating imp this weekend if we can
settle this quickly.
--
___
Python tracker
<h
Changes by Brett Cannon :
--
assignee: -> barry
___
Python tracker
<http://bugs.python.org/issue18192>
___
___
Python-bugs-list mailing list
Unsubscri
Brett Cannon added the comment:
I'll put it into importlib.util.MAGIC.
--
___
Python tracker
<http://bugs.python.org/issue18192>
___
___
Python-bugs-list m
Changes by Brett Cannon :
--
resolution: -> fixed
stage: needs patch -> committed/rejected
status: open -> closed
___
Python tracker
<http://bugs.python.or
2901 - 3000 of 5934 matches
Mail list logo