call site 0 for code.compile
path/testing/fscommon.py - line 230
228
229
230
231
   def test__getpymodule_a(self):
       otherdir = self.root.join('otherdir')
->     mod = otherdir.join('a.py')._getpymodule()
       assert mod.result == "got it"
path/common.py - line 391
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
   def _getpymodule(self):
       """resolve this path to a module python object. """
       modname = str(self)
       modname = modname.replace('.', self.sep)
       try:
           return sys.modules[modname]
       except KeyError:
           co = self._getpycodeobj()
           mod = py.std.new.module(modname)
           mod.__file__ = PathStr(self)
           if self.basename == '__init__.py':
               mod.__path__ = [str(self.dirpath())]
           sys.modules[modname] = mod
           try: 
->             exec co in mod.__dict__
           except: 
               del sys.modules[modname] 
               raise 
           return mod
None</home/hpk/py/release/0.9.x/py/code/source.py:213> - line 1
1
-> from b import stuff as result
path/common.py - line 448
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
   def custom_import_hook(name, glob=None, loc=None, fromlist=None, extra=None, level=None):
       __tracebackhide__ = False 
       __file__ = glob and glob.get('__file__')
       if isinstance(__file__, PathStr):
           # try to perform a relative import
           # for cooperation with py.magic.autopath, first look in the pkgdir
           modules = None
           if hasattr(__file__.__path__, 'pkgdir'):
               modules = relativeimport(__file__.__path__.pkgdir, name)
           if not modules:
->             modules = relativeimport(__file__.__path__, name)
           if modules:
               if fromlist:
                   submodule = modules[-1]  # innermost submodule
                   # try to import submodules named in the 'fromlist' if the
                   # 'submodule' is a package
                   p = submodule.__file__.__path__
                   if p.check(basename='__init__.py'):
                       for name in fromlist:
                           relativeimport(p, name, parent=submodule)
                           # failures are fine
                   return submodule
               else:
                   return modules[0]   # outermost package
       # fall-back
       __tracebackhide__ = True 
       try:
           return old_import_hook(name, glob, loc, fromlist, level)
       except TypeError:
           return old_import_hook(name, glob, loc, fromlist)
path/common.py - line 428
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
   def relativeimport(p, name, parent=None):
       names = name.split('.')
       last_list = [False] * (len(names)-1) + [True]
       modules = []
       for name, is_last in zip(names, last_list):
           if hasattr(parent, name):
               # shortcut if there is already the correct name
               # in the parent package
               submodule = getattr(parent, name)
           else:
               if is_last and p.new(basename=name+'.py').check():
                   p = p.new(basename=name+'.py')
               else:
                   p = p.new(basename=name).join('__init__.py')
                   if not p.check():
                       return None   # not found
->             submodule = p._getpymodule()
               if parent is not None:
                   setattr(parent, name, submodule)
           modules.append(submodule)
           parent = submodule
       return modules   # success
path/common.py - line 384
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
   def _getpymodule(self):
       """resolve this path to a module python object. """
       modname = str(self)
       modname = modname.replace('.', self.sep)
       try:
           return sys.modules[modname]
       except KeyError:
->         co = self._getpycodeobj()
           mod = py.std.new.module(modname)
           mod.__file__ = PathStr(self)
           if self.basename == '__init__.py':
               mod.__path__ = [str(self.dirpath())]
           sys.modules[modname] = mod
           try: 
               exec co in mod.__dict__
           except: 
               del sys.modules[modname] 
               raise 
           return mod
path/common.py - line 401
397
398
399
400
401
   def _getpycodeobj(self):
       """ read the path and compile it to a py.code.Code object. """
       s = self.read('rU')
       # XXX str(self) should show up somewhere in the code's filename
->     return py.code.compile(s)