Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3002)

Delta Between Two Patch Sets: Lib/importlib/abc.py

Issue 15030: PyPycLoader can't read cached .pyc files
Left Patch Set: Created 11 months, 3 weeks ago
Right Patch Set: Created 11 months, 3 weeks ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | Lib/importlib/test/source/test_abc_loader.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 """Abstract base classes related to import.""" 1 """Abstract base classes related to import."""
2 from . import _bootstrap 2 from . import _bootstrap
3 from . import machinery 3 from . import machinery
4 try: 4 try:
5 import _frozen_importlib 5 import _frozen_importlib
6 except ImportError as exc: 6 except ImportError as exc:
7 if exc.name != '_frozen_importlib': 7 if exc.name != '_frozen_importlib':
8 raise 8 raise
9 _frozen_importlib = None 9 _frozen_importlib = None
10 import abc 10 import abc
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 if source_path is None: 316 if source_path is None:
317 message = "a source path must exist to load {0}".format(fullname) 317 message = "a source path must exist to load {0}".format(fullname)
318 raise ImportError(message, name=fullname) 318 raise ImportError(message, name=fullname)
319 source = self.get_data(source_path) 319 source = self.get_data(source_path)
320 code_object = compile(source, source_path, 'exec', dont_inherit=True) 320 code_object = compile(source, source_path, 'exec', dont_inherit=True)
321 # Generate bytecode and write it out. 321 # Generate bytecode and write it out.
322 if not sys.dont_write_bytecode: 322 if not sys.dont_write_bytecode:
323 bytecode = marshal.dumps(code_object) 323 bytecode = marshal.dumps(code_object)
324 data = bytearray(imp.get_magic()) 324 data = bytearray(imp.get_magic())
325 data.extend(_bootstrap._w_long(source_timestamp)) 325 data.extend(_bootstrap._w_long(source_timestamp))
326 data.extend(_bootstrap._w_long(len(bytecode))) 326 data.extend(_bootstrap._w_long(len(source)))
brett.cannon 2012/06/28 17:08:02 It is the length of the source, not the bytecode;
327 data.extend(bytecode) 327 data.extend(bytecode)
328 self.write_bytecode(fullname, data) 328 self.write_bytecode(fullname, data)
329 return code_object 329 return code_object
330 330
331 @abc.abstractmethod 331 @abc.abstractmethod
332 def source_mtime(self, fullname): 332 def source_mtime(self, fullname):
333 """Abstract method. Accepts a str filename and returns an int 333 """Abstract method. Accepts a str filename and returns an int
334 modification time for the source of the module.""" 334 modification time for the source of the module."""
335 raise NotImplementedError 335 raise NotImplementedError
336 336
337 @abc.abstractmethod 337 @abc.abstractmethod
338 def bytecode_path(self, fullname): 338 def bytecode_path(self, fullname):
339 """Abstract method. Accepts a str filename and returns the str pathname 339 """Abstract method. Accepts a str filename and returns the str pathname
340 to the bytecode for the module.""" 340 to the bytecode for the module."""
341 raise NotImplementedError 341 raise NotImplementedError
342 342
343 @abc.abstractmethod 343 @abc.abstractmethod
344 def write_bytecode(self, fullname, bytecode): 344 def write_bytecode(self, fullname, bytecode):
345 """Abstract method. Accepts a str filename and bytes object 345 """Abstract method. Accepts a str filename and bytes object
346 representing the bytecode for the module. Returns a boolean 346 representing the bytecode for the module. Returns a boolean
347 representing whether the bytecode was written or not.""" 347 representing whether the bytecode was written or not."""
348 raise NotImplementedError 348 raise NotImplementedError
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7