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

Unified Diff: Lib/pydoc.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/pstats.py ('k') | Lib/_pyio.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/pydoc.py Tue Jul 26 09:37:46 2011 +0300
+++ b/Lib/pydoc.py Mon Jul 25 09:47:18 2011 -0400
@@ -51,17 +51,16 @@
# the current directory is changed with os.chdir(), an incorrect
# path will be displayed.
+import os
+import sys
import builtins
import imp
+import io
import inspect
-import io
-import os
import pkgutil
import platform
import re
-import sys
import time
-import tokenize
import warnings
from collections import deque
from reprlib import Repr
@@ -222,7 +221,7 @@
if lastupdate < mtime:
info = inspect.getmoduleinfo(filename)
try:
- file = tokenize.open(filename)
+ file = open(filename)
except IOError:
# module can't be opened, so skip it
return None
@@ -250,18 +249,20 @@
def importfile(path):
"""Import a Python source file or compiled file given its path."""
magic = imp.get_magic()
- with open(path, 'rb') as file:
- if file.read(len(magic)) == magic:
- kind = imp.PY_COMPILED
- else:
- kind = imp.PY_SOURCE
- file.seek(0)
- filename = os.path.basename(path)
- name, ext = os.path.splitext(filename)
- try:
- module = imp.load_module(name, file, path, (ext, 'r', kind))
- except:
- raise ErrorDuringImport(path, sys.exc_info())
+ file = open(path, 'r')
+ if file.read(len(magic)) == magic:
+ kind = imp.PY_COMPILED
+ else:
+ kind = imp.PY_SOURCE
+ file.close()
+ filename = os.path.basename(path)
+ name, ext = os.path.splitext(filename)
+ file = open(path, 'r')
+ try:
+ module = imp.load_module(name, file, path, (ext, 'r', kind))
+ except:
+ raise ErrorDuringImport(path, sys.exc_info())
+ file.close()
return module
def safeimport(path, forceload=0, cache={}):
@@ -2311,7 +2312,7 @@
def html_getfile(path):
"""Get and display a source file listing safely."""
path = path.replace('%20', ' ')
- with tokenize.open(path) as fp:
+ with open(path, 'r') as fp:
lines = html.escape(fp.read())
body = '<pre>%s</pre>' % lines
heading = html.heading(
« no previous file with comments | « Lib/pstats.py ('k') | Lib/_pyio.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+