importer.py (13670:8a98db5a481f) importer.py (13671:b288ca1bcae8)
1# Copyright (c) 2008 The Hewlett-Packard Development Company
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 63 unchanged lines hidden (view full) ---

72
73 if os.path.basename(srcfile) == '__init__.py':
74 mod.__path__ = fullname.split('.')
75 mod.__package__ = fullname
76 else:
77 mod.__package__ = fullname.rpartition('.')[0]
78 mod.__file__ = srcfile
79
1# Copyright (c) 2008 The Hewlett-Packard Development Company
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 63 unchanged lines hidden (view full) ---

72
73 if os.path.basename(srcfile) == '__init__.py':
74 mod.__path__ = fullname.split('.')
75 mod.__package__ = fullname
76 else:
77 mod.__package__ = fullname.rpartition('.')[0]
78 mod.__file__ = srcfile
79
80 exec code in mod.__dict__
80 exec(code, mod.__dict__)
81 except Exception:
82 del sys.modules[fullname]
83 raise
84
85 return mod
86
87# Create an importer and add it to the meta_path so future imports can
88# use it. There's currently nothing in the importer, but calls to
89# add_module can be used to add code.
90import sys
91importer = CodeImporter()
92add_module = importer.add_module
93sys.meta_path.append(importer)
81 except Exception:
82 del sys.modules[fullname]
83 raise
84
85 return mod
86
87# Create an importer and add it to the meta_path so future imports can
88# use it. There's currently nothing in the importer, but calls to
89# add_module can be used to add code.
90import sys
91importer = CodeImporter()
92add_module = importer.add_module
93sys.meta_path.append(importer)