[issue24907] Module location load order is not respected if pkg_resources is imported and a namespace is declared

2021-06-20 Thread Irit Katriel


Irit Katriel  added the comment:

2.7 is past EOL and I could not reproduce this on a current python version. 
Please create a new issue if you are still having a problem with this on 3.9+.

PS C:\Users\User\src\cpython-dev> .\python.bat
Running Release|x64 interpreter...
Python 3.11.0a0 (heads/main-dirty:09eb817115, Jun 20 2021, 16:50:29) [MSC 
v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> with open('json/__init__.py', 'w') as f:
...f.write("__import__('pkg_resources').declare_namespace(__name__); 
print('test')")
...
70
>>> quit()
PS C:\Users\User\src\cpython-dev> python -c 'import json; print( json.__file__)'
Running Release|x64 interpreter...
test
C:\Users\User\src\cpython-dev\json\__init__.py

--
nosy: +iritkatriel
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24907] Module location load order is not respected if pkg_resources is imported and a namespace is declared

2015-08-24 Thread Vadim Kantorov

Vadim Kantorov added the comment:

From my (novice) standpoint, it's very weird that importing pkg_resources in a 
module's __init__.py causes Python to deviate from its core module import 
rules / sequence.

Would you consider reporting this issue to pkg_resources's authors more 
appropriate?

--
status: pending - open

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



[issue24907] Module location load order is not respected if pkg_resources is imported and a namespace is declared

2015-08-24 Thread R. David Murray

R. David Murray added the comment:

Yes, unless you can identify a python bug yourself.  I believe pkg_resources 
does a bunch of imports when it is imported, so I'm not really surprised that 
it has an effect on the order in which things are imported.

--

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



[issue24907] Module location load order is not respected if pkg_resources is imported and a namespace is declared

2015-08-24 Thread R. David Murray

R. David Murray added the comment:

To be clear: I believe it imports things that are not in the standard library, 
based on scanning sys.path.  But I haven't studied the code in depth, so I 
could be wrong.

--

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



[issue24907] Module location load order is not respected if pkg_resources is imported and a namespace is declared

2015-08-21 Thread R. David Murray

R. David Murray added the comment:

pkg_resources is 3rd party code (from the point of view of this tracker).  If 
you are saying its code is revealing a bug in python, can you expand on what 
exactly the bug is?

--
nosy: +r.david.murray

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



[issue24907] Module location load order is not respected if pkg_resources is imported and a namespace is declared

2015-08-21 Thread Brett Cannon

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


--
status: open - pending

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



[issue24907] Module location load order is not respected if pkg_resources is imported and a namespace is declared

2015-08-21 Thread Vadim Kantorov

New submission from Vadim Kantorov:

If module's __init__.py contains 
__import__('pkg_resources').declare_namespace(__name__), the module is not 
loaded, even though it's located in the current directory and should mask other 
modules.

Originally I stumbled upon this issue while installing a new version of Google 
Protobuf. But here's a simpler repro:

$ python -c 'import json; print json.__file__'
/usr/lib/python2.7/json/__init__.pyc

$ mkdir json; echo print 'test'  json/__init__.py
$ python -c 'import json; print json.__file__'
test
json/__init__.py

$ echo __import__('pkg_resources').declare_namespace(__name__); print 'test' 
 json/__init__.py
$ python -c 'import json; print json.__file__'
test
/usr/lib/python2.7/json/__init__.pyc

For Protobuf, if you build Python bindings from sources, the google/__init__.py 
will contain exactly __import__('pkg_resources').declare_namespace(__name__) 
and it prevents the freshly-built module from being loaded, even if the module 
egg is at the first place in sys.path. So an older version gets loaded and it 
screws things up.

Ubuntu 14.10, Python 2.7.8

--
components: Extension Modules
messages: 248948
nosy: Vadim Kantorov
priority: normal
severity: normal
status: open
title: Module location load order is not respected if pkg_resources is imported 
and a namespace is declared
versions: Python 2.7

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