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

Side by Side Diff: Lib/cgi.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months 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:
View unified diff | Download patch
« no previous file with comments | « Lib/binhex.py ('k') | Lib/cgitb.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #! /usr/local/bin/python 1 #! /usr/local/bin/python
2 2
3 # NOTE: the above "/usr/local/bin/python" is NOT a mistake. It is 3 # NOTE: the above "/usr/local/bin/python" is NOT a mistake. It is
4 # intentionally NOT "/usr/bin/env python". On many systems 4 # intentionally NOT "/usr/bin/env python". On many systems
5 # (e.g. Solaris), /usr/local/bin is not in $PATH as passed to CGI 5 # (e.g. Solaris), /usr/local/bin is not in $PATH as passed to CGI
6 # scripts, and /usr/local/bin is the default directory where Python is 6 # scripts, and /usr/local/bin is the default directory where Python is
7 # installed, so /usr/bin/env would be unable to find python. Granted, 7 # installed, so /usr/bin/env would be unable to find python. Granted,
8 # binary installations by Linux vendors often install Python in 8 # binary installations by Linux vendors often install Python in
9 # /usr/bin. So let those vendors patch cgi.py to match their choice 9 # /usr/bin. So let those vendors patch cgi.py to match their choice
10 # of installation. 10 # of installation.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 If the global logfp is not None, it should be a file object to 69 If the global logfp is not None, it should be a file object to
70 which log data is written. 70 which log data is written.
71 71
72 If the global logfp is None, the global logfile may be a string 72 If the global logfp is None, the global logfile may be a string
73 giving a filename to open, in append mode. This file should be 73 giving a filename to open, in append mode. This file should be
74 world writable!!! If the file can't be opened, logging is 74 world writable!!! If the file can't be opened, logging is
75 silently disabled (since there is no safe place where we could 75 silently disabled (since there is no safe place where we could
76 send an error message). 76 send an error message).
77 77
78 """ 78 """
79 global log, logfile, logfp 79 global logfp, log
80 if logfile and not logfp: 80 if logfile and not logfp:
81 try: 81 try:
82 logfp = open(logfile, "a") 82 logfp = open(logfile, "a")
83 except IOError: 83 except IOError:
84 pass 84 pass
85 if not logfp: 85 if not logfp:
86 log = nolog 86 log = nolog
87 else: 87 else:
88 log = dolog 88 log = dolog
89 log(*allargs) 89 log(*allargs)
90 90
91 def dolog(fmt, *args): 91 def dolog(fmt, *args):
92 """Write a log message to the log file. See initlog() for docs.""" 92 """Write a log message to the log file. See initlog() for docs."""
93 logfp.write(fmt%args + "\n") 93 logfp.write(fmt%args + "\n")
94 94
95 def nolog(*allargs): 95 def nolog(*allargs):
96 """Dummy function, assigned to log when logging is disabled.""" 96 """Dummy function, assigned to log when logging is disabled."""
97 pass 97 pass
98
99 def closelog():
100 """Close the log file."""
101 global log, logfile, logfp
102 logfile = ''
103 if logfp:
104 logfp.close()
105 logfp = None
106 log = initlog
107 98
108 log = initlog # The current logging function 99 log = initlog # The current logging function
109 100
110 101
111 # Parsing functions 102 # Parsing functions
112 # ================= 103 # =================
113 104
114 # Maximum input we will accept when REQUEST_METHOD is POST 105 # Maximum input we will accept when REQUEST_METHOD is POST
115 # 0 ==> unlimited input 106 # 0 ==> unlimited input
116 maxlen = 0 107 maxlen = 0
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 else: 1019 else:
1029 _vb_pattern = "^[ -~]{0,200}[!-~]$" 1020 _vb_pattern = "^[ -~]{0,200}[!-~]$"
1030 return re.match(_vb_pattern, s) 1021 return re.match(_vb_pattern, s)
1031 1022
1032 # Invoke mainline 1023 # Invoke mainline
1033 # =============== 1024 # ===============
1034 1025
1035 # Call test() when this file is run as a script (not imported as a module) 1026 # Call test() when this file is run as a script (not imported as a module)
1036 if __name__ == '__main__': 1027 if __name__ == '__main__':
1037 test() 1028 test()
OLDNEW
« no previous file with comments | « Lib/binhex.py ('k') | Lib/cgitb.py » ('j') | no next file with comments »

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