call site 2 for path.local.mtime
path/testing/fscommon.py - line 240
238
239
240
241
   def test__getpymodule_c(self):
       otherdir = self.root.join('otherdir')
->     mod = otherdir.join('c.py')._getpymodule()
       assert mod.value == "got it"
path/local/local.py - line 439
436
437
438
439
440
441
442
   def _getpymodule(self):
       """resolve this path to a module python object. """
       if self.ext != '.c':
->         return super(LocalPath, self)._getpymodule()
       from py.__.misc.buildcmodule import make_module_from_c
       mod = make_module_from_c(self)
       return mod
path/common.py - line 387
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
   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
/tmp/pytest-0/TestLocalPath/otherdir/c.py - line 2
1
   import py; py.magic.autopath()
path/common.py - line 442
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
   def custom_import_hook(name, glob=None, loc=None, fromlist=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 
       return old_import_hook(name, glob, loc, fromlist)
path/common.py - line 424
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
   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/local/local.py - line 439
436
437
438
439
440
441
442
   def _getpymodule(self):
       """resolve this path to a module python object. """
       if self.ext != '.c':
->         return super(LocalPath, self)._getpymodule()
       from py.__.misc.buildcmodule import make_module_from_c
       mod = make_module_from_c(self)
       return mod
path/common.py - line 380
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
   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/local/local.py - line 449
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
   def _getpycodeobj(self):
       """ read the path and compile it to a code object. """
       dotpy = self.check(ext='.py')
       if dotpy:
           my_magic     = py.std.imp.get_magic()
->         my_timestamp = int(self.mtime())
           if __debug__:
               pycfile = self + 'c'
           else:
               pycfile = self + 'o'
           try:
               f = pycfile.open('rb')
               try:
                   header = f.read(8)
                   if len(header) == 8:
                       magic, timestamp = py.std.struct.unpack('<4si', header)
                       if magic == my_magic and timestamp == my_timestamp:
                           co = py.std.marshal.load(f)
                           path1 = co.co_filename
                           path2 = str(self)
                           if path1 == path2:
                               return co
                           try:
                               if os.path.samefile(path1, path2):
                                   return co
                           except (OSError,          # probably path1 not found
                                   AttributeError):  # samefile() not available
                               pass
               finally:
                   f.close()
           except py.error.Error:
               pass
       s = self.read(mode='rU') + '\n'
       codeobj = compile(s, str(self), 'exec', generators.compiler_flag)
       if dotpy:
           try:
               f = pycfile.open('wb')
               f.write(py.std.struct.pack('<4si', 'TEMP', -1))  # fixed below
               py.std.marshal.dump(codeobj, f)
               f.flush()
               f.seek(0)
               f.write(py.std.struct.pack('<4si', my_magic, my_timestamp))
               f.close()
           except py.error.Error:
               pass
       return codeobj