mirror of https://github.com/python/cpython.git
Fix by Sjoerd for a package related bug: If you have a non-empy
__init__.py it isn't read. (Sjoerd just came up with this, so it's not heavily tested.) Other (yet unsolved) package problems noted by Sjoerd: - If you have a package and a module inside that or another package with the same name, module caching doesn't work properly since the key is the base name of the module/package. - The only entry that is returned when you readmodule a package is a __path__ whose value is a list which confuses certain class browsers that I wrote. (Hm, this could be construed as a feature.)
This commit is contained in:
parent
c87f5f4f7a
commit
3d548717f5
|
@ -123,6 +123,8 @@ def readmodule(module, path=[], inpackage=0):
|
||||||
module and return a dictionary with one entry for each class
|
module and return a dictionary with one entry for each class
|
||||||
found in the module.'''
|
found in the module.'''
|
||||||
|
|
||||||
|
dict = {}
|
||||||
|
|
||||||
i = string.rfind(module, '.')
|
i = string.rfind(module, '.')
|
||||||
if i >= 0:
|
if i >= 0:
|
||||||
# Dotted module name
|
# Dotted module name
|
||||||
|
@ -137,7 +139,6 @@ def readmodule(module, path=[], inpackage=0):
|
||||||
return _modules[module]
|
return _modules[module]
|
||||||
if module in sys.builtin_module_names:
|
if module in sys.builtin_module_names:
|
||||||
# this is a built-in module
|
# this is a built-in module
|
||||||
dict = {}
|
|
||||||
_modules[module] = dict
|
_modules[module] = dict
|
||||||
return dict
|
return dict
|
||||||
|
|
||||||
|
@ -153,18 +154,17 @@ def readmodule(module, path=[], inpackage=0):
|
||||||
fullpath = list(path) + sys.path
|
fullpath = list(path) + sys.path
|
||||||
f, file, (suff, mode, type) = imp.find_module(module, fullpath)
|
f, file, (suff, mode, type) = imp.find_module(module, fullpath)
|
||||||
if type == imp.PKG_DIRECTORY:
|
if type == imp.PKG_DIRECTORY:
|
||||||
dict = {'__path__': [file]}
|
dict['__path__'] = [file]
|
||||||
_modules[module] = dict
|
_modules[module] = dict
|
||||||
# XXX Should we recursively look for submodules?
|
path = [file] + path
|
||||||
return dict
|
f, file, (suff, mode, type) = \
|
||||||
|
imp.find_module('__init__', [file])
|
||||||
if type != imp.PY_SOURCE:
|
if type != imp.PY_SOURCE:
|
||||||
# not Python source, can't do anything with this module
|
# not Python source, can't do anything with this module
|
||||||
f.close()
|
f.close()
|
||||||
dict = {}
|
|
||||||
_modules[module] = dict
|
_modules[module] = dict
|
||||||
return dict
|
return dict
|
||||||
|
|
||||||
dict = {}
|
|
||||||
_modules[module] = dict
|
_modules[module] = dict
|
||||||
imports = []
|
imports = []
|
||||||
classstack = [] # stack of (class, indent) pairs
|
classstack = [] # stack of (class, indent) pairs
|
||||||
|
|
Loading…
Reference in New Issue