Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
ff712aa8
Kaydet (Commit)
ff712aa8
authored
Agu 15, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
The usual.
üst
f84a539d
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
910 additions
and
92 deletions
+910
-92
basehttp.py
Lib/dos-8x3/basehttp.py
+2
-2
mimetool.py
Lib/dos-8x3/mimetool.py
+22
-2
nturl2pa.py
Lib/dos-8x3/nturl2pa.py
+8
-4
regex_te.py
Lib/dos-8x3/regex_te.py
+289
-0
socketse.py
Lib/dos-8x3/socketse.py
+5
-5
stringio.py
Lib/dos-8x3/stringio.py
+4
-1
test_opc.py
Lib/dos-8x3/test_opc.py
+35
-0
test_reg.py
Lib/dos-8x3/test_reg.py
+48
-0
test_rot.py
Lib/dos-8x3/test_rot.py
+1
-1
test_soc.py
Lib/dos-8x3/test_soc.py
+1
-1
test_thr.py
Lib/dos-8x3/test_thr.py
+2
-2
test_typ.py
Lib/dos-8x3/test_typ.py
+4
-4
tracebac.py
Lib/dos-8x3/tracebac.py
+9
-9
userdict.py
Lib/dos-8x3/userdict.py
+25
-15
basehttp.py
Lib/dos_8x3/basehttp.py
+2
-2
mimetool.py
Lib/dos_8x3/mimetool.py
+22
-2
nturl2pa.py
Lib/dos_8x3/nturl2pa.py
+8
-4
regex_te.py
Lib/dos_8x3/regex_te.py
+289
-0
socketse.py
Lib/dos_8x3/socketse.py
+5
-5
stringio.py
Lib/dos_8x3/stringio.py
+4
-1
test_opc.py
Lib/dos_8x3/test_opc.py
+35
-0
test_reg.py
Lib/dos_8x3/test_reg.py
+48
-0
test_rot.py
Lib/dos_8x3/test_rot.py
+1
-1
test_soc.py
Lib/dos_8x3/test_soc.py
+1
-1
test_thr.py
Lib/dos_8x3/test_thr.py
+2
-2
test_typ.py
Lib/dos_8x3/test_typ.py
+4
-4
tracebac.py
Lib/dos_8x3/tracebac.py
+9
-9
userdict.py
Lib/dos_8x3/userdict.py
+25
-15
No files found.
Lib/dos-8x3/basehttp.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -236,7 +236,7 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
words
=
string
.
split
(
requestline
)
if
len
(
words
)
==
3
:
[
command
,
path
,
version
]
=
words
if
version
!=
self
.
protocol_version
:
if
version
[:
5
]
!=
'HTTP/'
:
self
.
send_error
(
400
,
"Bad request version (
%
s)"
%
`version`
)
return
elif
len
(
words
)
==
2
:
...
...
@@ -297,7 +297,7 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
self
.
log_request
(
code
)
if
message
is
None
:
if
self
.
responses
.
has_key
(
code
):
message
=
self
.
responses
[
code
][
1
]
message
=
self
.
responses
[
code
][
0
]
else
:
message
=
''
if
self
.
request_version
!=
'HTTP/0.9'
:
...
...
Lib/dos-8x3/mimetool.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -131,9 +131,16 @@ def choose_boundary():
# Subroutines for decoding some common content-transfer-types
# XXX This requires that uudecode and mmencode are in $PATH
def
decode
(
input
,
output
,
encoding
):
if
encoding
==
'base64'
:
import
base64
return
base64
.
decode
(
input
,
output
)
if
encoding
==
'quoted-printable'
:
import
quopri
return
quopri
.
decode
(
input
,
output
)
if
encoding
in
(
'uuencode'
,
'x-uuencode'
):
import
uu
return
uu
.
decode
(
input
,
output
)
if
decodetab
.
has_key
(
encoding
):
pipethrough
(
input
,
decodetab
[
encoding
],
output
)
else
:
...
...
@@ -141,12 +148,25 @@ def decode(input, output, encoding):
'unknown Content-Transfer-Encoding:
%
s'
%
encoding
def
encode
(
input
,
output
,
encoding
):
if
encoding
==
'base64'
:
import
base64
return
base64
.
encode
(
input
,
output
)
if
encoding
==
'quoted-printable'
:
import
quopri
return
quopri
.
encode
(
input
,
output
,
0
)
if
encoding
in
(
'uuencode'
,
'x-uuencode'
):
import
uu
return
uu
.
encode
(
input
,
output
)
if
encodetab
.
has_key
(
encoding
):
pipethrough
(
input
,
encodetab
[
encoding
],
output
)
else
:
raise
ValueError
,
\
'unknown Content-Transfer-Encoding:
%
s'
%
encoding
# The following is no longer used for standard encodings
# XXX This requires that uudecode and mmencode are in $PATH
uudecode_pipe
=
'''(
TEMP=/tmp/@uu.$$
sed "s
%
^begin [0-7][0-7]* .*
%
begin 600 $TEMP
%
" | uudecode
...
...
Lib/dos-8x3/nturl2pa.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -4,8 +4,6 @@
def
url2pathname
(
url
):
""" Convert a URL to a DOS path...
Currently only works for absolute paths
///C|/foo/bar/spam.foo
becomes
...
...
@@ -13,6 +11,10 @@ def url2pathname(url):
C:
\f
oo
\b
ar
\
spam.foo
"""
import
string
if
not
'|'
in
url
:
# No drive specifier, just convert slashes
components
=
string
.
splitfields
(
url
,
'/'
)
return
string
.
joinfields
(
components
,
'
\\
'
)
comp
=
string
.
splitfields
(
url
,
'|'
)
if
len
(
comp
)
!=
2
or
comp
[
0
][
-
1
]
not
in
string
.
letters
:
error
=
'Bad URL: '
+
url
...
...
@@ -28,8 +30,6 @@ def url2pathname(url):
def
pathname2url
(
p
):
""" Convert a DOS path name to a file url...
Currently only works for absolute paths
C:
\f
oo
\b
ar
\
spam.foo
becomes
...
...
@@ -38,6 +38,10 @@ def pathname2url(p):
"""
import
string
if
not
':'
in
p
:
# No drive specifier, just convert slashes
components
=
string
.
splitfields
(
p
,
'
\\
'
)
return
string
.
joinfields
(
components
,
'/'
)
comp
=
string
.
splitfields
(
p
,
':'
)
if
len
(
comp
)
!=
2
or
len
(
comp
[
0
])
>
1
:
error
=
'Bad path: '
+
p
...
...
Lib/dos-8x3/regex_te.py
0 → 100644
Dosyayı görüntüle @
ff712aa8
# Regex test suite and benchmark suite v1.5a2
# Due to the use of r"aw" strings, this file will
# only work with Python 1.5 or higher.
# The 3 possible outcomes for each pattern
[
SUCCEED
,
FAIL
,
SYNTAX_ERROR
]
=
range
(
3
)
# Benchmark suite (needs expansion)
#
# The benchmark suite does not test correctness, just speed. The
# first element of each tuple is the regex pattern; the second is a
# string to match it against. The benchmarking code will embed the
# second string inside several sizes of padding, to test how regex
# matching performs on large strings.
benchmarks
=
[
(
'Python'
,
'Python'
),
# Simple text literal
(
'.*Python'
,
'Python'
),
# Bad text literal
(
'.*Python.*'
,
'Python'
),
# Worse text literal
(
'.*
\\
(Python
\\
)'
,
'Python'
),
# Bad text literal with grouping
(
'(Python
\\
|Perl
\\
|Tcl'
,
'Perl'
),
# Alternation
(
'
\\
(Python
\\
|Perl
\\
|Tcl
\\
)'
,
'Perl'
),
# Grouped alternation
(
'
\\
(Python
\\
)
\\
1'
,
'PythonPython'
),
# Backreference
# ('\\([0a-z][a-z]*,\\)+', 'a5,b7,c9,'), # Disable the fastmap optimization
(
'
\\
([a-z][a-z0-9]*,
\\
)+'
,
'a5,b7,c9,'
)
# A few sets
]
# Test suite (for verifying correctness)
#
# The test suite is a list of 5- or 3-tuples. The 5 parts of a
# complete tuple are:
# element 0: a string containing the pattern
# 1: the string to match against the pattern
# 2: the expected result (SUCCEED, FAIL, SYNTAX_ERROR)
# 3: a string that will be eval()'ed to produce a test string.
# This is an arbitrary Python expression; the available
# variables are "found" (the whole match), and "g1", "g2", ...
# up to "g10" contain the contents of each group, or the
# string 'None' if the group wasn't given a value.
# 4: The expected result of evaluating the expression.
# If the two don't match, an error is reported.
#
# If the regex isn't expected to work, the latter two elements can be omitted.
tests
=
[
(
'abc'
,
'abc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'abc'
,
'xbc'
,
FAIL
),
(
'abc'
,
'axc'
,
FAIL
),
(
'abc'
,
'abx'
,
FAIL
),
(
'abc'
,
'xabcy'
,
SUCCEED
,
'found'
,
'abc'
),
(
'abc'
,
'ababc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'ab*c'
,
'abc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'ab*bc'
,
'abc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'ab*bc'
,
'abbc'
,
SUCCEED
,
'found'
,
'abbc'
),
(
'ab*bc'
,
'abbbbc'
,
SUCCEED
,
'found'
,
'abbbbc'
),
(
'ab+bc'
,
'abbc'
,
SUCCEED
,
'found'
,
'abbc'
),
(
'ab+bc'
,
'abc'
,
FAIL
),
(
'ab+bc'
,
'abq'
,
FAIL
),
(
'ab+bc'
,
'abbbbc'
,
SUCCEED
,
'found'
,
'abbbbc'
),
(
'ab?bc'
,
'abbc'
,
SUCCEED
,
'found'
,
'abbc'
),
(
'ab?bc'
,
'abc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'ab?bc'
,
'abbbbc'
,
FAIL
),
(
'ab?c'
,
'abc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'^abc$'
,
'abc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'^abc$'
,
'abcc'
,
FAIL
),
(
'^abc'
,
'abcc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'^abc$'
,
'aabc'
,
FAIL
),
(
'abc$'
,
'aabc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'^'
,
'abc'
,
SUCCEED
,
'found+"-"'
,
'-'
),
(
'$'
,
'abc'
,
SUCCEED
,
'found+"-"'
,
'-'
),
(
'a.c'
,
'abc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'a.c'
,
'axc'
,
SUCCEED
,
'found'
,
'axc'
),
(
'a.*c'
,
'axyzc'
,
SUCCEED
,
'found'
,
'axyzc'
),
(
'a.*c'
,
'axyzd'
,
FAIL
),
(
'a[bc]d'
,
'abc'
,
FAIL
),
(
'a[bc]d'
,
'abd'
,
SUCCEED
,
'found'
,
'abd'
),
(
'a[b-d]e'
,
'abd'
,
FAIL
),
(
'a[b-d]e'
,
'ace'
,
SUCCEED
,
'found'
,
'ace'
),
(
'a[b-d]'
,
'aac'
,
SUCCEED
,
'found'
,
'ac'
),
(
'a[-b]'
,
'a-'
,
SUCCEED
,
'found'
,
'a-'
),
(
'a[b-]'
,
'a-'
,
SUCCEED
,
'found'
,
'a-'
),
(
'a[]b'
,
'-'
,
SYNTAX_ERROR
),
(
'a['
,
'-'
,
SYNTAX_ERROR
),
(
'a
\\
'
,
'-'
,
SYNTAX_ERROR
),
(
'abc
\\
)'
,
'-'
,
SYNTAX_ERROR
),
(
'
\\
(abc'
,
'-'
,
SYNTAX_ERROR
),
(
'a]'
,
'a]'
,
SUCCEED
,
'found'
,
'a]'
),
(
'a[]]b'
,
'a]b'
,
SUCCEED
,
'found'
,
'a]b'
),
(
'a[^bc]d'
,
'aed'
,
SUCCEED
,
'found'
,
'aed'
),
(
'a[^bc]d'
,
'abd'
,
FAIL
),
(
'a[^-b]c'
,
'adc'
,
SUCCEED
,
'found'
,
'adc'
),
(
'a[^-b]c'
,
'a-c'
,
FAIL
),
(
'a[^]b]c'
,
'a]c'
,
FAIL
),
(
'a[^]b]c'
,
'adc'
,
SUCCEED
,
'found'
,
'adc'
),
(
'
\\
ba
\\
b'
,
'a-'
,
SUCCEED
,
'"-"'
,
'-'
),
(
'
\\
ba
\\
b'
,
'-a'
,
SUCCEED
,
'"-"'
,
'-'
),
(
'
\\
ba
\\
b'
,
'-a-'
,
SUCCEED
,
'"-"'
,
'-'
),
(
'
\\
by
\\
b'
,
'xy'
,
FAIL
),
(
'
\\
by
\\
b'
,
'yz'
,
FAIL
),
(
'
\\
by
\\
b'
,
'xyz'
,
FAIL
),
(
'ab
\\
|cd'
,
'abc'
,
SUCCEED
,
'found'
,
'ab'
),
(
'ab
\\
|cd'
,
'abcd'
,
SUCCEED
,
'found'
,
'ab'
),
(
'
\\
(
\\
)ef'
,
'def'
,
SUCCEED
,
'found+"-"+g1'
,
'ef-'
),
(
'$b'
,
'b'
,
FAIL
),
(
'a(b'
,
'a(b'
,
SUCCEED
,
'found+"-"+g1'
,
'a(b-None'
),
(
'a(*b'
,
'ab'
,
SUCCEED
,
'found'
,
'ab'
),
(
'a(*b'
,
'a((b'
,
SUCCEED
,
'found'
,
'a((b'
),
(
'a
\\\\
b'
,
'a
\\
b'
,
SUCCEED
,
'found'
,
'a
\\
b'
),
(
'
\\
(
\\
(a
\\
)
\\
)'
,
'abc'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'a-a-a'
),
(
'
\\
(a
\\
)b
\\
(c
\\
)'
,
'abc'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'abc-a-c'
),
(
'a+b+c'
,
'aabbabc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'
\\
(a+
\\
|b
\\
)*'
,
'ab'
,
SUCCEED
,
'found+"-"+g1'
,
'ab-b'
),
(
'
\\
(a+
\\
|b
\\
)+'
,
'ab'
,
SUCCEED
,
'found+"-"+g1'
,
'ab-b'
),
(
'
\\
(a+
\\
|b
\\
)?'
,
'ab'
,
SUCCEED
,
'found+"-"+g1'
,
'a-a'
),
(
'
\\
)
\\
('
,
'-'
,
SYNTAX_ERROR
),
(
'[^ab]*'
,
'cde'
,
SUCCEED
,
'found'
,
'cde'
),
(
'abc'
,
''
,
FAIL
),
(
'a*'
,
''
,
SUCCEED
,
'found'
,
''
),
(
'a
\\
|b
\\
|c
\\
|d
\\
|e'
,
'e'
,
SUCCEED
,
'found'
,
'e'
),
(
'
\\
(a
\\
|b
\\
|c
\\
|d
\\
|e
\\
)f'
,
'ef'
,
SUCCEED
,
'found+"-"+g1'
,
'ef-e'
),
(
'abcd*efg'
,
'abcdefg'
,
SUCCEED
,
'found'
,
'abcdefg'
),
(
'ab*'
,
'xabyabbbz'
,
SUCCEED
,
'found'
,
'ab'
),
(
'ab*'
,
'xayabbbz'
,
SUCCEED
,
'found'
,
'a'
),
(
'
\\
(ab
\\
|cd
\\
)e'
,
'abcde'
,
SUCCEED
,
'found+"-"+g1'
,
'cde-cd'
),
(
'[abhgefdc]ij'
,
'hij'
,
SUCCEED
,
'found'
,
'hij'
),
(
'^
\\
(ab
\\
|cd
\\
)e'
,
'abcde'
,
FAIL
,
'xg1y'
,
'xy'
),
(
'
\\
(abc
\\
|
\\
)ef'
,
'abcdef'
,
SUCCEED
,
'found+"-"+g1'
,
'ef-'
),
(
'
\\
(a
\\
|b
\\
)c*d'
,
'abcd'
,
SUCCEED
,
'found+"-"+g1'
,
'bcd-b'
),
(
'
\\
(ab
\\
|ab*
\\
)bc'
,
'abc'
,
SUCCEED
,
'found+"-"+g1'
,
'abc-a'
),
(
'a
\\
([bc]*
\\
)c*'
,
'abc'
,
SUCCEED
,
'found+"-"+g1'
,
'abc-bc'
),
(
'a
\\
([bc]*
\\
)
\\
(c*d
\\
)'
,
'abcd'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'abcd-bc-d'
),
(
'a
\\
([bc]+
\\
)
\\
(c*d
\\
)'
,
'abcd'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'abcd-bc-d'
),
(
'a
\\
([bc]*
\\
)
\\
(c+d
\\
)'
,
'abcd'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'abcd-b-cd'
),
(
'a[bcd]*dcdcde'
,
'adcdcde'
,
SUCCEED
,
'found'
,
'adcdcde'
),
(
'a[bcd]+dcdcde'
,
'adcdcde'
,
FAIL
),
(
'
\\
(ab
\\
|a
\\
)b*c'
,
'abc'
,
SUCCEED
,
'found+"-"+g1'
,
'abc-ab'
),
(
'
\\
(
\\
(a
\\
)
\\
(b
\\
)c
\\
)
\\
(d
\\
)'
,
'abcd'
,
SUCCEED
,
'g1+"-"+g2+"-"+g3+"-"+g4'
,
'abc-a-b-d'
),
(
'[a-zA-Z_][a-zA-Z0-9_]*'
,
'alpha'
,
SUCCEED
,
'found'
,
'alpha'
),
(
'^a
\\
(bc+
\\
|b[eh]
\\
)g
\\
|.h$'
,
'abh'
,
SUCCEED
,
'found+"-"+g1'
,
'bh-None'
),
(
'
\\
(bc+d$
\\
|ef*g.
\\
|h?i
\\
(j
\\
|k
\\
)
\\
)'
,
'effgz'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'effgz-effgz-None'
),
(
'
\\
(bc+d$
\\
|ef*g.
\\
|h?i
\\
(j
\\
|k
\\
)
\\
)'
,
'ij'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'ij-ij-j'
),
(
'
\\
(bc+d$
\\
|ef*g.
\\
|h?i
\\
(j
\\
|k
\\
)
\\
)'
,
'effg'
,
FAIL
),
(
'
\\
(bc+d$
\\
|ef*g.
\\
|h?i
\\
(j
\\
|k
\\
)
\\
)'
,
'bcdd'
,
FAIL
),
(
'
\\
(bc+d$
\\
|ef*g.
\\
|h?i
\\
(j
\\
|k
\\
)
\\
)'
,
'reffgz'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'effgz-effgz-None'
),
(
'
\\
(
\\
(
\\
(
\\
(
\\
(
\\
(
\\
(
\\
(
\\
(a
\\
)
\\
)
\\
)
\\
)
\\
)
\\
)
\\
)
\\
)
\\
)'
,
'a'
,
SUCCEED
,
'found'
,
'a'
),
(
'multiple words of text'
,
'uh-uh'
,
FAIL
),
(
'multiple words'
,
'multiple words, yeah'
,
SUCCEED
,
'found'
,
'multiple words'
),
(
'
\\
(.*
\\
)c
\\
(.*
\\
)'
,
'abcde'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'abcde-ab-de'
),
(
'(
\\
(.*
\\
),
\\
(.*
\\
))'
,
'(a, b)'
,
SUCCEED
,
'g2+"-"+g1'
,
'b-a'
),
(
'[k]'
,
'ab'
,
FAIL
),
(
'a[-]?c'
,
'ac'
,
SUCCEED
,
'found'
,
'ac'
),
(
'
\\
(abc
\\
)
\\
1'
,
'abcabc'
,
SUCCEED
,
'g1'
,
'abc'
),
(
'
\\
([a-c]*
\\
)
\\
1'
,
'abcabc'
,
SUCCEED
,
'g1'
,
'abc'
),
(
'^
\\
(.+
\\
)?B'
,
'AB'
,
SUCCEED
,
'g1'
,
'A'
),
(
'
\\
(a+
\\
).
\\
1$'
,
'aaaaa'
,
SUCCEED
,
'found+"-"+g1'
,
'aaaaa-aa'
),
(
'^
\\
(a+
\\
).
\\
1$'
,
'aaaa'
,
FAIL
),
(
'
\\
(abc
\\
)
\\
1'
,
'abcabc'
,
SUCCEED
,
'found+"-"+g1'
,
'abcabc-abc'
),
(
'
\\
([a-c]+
\\
)
\\
1'
,
'abcabc'
,
SUCCEED
,
'found+"-"+g1'
,
'abcabc-abc'
),
(
'
\\
(a
\\
)
\\
1'
,
'aa'
,
SUCCEED
,
'found+"-"+g1'
,
'aa-a'
),
(
'
\\
(a+
\\
)
\\
1'
,
'aa'
,
SUCCEED
,
'found+"-"+g1'
,
'aa-a'
),
(
'
\\
(a+
\\
)+
\\
1'
,
'aa'
,
SUCCEED
,
'found+"-"+g1'
,
'aa-a'
),
(
'
\\
(a
\\
).+
\\
1'
,
'aba'
,
SUCCEED
,
'found+"-"+g1'
,
'aba-a'
),
(
'
\\
(a
\\
)ba*
\\
1'
,
'aba'
,
SUCCEED
,
'found+"-"+g1'
,
'aba-a'
),
(
'
\\
(aa
\\
|a
\\
)a
\\
1$'
,
'aaa'
,
SUCCEED
,
'found+"-"+g1'
,
'aaa-a'
),
(
'
\\
(a
\\
|aa
\\
)a
\\
1$'
,
'aaa'
,
SUCCEED
,
'found+"-"+g1'
,
'aaa-a'
),
(
'
\\
(a+
\\
)a
\\
1$'
,
'aaa'
,
SUCCEED
,
'found+"-"+g1'
,
'aaa-a'
),
(
'
\\
([abc]*
\\
)
\\
1'
,
'abcabc'
,
SUCCEED
,
'found+"-"+g1'
,
'abcabc-abc'
),
(
'
\\
(a
\\
)
\\
(b
\\
)c
\\
|ab'
,
'ab'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'ab-None-None'
),
(
'
\\
(a
\\
)+x'
,
'aaax'
,
SUCCEED
,
'found+"-"+g1'
,
'aaax-a'
),
(
'
\\
([ac]
\\
)+x'
,
'aacx'
,
SUCCEED
,
'found+"-"+g1'
,
'aacx-c'
),
(
'
\\
([^/]*/
\\
)*sub1/'
,
'd:msgs/tdir/sub1/trial/away.cpp'
,
SUCCEED
,
'found+"-"+g1'
,
'd:msgs/tdir/sub1/-tdir/'
),
(
'
\\
([^.]*
\\
)
\\
.
\\
([^:]*
\\
):[T ]+
\\
(.*
\\
)'
,
'track1.title:TBlah blah blah'
,
SUCCEED
,
'found+"-"+g1+"-"+g2+"-"+g3'
,
'track1.title:TBlah blah blah-track1-title-Blah blah blah'
),
(
'
\\
([^N]*N
\\
)+'
,
'abNNxyzN'
,
SUCCEED
,
'found+"-"+g1'
,
'abNNxyzN-xyzN'
),
(
'
\\
([^N]*N
\\
)+'
,
'abNNxyz'
,
SUCCEED
,
'found+"-"+g1'
,
'abNN-N'
),
(
'
\\
([abc]*
\\
)x'
,
'abcx'
,
SUCCEED
,
'found+"-"+g1'
,
'abcx-abc'
),
(
'
\\
([abc]*
\\
)x'
,
'abc'
,
FAIL
),
(
'
\\
([xyz]*
\\
)x'
,
'abcx'
,
SUCCEED
,
'found+"-"+g1'
,
'x-'
),
(
'
\\
(a
\\
)+b
\\
|aac'
,
'aac'
,
SUCCEED
,
'found+"-"+g1'
,
'aac-None'
),
(
'
\
<a'
,
'a'
,
SUCCEED
,
'found'
,
'a'
),
(
'
\
<a'
,
'!'
,
FAIL
),
(
'a
\
<b'
,
'ab'
,
FAIL
),
(
'a
\
>'
,
'ab'
,
FAIL
),
(
'a
\
>'
,
'a!'
,
SUCCEED
,
'found'
,
'a'
),
(
'a
\
>'
,
'a'
,
SUCCEED
,
'found'
,
'a'
),
]
Lib/dos-8x3/socketse.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -34,10 +34,10 @@ synchronous servers of four types:
| UDPServer |------->| UnixDatagramServer |
+-----------+ +--------------------+
(
Note that UnixDatagramServer derives from UDPServer, not from
Note that UnixDatagramServer derives from UDPServer, not from
UnixStreamServer -- the only difference between an IP and a Unix
stream server is the address family, which is simply repeated in both
unix server classes.
)
unix server classes.
Forking and threading versions of each type of server can be created
using the ForkingServer and ThreadingServer mix-in classes. For
...
...
@@ -45,8 +45,8 @@ instance, a threading UDP server class is created as follows:
class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass
(
The Mix-in class must come first, since it overrides a method defined
in UDPServer!
)
The Mix-in class must come first, since it overrides a method defined
in UDPServer!
To implement a service, you must derive a class from
BaseRequestHandler and redefine its handle() method. You can then run
...
...
@@ -266,7 +266,7 @@ class UDPServer(TCPServer):
max_packet_size
=
8192
def
get_request
(
self
):
return
self
.
socket
.
recvfrom
(
max_packet_size
)
return
self
.
socket
.
recvfrom
(
self
.
max_packet_size
)
if
hasattr
(
socket
,
'AF_UNIX'
):
...
...
Lib/dos-8x3/stringio.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -64,7 +64,7 @@ class StringIO:
r
=
self
.
buf
[
self
.
pos
:
newpos
]
self
.
pos
=
newpos
return
r
def
readline
(
self
):
def
readline
(
self
,
length
=
None
):
if
self
.
buflist
:
self
.
buf
=
self
.
buf
+
string
.
joinfields
(
self
.
buflist
,
''
)
self
.
buflist
=
[]
...
...
@@ -73,6 +73,9 @@ class StringIO:
newpos
=
self
.
len
else
:
newpos
=
i
+
1
if
length
is
not
None
:
if
self
.
pos
+
length
<
newpos
:
newpos
=
self
.
pos
+
length
r
=
self
.
buf
[
self
.
pos
:
newpos
]
self
.
pos
=
newpos
return
r
...
...
Lib/dos-8x3/test_opc.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -57,3 +57,38 @@ except AClass, v:
try
:
raise
BClass
,
a
except
TypeError
:
pass
print
'2.3 comparing function objects'
f
=
eval
(
'lambda: None'
)
g
=
eval
(
'lambda: None'
)
if
f
!=
g
:
raise
TestFailed
f
=
eval
(
'lambda a: a'
)
g
=
eval
(
'lambda a: a'
)
if
f
!=
g
:
raise
TestFailed
f
=
eval
(
'lambda a=1: a'
)
g
=
eval
(
'lambda a=1: a'
)
if
f
!=
g
:
raise
TestFailed
f
=
eval
(
'lambda: 0'
)
g
=
eval
(
'lambda: 1'
)
if
f
==
g
:
raise
TestFailed
f
=
eval
(
'lambda: None'
)
g
=
eval
(
'lambda a: None'
)
if
f
==
g
:
raise
TestFailed
f
=
eval
(
'lambda a: None'
)
g
=
eval
(
'lambda b: None'
)
if
f
==
g
:
raise
TestFailed
f
=
eval
(
'lambda a: None'
)
g
=
eval
(
'lambda a=None: None'
)
if
f
==
g
:
raise
TestFailed
f
=
eval
(
'lambda a=0: None'
)
g
=
eval
(
'lambda a=1: None'
)
if
f
==
g
:
raise
TestFailed
Lib/dos-8x3/test_reg.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -60,3 +60,51 @@ except regex.error:
print
'caught expected exception'
else
:
print
'expected regex.error not raised'
from
regex_tests
import
*
if
verbose
:
print
'Running regex_tests test suite'
for
t
in
tests
:
pattern
=
s
=
outcome
=
repl
=
expected
=
None
if
len
(
t
)
==
5
:
pattern
,
s
,
outcome
,
repl
,
expected
=
t
elif
len
(
t
)
==
3
:
pattern
,
s
,
outcome
=
t
else
:
raise
ValueError
,
(
'Test tuples should have 3 or 5 fields'
,
t
)
try
:
obj
=
regex
.
compile
(
pattern
)
except
regex
.
error
:
if
outcome
==
SYNTAX_ERROR
:
pass
# Expected a syntax error
else
:
# Regex syntax errors aren't yet reported, so for
# the official test suite they'll be quietly ignored.
pass
#print '=== Syntax error:', t
else
:
try
:
result
=
obj
.
search
(
s
)
except
regex
.
error
,
msg
:
print
'=== Unexpected exception'
,
t
,
repr
(
msg
)
if
outcome
==
SYNTAX_ERROR
:
# This should have been a syntax error; forget it.
pass
elif
outcome
==
FAIL
:
if
result
==-
1
:
pass
# No match, as expected
else
:
print
'=== Succeeded incorrectly'
,
t
elif
outcome
==
SUCCEED
:
if
result
!=-
1
:
# Matched, as expected, so now we compute the
# result string and compare it to our expected result.
start
,
end
=
obj
.
regs
[
0
]
found
=
s
[
start
:
end
]
groups
=
obj
.
group
(
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
)
vardict
=
vars
()
for
i
in
range
(
len
(
groups
)):
vardict
[
'g'
+
str
(
i
+
1
)]
=
str
(
groups
[
i
])
repl
=
eval
(
repl
)
if
repl
!=
expected
:
print
'=== grouping error'
,
t
,
repr
(
repl
)
+
' should be '
+
repr
(
expected
)
else
:
print
'=== Failed incorrectly'
,
t
Lib/dos-8x3/test_rot.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -7,7 +7,7 @@ A = 'spam and eggs'
B
=
'cheese shop'
a
=
r
.
encrypt
(
A
)
print
a
print
`a`
b
=
r
.
encryptmore
(
B
)
print
b
...
...
Lib/dos-8x3/test_soc.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -65,7 +65,7 @@ for optional in ("AF_UNIX",
):
missing_ok
(
optional
)
socktype
=
socket
.
socket_t
ype
socktype
=
socket
.
SocketT
ype
hostname
=
socket
.
gethostname
()
ip
=
socket
.
gethostbyname
(
hostname
)
hname
,
aliases
,
ipaddrs
=
socket
.
gethostbyaddr
(
ip
)
...
...
Lib/dos-8x3/test_thr.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -21,7 +21,7 @@ def task(ident):
delay
=
whrandom
.
random
()
*
numtasks
whmutex
.
release
()
if
verbose
:
print
'task'
,
ident
,
'will run for'
,
delay
,
'sec'
print
'task'
,
ident
,
'will run for'
,
round
(
delay
,
1
)
,
'sec'
time
.
sleep
(
delay
)
if
verbose
:
print
'task'
,
ident
,
'done'
...
...
@@ -89,7 +89,7 @@ def task2(ident):
delay
=
whrandom
.
random
()
*
numtasks
whmutex
.
release
()
if
verbose
:
print
'task'
,
ident
,
'will run for'
,
delay
,
'sec'
print
'task'
,
ident
,
'will run for'
,
round
(
delay
,
1
)
,
'sec'
time
.
sleep
(
delay
)
if
verbose
:
print
'task'
,
ident
,
'entering barrier'
,
i
...
...
Lib/dos-8x3/test_typ.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -183,9 +183,9 @@ if d <> {'a': 4, 'c': 3}: raise TestFailed, 'dict item deletion'
d
=
{
1
:
1
,
2
:
2
,
3
:
3
}
d
.
clear
()
if
d
!=
{}:
raise
TestFailed
,
'dict clear'
d
.
absorb
({
1
:
100
})
d
.
absorb
({
2
:
20
})
d
.
absorb
({
1
:
1
,
2
:
2
,
3
:
3
})
if
d
!=
{
1
:
1
,
2
:
2
,
3
:
3
}:
raise
TestFailed
,
'dict
absorb
'
d
.
update
({
1
:
100
})
d
.
update
({
2
:
20
})
d
.
update
({
1
:
1
,
2
:
2
,
3
:
3
})
if
d
!=
{
1
:
1
,
2
:
2
,
3
:
3
}:
raise
TestFailed
,
'dict
update
'
if
d
.
copy
()
!=
{
1
:
1
,
2
:
2
,
3
:
3
}:
raise
TestFailed
,
'dict copy'
if
{}
.
copy
()
!=
{}:
raise
TestFailed
,
'empty dict copy'
Lib/dos-8x3/tracebac.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -128,8 +128,11 @@ def format_exception_only(etype, value):
def
print_exc
(
limit
=
None
,
file
=
None
):
if
not
file
:
file
=
sys
.
stderr
print_exception
(
sys
.
exc_type
,
sys
.
exc_value
,
sys
.
exc_traceback
,
limit
,
file
)
try
:
etype
,
value
,
tb
=
sys
.
exc_info
()
print_exception
(
etype
,
value
,
tb
,
limit
,
file
)
finally
:
etype
=
value
=
tb
=
None
def
print_last
(
limit
=
None
,
file
=
None
):
if
not
file
:
...
...
@@ -143,8 +146,7 @@ def print_stack(f=None, limit=None, file=None):
try
:
raise
ZeroDivisionError
except
ZeroDivisionError
:
tb
=
sys
.
exc_traceback
f
=
tb
.
tb_frame
.
f_back
f
=
sys
.
exc_info
()[
2
]
.
tb_frame
.
f_back
print_list
(
extract_stack
(
f
,
limit
),
file
)
def
format_stack
(
f
=
None
,
limit
=
None
):
...
...
@@ -152,17 +154,15 @@ def format_stack(f=None, limit=None):
try
:
raise
ZeroDivisionError
except
ZeroDivisionError
:
tb
=
sys
.
exc_traceback
f
=
tb
.
tb_frame
.
f_back
return
format_list
(
extract_stack
(
t
,
limit
))
f
=
sys
.
exc_info
()[
2
]
.
tb_frame
.
f_back
return
format_list
(
extract_stack
(
f
,
limit
))
def
extract_stack
(
f
=
None
,
limit
=
None
):
if
f
is
None
:
try
:
raise
ZeroDivisionError
except
ZeroDivisionError
:
tb
=
sys
.
exc_traceback
f
=
tb
.
tb_frame
.
f_back
f
=
sys
.
exc_info
()[
2
]
.
tb_frame
.
f_back
if
limit
is
None
:
if
hasattr
(
sys
,
'tracebacklimit'
):
limit
=
sys
.
tracebacklimit
...
...
Lib/dos-8x3/userdict.py
Dosyayı görüntüle @
ff712aa8
# A more or less complete user-defined wrapper around dictionary objects
class
UserDict
:
def
__init__
(
self
):
self
.
data
=
{}
def
__repr__
(
self
):
return
repr
(
self
.
data
)
def
__cmp__
(
self
,
dict
):
if
type
(
dict
)
==
type
(
self
.
data
):
return
cmp
(
self
.
data
,
dict
)
else
:
return
cmp
(
self
.
data
,
dict
.
data
)
def
__len__
(
self
):
return
len
(
self
.
data
)
def
__getitem__
(
self
,
key
):
return
self
.
data
[
key
]
def
__setitem__
(
self
,
key
,
item
):
self
.
data
[
key
]
=
item
def
__delitem__
(
self
,
key
):
del
self
.
data
[
key
]
def
keys
(
self
):
return
self
.
data
.
keys
()
def
items
(
self
):
return
self
.
data
.
items
()
def
values
(
self
):
return
self
.
data
.
values
()
def
has_key
(
self
,
key
):
return
self
.
data
.
has_key
(
key
)
def
__init__
(
self
):
self
.
data
=
{}
def
__repr__
(
self
):
return
repr
(
self
.
data
)
def
__cmp__
(
self
,
dict
):
if
type
(
dict
)
==
type
(
self
.
data
):
return
cmp
(
self
.
data
,
dict
)
else
:
return
cmp
(
self
.
data
,
dict
.
data
)
def
__len__
(
self
):
return
len
(
self
.
data
)
def
__getitem__
(
self
,
key
):
return
self
.
data
[
key
]
def
__setitem__
(
self
,
key
,
item
):
self
.
data
[
key
]
=
item
def
__delitem__
(
self
,
key
):
del
self
.
data
[
key
]
def
clear
(
self
):
return
self
.
data
.
clear
()
def
copy
(
self
):
import
copy
return
copy
.
copy
(
self
)
def
keys
(
self
):
return
self
.
data
.
keys
()
def
items
(
self
):
return
self
.
data
.
items
()
def
values
(
self
):
return
self
.
data
.
values
()
def
has_key
(
self
,
key
):
return
self
.
data
.
has_key
(
key
)
def
update
(
self
,
other
):
if
type
(
other
)
is
type
(
self
.
data
):
self
.
data
.
update
(
other
)
else
:
for
k
,
v
in
other
.
items
():
self
.
data
[
k
]
=
v
Lib/dos_8x3/basehttp.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -236,7 +236,7 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
words
=
string
.
split
(
requestline
)
if
len
(
words
)
==
3
:
[
command
,
path
,
version
]
=
words
if
version
!=
self
.
protocol_version
:
if
version
[:
5
]
!=
'HTTP/'
:
self
.
send_error
(
400
,
"Bad request version (
%
s)"
%
`version`
)
return
elif
len
(
words
)
==
2
:
...
...
@@ -297,7 +297,7 @@ class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
self
.
log_request
(
code
)
if
message
is
None
:
if
self
.
responses
.
has_key
(
code
):
message
=
self
.
responses
[
code
][
1
]
message
=
self
.
responses
[
code
][
0
]
else
:
message
=
''
if
self
.
request_version
!=
'HTTP/0.9'
:
...
...
Lib/dos_8x3/mimetool.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -131,9 +131,16 @@ def choose_boundary():
# Subroutines for decoding some common content-transfer-types
# XXX This requires that uudecode and mmencode are in $PATH
def
decode
(
input
,
output
,
encoding
):
if
encoding
==
'base64'
:
import
base64
return
base64
.
decode
(
input
,
output
)
if
encoding
==
'quoted-printable'
:
import
quopri
return
quopri
.
decode
(
input
,
output
)
if
encoding
in
(
'uuencode'
,
'x-uuencode'
):
import
uu
return
uu
.
decode
(
input
,
output
)
if
decodetab
.
has_key
(
encoding
):
pipethrough
(
input
,
decodetab
[
encoding
],
output
)
else
:
...
...
@@ -141,12 +148,25 @@ def decode(input, output, encoding):
'unknown Content-Transfer-Encoding:
%
s'
%
encoding
def
encode
(
input
,
output
,
encoding
):
if
encoding
==
'base64'
:
import
base64
return
base64
.
encode
(
input
,
output
)
if
encoding
==
'quoted-printable'
:
import
quopri
return
quopri
.
encode
(
input
,
output
,
0
)
if
encoding
in
(
'uuencode'
,
'x-uuencode'
):
import
uu
return
uu
.
encode
(
input
,
output
)
if
encodetab
.
has_key
(
encoding
):
pipethrough
(
input
,
encodetab
[
encoding
],
output
)
else
:
raise
ValueError
,
\
'unknown Content-Transfer-Encoding:
%
s'
%
encoding
# The following is no longer used for standard encodings
# XXX This requires that uudecode and mmencode are in $PATH
uudecode_pipe
=
'''(
TEMP=/tmp/@uu.$$
sed "s
%
^begin [0-7][0-7]* .*
%
begin 600 $TEMP
%
" | uudecode
...
...
Lib/dos_8x3/nturl2pa.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -4,8 +4,6 @@
def
url2pathname
(
url
):
""" Convert a URL to a DOS path...
Currently only works for absolute paths
///C|/foo/bar/spam.foo
becomes
...
...
@@ -13,6 +11,10 @@ def url2pathname(url):
C:
\f
oo
\b
ar
\
spam.foo
"""
import
string
if
not
'|'
in
url
:
# No drive specifier, just convert slashes
components
=
string
.
splitfields
(
url
,
'/'
)
return
string
.
joinfields
(
components
,
'
\\
'
)
comp
=
string
.
splitfields
(
url
,
'|'
)
if
len
(
comp
)
!=
2
or
comp
[
0
][
-
1
]
not
in
string
.
letters
:
error
=
'Bad URL: '
+
url
...
...
@@ -28,8 +30,6 @@ def url2pathname(url):
def
pathname2url
(
p
):
""" Convert a DOS path name to a file url...
Currently only works for absolute paths
C:
\f
oo
\b
ar
\
spam.foo
becomes
...
...
@@ -38,6 +38,10 @@ def pathname2url(p):
"""
import
string
if
not
':'
in
p
:
# No drive specifier, just convert slashes
components
=
string
.
splitfields
(
p
,
'
\\
'
)
return
string
.
joinfields
(
components
,
'/'
)
comp
=
string
.
splitfields
(
p
,
':'
)
if
len
(
comp
)
!=
2
or
len
(
comp
[
0
])
>
1
:
error
=
'Bad path: '
+
p
...
...
Lib/dos_8x3/regex_te.py
0 → 100644
Dosyayı görüntüle @
ff712aa8
# Regex test suite and benchmark suite v1.5a2
# Due to the use of r"aw" strings, this file will
# only work with Python 1.5 or higher.
# The 3 possible outcomes for each pattern
[
SUCCEED
,
FAIL
,
SYNTAX_ERROR
]
=
range
(
3
)
# Benchmark suite (needs expansion)
#
# The benchmark suite does not test correctness, just speed. The
# first element of each tuple is the regex pattern; the second is a
# string to match it against. The benchmarking code will embed the
# second string inside several sizes of padding, to test how regex
# matching performs on large strings.
benchmarks
=
[
(
'Python'
,
'Python'
),
# Simple text literal
(
'.*Python'
,
'Python'
),
# Bad text literal
(
'.*Python.*'
,
'Python'
),
# Worse text literal
(
'.*
\\
(Python
\\
)'
,
'Python'
),
# Bad text literal with grouping
(
'(Python
\\
|Perl
\\
|Tcl'
,
'Perl'
),
# Alternation
(
'
\\
(Python
\\
|Perl
\\
|Tcl
\\
)'
,
'Perl'
),
# Grouped alternation
(
'
\\
(Python
\\
)
\\
1'
,
'PythonPython'
),
# Backreference
# ('\\([0a-z][a-z]*,\\)+', 'a5,b7,c9,'), # Disable the fastmap optimization
(
'
\\
([a-z][a-z0-9]*,
\\
)+'
,
'a5,b7,c9,'
)
# A few sets
]
# Test suite (for verifying correctness)
#
# The test suite is a list of 5- or 3-tuples. The 5 parts of a
# complete tuple are:
# element 0: a string containing the pattern
# 1: the string to match against the pattern
# 2: the expected result (SUCCEED, FAIL, SYNTAX_ERROR)
# 3: a string that will be eval()'ed to produce a test string.
# This is an arbitrary Python expression; the available
# variables are "found" (the whole match), and "g1", "g2", ...
# up to "g10" contain the contents of each group, or the
# string 'None' if the group wasn't given a value.
# 4: The expected result of evaluating the expression.
# If the two don't match, an error is reported.
#
# If the regex isn't expected to work, the latter two elements can be omitted.
tests
=
[
(
'abc'
,
'abc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'abc'
,
'xbc'
,
FAIL
),
(
'abc'
,
'axc'
,
FAIL
),
(
'abc'
,
'abx'
,
FAIL
),
(
'abc'
,
'xabcy'
,
SUCCEED
,
'found'
,
'abc'
),
(
'abc'
,
'ababc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'ab*c'
,
'abc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'ab*bc'
,
'abc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'ab*bc'
,
'abbc'
,
SUCCEED
,
'found'
,
'abbc'
),
(
'ab*bc'
,
'abbbbc'
,
SUCCEED
,
'found'
,
'abbbbc'
),
(
'ab+bc'
,
'abbc'
,
SUCCEED
,
'found'
,
'abbc'
),
(
'ab+bc'
,
'abc'
,
FAIL
),
(
'ab+bc'
,
'abq'
,
FAIL
),
(
'ab+bc'
,
'abbbbc'
,
SUCCEED
,
'found'
,
'abbbbc'
),
(
'ab?bc'
,
'abbc'
,
SUCCEED
,
'found'
,
'abbc'
),
(
'ab?bc'
,
'abc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'ab?bc'
,
'abbbbc'
,
FAIL
),
(
'ab?c'
,
'abc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'^abc$'
,
'abc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'^abc$'
,
'abcc'
,
FAIL
),
(
'^abc'
,
'abcc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'^abc$'
,
'aabc'
,
FAIL
),
(
'abc$'
,
'aabc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'^'
,
'abc'
,
SUCCEED
,
'found+"-"'
,
'-'
),
(
'$'
,
'abc'
,
SUCCEED
,
'found+"-"'
,
'-'
),
(
'a.c'
,
'abc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'a.c'
,
'axc'
,
SUCCEED
,
'found'
,
'axc'
),
(
'a.*c'
,
'axyzc'
,
SUCCEED
,
'found'
,
'axyzc'
),
(
'a.*c'
,
'axyzd'
,
FAIL
),
(
'a[bc]d'
,
'abc'
,
FAIL
),
(
'a[bc]d'
,
'abd'
,
SUCCEED
,
'found'
,
'abd'
),
(
'a[b-d]e'
,
'abd'
,
FAIL
),
(
'a[b-d]e'
,
'ace'
,
SUCCEED
,
'found'
,
'ace'
),
(
'a[b-d]'
,
'aac'
,
SUCCEED
,
'found'
,
'ac'
),
(
'a[-b]'
,
'a-'
,
SUCCEED
,
'found'
,
'a-'
),
(
'a[b-]'
,
'a-'
,
SUCCEED
,
'found'
,
'a-'
),
(
'a[]b'
,
'-'
,
SYNTAX_ERROR
),
(
'a['
,
'-'
,
SYNTAX_ERROR
),
(
'a
\\
'
,
'-'
,
SYNTAX_ERROR
),
(
'abc
\\
)'
,
'-'
,
SYNTAX_ERROR
),
(
'
\\
(abc'
,
'-'
,
SYNTAX_ERROR
),
(
'a]'
,
'a]'
,
SUCCEED
,
'found'
,
'a]'
),
(
'a[]]b'
,
'a]b'
,
SUCCEED
,
'found'
,
'a]b'
),
(
'a[^bc]d'
,
'aed'
,
SUCCEED
,
'found'
,
'aed'
),
(
'a[^bc]d'
,
'abd'
,
FAIL
),
(
'a[^-b]c'
,
'adc'
,
SUCCEED
,
'found'
,
'adc'
),
(
'a[^-b]c'
,
'a-c'
,
FAIL
),
(
'a[^]b]c'
,
'a]c'
,
FAIL
),
(
'a[^]b]c'
,
'adc'
,
SUCCEED
,
'found'
,
'adc'
),
(
'
\\
ba
\\
b'
,
'a-'
,
SUCCEED
,
'"-"'
,
'-'
),
(
'
\\
ba
\\
b'
,
'-a'
,
SUCCEED
,
'"-"'
,
'-'
),
(
'
\\
ba
\\
b'
,
'-a-'
,
SUCCEED
,
'"-"'
,
'-'
),
(
'
\\
by
\\
b'
,
'xy'
,
FAIL
),
(
'
\\
by
\\
b'
,
'yz'
,
FAIL
),
(
'
\\
by
\\
b'
,
'xyz'
,
FAIL
),
(
'ab
\\
|cd'
,
'abc'
,
SUCCEED
,
'found'
,
'ab'
),
(
'ab
\\
|cd'
,
'abcd'
,
SUCCEED
,
'found'
,
'ab'
),
(
'
\\
(
\\
)ef'
,
'def'
,
SUCCEED
,
'found+"-"+g1'
,
'ef-'
),
(
'$b'
,
'b'
,
FAIL
),
(
'a(b'
,
'a(b'
,
SUCCEED
,
'found+"-"+g1'
,
'a(b-None'
),
(
'a(*b'
,
'ab'
,
SUCCEED
,
'found'
,
'ab'
),
(
'a(*b'
,
'a((b'
,
SUCCEED
,
'found'
,
'a((b'
),
(
'a
\\\\
b'
,
'a
\\
b'
,
SUCCEED
,
'found'
,
'a
\\
b'
),
(
'
\\
(
\\
(a
\\
)
\\
)'
,
'abc'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'a-a-a'
),
(
'
\\
(a
\\
)b
\\
(c
\\
)'
,
'abc'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'abc-a-c'
),
(
'a+b+c'
,
'aabbabc'
,
SUCCEED
,
'found'
,
'abc'
),
(
'
\\
(a+
\\
|b
\\
)*'
,
'ab'
,
SUCCEED
,
'found+"-"+g1'
,
'ab-b'
),
(
'
\\
(a+
\\
|b
\\
)+'
,
'ab'
,
SUCCEED
,
'found+"-"+g1'
,
'ab-b'
),
(
'
\\
(a+
\\
|b
\\
)?'
,
'ab'
,
SUCCEED
,
'found+"-"+g1'
,
'a-a'
),
(
'
\\
)
\\
('
,
'-'
,
SYNTAX_ERROR
),
(
'[^ab]*'
,
'cde'
,
SUCCEED
,
'found'
,
'cde'
),
(
'abc'
,
''
,
FAIL
),
(
'a*'
,
''
,
SUCCEED
,
'found'
,
''
),
(
'a
\\
|b
\\
|c
\\
|d
\\
|e'
,
'e'
,
SUCCEED
,
'found'
,
'e'
),
(
'
\\
(a
\\
|b
\\
|c
\\
|d
\\
|e
\\
)f'
,
'ef'
,
SUCCEED
,
'found+"-"+g1'
,
'ef-e'
),
(
'abcd*efg'
,
'abcdefg'
,
SUCCEED
,
'found'
,
'abcdefg'
),
(
'ab*'
,
'xabyabbbz'
,
SUCCEED
,
'found'
,
'ab'
),
(
'ab*'
,
'xayabbbz'
,
SUCCEED
,
'found'
,
'a'
),
(
'
\\
(ab
\\
|cd
\\
)e'
,
'abcde'
,
SUCCEED
,
'found+"-"+g1'
,
'cde-cd'
),
(
'[abhgefdc]ij'
,
'hij'
,
SUCCEED
,
'found'
,
'hij'
),
(
'^
\\
(ab
\\
|cd
\\
)e'
,
'abcde'
,
FAIL
,
'xg1y'
,
'xy'
),
(
'
\\
(abc
\\
|
\\
)ef'
,
'abcdef'
,
SUCCEED
,
'found+"-"+g1'
,
'ef-'
),
(
'
\\
(a
\\
|b
\\
)c*d'
,
'abcd'
,
SUCCEED
,
'found+"-"+g1'
,
'bcd-b'
),
(
'
\\
(ab
\\
|ab*
\\
)bc'
,
'abc'
,
SUCCEED
,
'found+"-"+g1'
,
'abc-a'
),
(
'a
\\
([bc]*
\\
)c*'
,
'abc'
,
SUCCEED
,
'found+"-"+g1'
,
'abc-bc'
),
(
'a
\\
([bc]*
\\
)
\\
(c*d
\\
)'
,
'abcd'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'abcd-bc-d'
),
(
'a
\\
([bc]+
\\
)
\\
(c*d
\\
)'
,
'abcd'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'abcd-bc-d'
),
(
'a
\\
([bc]*
\\
)
\\
(c+d
\\
)'
,
'abcd'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'abcd-b-cd'
),
(
'a[bcd]*dcdcde'
,
'adcdcde'
,
SUCCEED
,
'found'
,
'adcdcde'
),
(
'a[bcd]+dcdcde'
,
'adcdcde'
,
FAIL
),
(
'
\\
(ab
\\
|a
\\
)b*c'
,
'abc'
,
SUCCEED
,
'found+"-"+g1'
,
'abc-ab'
),
(
'
\\
(
\\
(a
\\
)
\\
(b
\\
)c
\\
)
\\
(d
\\
)'
,
'abcd'
,
SUCCEED
,
'g1+"-"+g2+"-"+g3+"-"+g4'
,
'abc-a-b-d'
),
(
'[a-zA-Z_][a-zA-Z0-9_]*'
,
'alpha'
,
SUCCEED
,
'found'
,
'alpha'
),
(
'^a
\\
(bc+
\\
|b[eh]
\\
)g
\\
|.h$'
,
'abh'
,
SUCCEED
,
'found+"-"+g1'
,
'bh-None'
),
(
'
\\
(bc+d$
\\
|ef*g.
\\
|h?i
\\
(j
\\
|k
\\
)
\\
)'
,
'effgz'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'effgz-effgz-None'
),
(
'
\\
(bc+d$
\\
|ef*g.
\\
|h?i
\\
(j
\\
|k
\\
)
\\
)'
,
'ij'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'ij-ij-j'
),
(
'
\\
(bc+d$
\\
|ef*g.
\\
|h?i
\\
(j
\\
|k
\\
)
\\
)'
,
'effg'
,
FAIL
),
(
'
\\
(bc+d$
\\
|ef*g.
\\
|h?i
\\
(j
\\
|k
\\
)
\\
)'
,
'bcdd'
,
FAIL
),
(
'
\\
(bc+d$
\\
|ef*g.
\\
|h?i
\\
(j
\\
|k
\\
)
\\
)'
,
'reffgz'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'effgz-effgz-None'
),
(
'
\\
(
\\
(
\\
(
\\
(
\\
(
\\
(
\\
(
\\
(
\\
(a
\\
)
\\
)
\\
)
\\
)
\\
)
\\
)
\\
)
\\
)
\\
)'
,
'a'
,
SUCCEED
,
'found'
,
'a'
),
(
'multiple words of text'
,
'uh-uh'
,
FAIL
),
(
'multiple words'
,
'multiple words, yeah'
,
SUCCEED
,
'found'
,
'multiple words'
),
(
'
\\
(.*
\\
)c
\\
(.*
\\
)'
,
'abcde'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'abcde-ab-de'
),
(
'(
\\
(.*
\\
),
\\
(.*
\\
))'
,
'(a, b)'
,
SUCCEED
,
'g2+"-"+g1'
,
'b-a'
),
(
'[k]'
,
'ab'
,
FAIL
),
(
'a[-]?c'
,
'ac'
,
SUCCEED
,
'found'
,
'ac'
),
(
'
\\
(abc
\\
)
\\
1'
,
'abcabc'
,
SUCCEED
,
'g1'
,
'abc'
),
(
'
\\
([a-c]*
\\
)
\\
1'
,
'abcabc'
,
SUCCEED
,
'g1'
,
'abc'
),
(
'^
\\
(.+
\\
)?B'
,
'AB'
,
SUCCEED
,
'g1'
,
'A'
),
(
'
\\
(a+
\\
).
\\
1$'
,
'aaaaa'
,
SUCCEED
,
'found+"-"+g1'
,
'aaaaa-aa'
),
(
'^
\\
(a+
\\
).
\\
1$'
,
'aaaa'
,
FAIL
),
(
'
\\
(abc
\\
)
\\
1'
,
'abcabc'
,
SUCCEED
,
'found+"-"+g1'
,
'abcabc-abc'
),
(
'
\\
([a-c]+
\\
)
\\
1'
,
'abcabc'
,
SUCCEED
,
'found+"-"+g1'
,
'abcabc-abc'
),
(
'
\\
(a
\\
)
\\
1'
,
'aa'
,
SUCCEED
,
'found+"-"+g1'
,
'aa-a'
),
(
'
\\
(a+
\\
)
\\
1'
,
'aa'
,
SUCCEED
,
'found+"-"+g1'
,
'aa-a'
),
(
'
\\
(a+
\\
)+
\\
1'
,
'aa'
,
SUCCEED
,
'found+"-"+g1'
,
'aa-a'
),
(
'
\\
(a
\\
).+
\\
1'
,
'aba'
,
SUCCEED
,
'found+"-"+g1'
,
'aba-a'
),
(
'
\\
(a
\\
)ba*
\\
1'
,
'aba'
,
SUCCEED
,
'found+"-"+g1'
,
'aba-a'
),
(
'
\\
(aa
\\
|a
\\
)a
\\
1$'
,
'aaa'
,
SUCCEED
,
'found+"-"+g1'
,
'aaa-a'
),
(
'
\\
(a
\\
|aa
\\
)a
\\
1$'
,
'aaa'
,
SUCCEED
,
'found+"-"+g1'
,
'aaa-a'
),
(
'
\\
(a+
\\
)a
\\
1$'
,
'aaa'
,
SUCCEED
,
'found+"-"+g1'
,
'aaa-a'
),
(
'
\\
([abc]*
\\
)
\\
1'
,
'abcabc'
,
SUCCEED
,
'found+"-"+g1'
,
'abcabc-abc'
),
(
'
\\
(a
\\
)
\\
(b
\\
)c
\\
|ab'
,
'ab'
,
SUCCEED
,
'found+"-"+g1+"-"+g2'
,
'ab-None-None'
),
(
'
\\
(a
\\
)+x'
,
'aaax'
,
SUCCEED
,
'found+"-"+g1'
,
'aaax-a'
),
(
'
\\
([ac]
\\
)+x'
,
'aacx'
,
SUCCEED
,
'found+"-"+g1'
,
'aacx-c'
),
(
'
\\
([^/]*/
\\
)*sub1/'
,
'd:msgs/tdir/sub1/trial/away.cpp'
,
SUCCEED
,
'found+"-"+g1'
,
'd:msgs/tdir/sub1/-tdir/'
),
(
'
\\
([^.]*
\\
)
\\
.
\\
([^:]*
\\
):[T ]+
\\
(.*
\\
)'
,
'track1.title:TBlah blah blah'
,
SUCCEED
,
'found+"-"+g1+"-"+g2+"-"+g3'
,
'track1.title:TBlah blah blah-track1-title-Blah blah blah'
),
(
'
\\
([^N]*N
\\
)+'
,
'abNNxyzN'
,
SUCCEED
,
'found+"-"+g1'
,
'abNNxyzN-xyzN'
),
(
'
\\
([^N]*N
\\
)+'
,
'abNNxyz'
,
SUCCEED
,
'found+"-"+g1'
,
'abNN-N'
),
(
'
\\
([abc]*
\\
)x'
,
'abcx'
,
SUCCEED
,
'found+"-"+g1'
,
'abcx-abc'
),
(
'
\\
([abc]*
\\
)x'
,
'abc'
,
FAIL
),
(
'
\\
([xyz]*
\\
)x'
,
'abcx'
,
SUCCEED
,
'found+"-"+g1'
,
'x-'
),
(
'
\\
(a
\\
)+b
\\
|aac'
,
'aac'
,
SUCCEED
,
'found+"-"+g1'
,
'aac-None'
),
(
'
\
<a'
,
'a'
,
SUCCEED
,
'found'
,
'a'
),
(
'
\
<a'
,
'!'
,
FAIL
),
(
'a
\
<b'
,
'ab'
,
FAIL
),
(
'a
\
>'
,
'ab'
,
FAIL
),
(
'a
\
>'
,
'a!'
,
SUCCEED
,
'found'
,
'a'
),
(
'a
\
>'
,
'a'
,
SUCCEED
,
'found'
,
'a'
),
]
Lib/dos_8x3/socketse.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -34,10 +34,10 @@ synchronous servers of four types:
| UDPServer |------->| UnixDatagramServer |
+-----------+ +--------------------+
(
Note that UnixDatagramServer derives from UDPServer, not from
Note that UnixDatagramServer derives from UDPServer, not from
UnixStreamServer -- the only difference between an IP and a Unix
stream server is the address family, which is simply repeated in both
unix server classes.
)
unix server classes.
Forking and threading versions of each type of server can be created
using the ForkingServer and ThreadingServer mix-in classes. For
...
...
@@ -45,8 +45,8 @@ instance, a threading UDP server class is created as follows:
class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass
(
The Mix-in class must come first, since it overrides a method defined
in UDPServer!
)
The Mix-in class must come first, since it overrides a method defined
in UDPServer!
To implement a service, you must derive a class from
BaseRequestHandler and redefine its handle() method. You can then run
...
...
@@ -266,7 +266,7 @@ class UDPServer(TCPServer):
max_packet_size
=
8192
def
get_request
(
self
):
return
self
.
socket
.
recvfrom
(
max_packet_size
)
return
self
.
socket
.
recvfrom
(
self
.
max_packet_size
)
if
hasattr
(
socket
,
'AF_UNIX'
):
...
...
Lib/dos_8x3/stringio.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -64,7 +64,7 @@ class StringIO:
r
=
self
.
buf
[
self
.
pos
:
newpos
]
self
.
pos
=
newpos
return
r
def
readline
(
self
):
def
readline
(
self
,
length
=
None
):
if
self
.
buflist
:
self
.
buf
=
self
.
buf
+
string
.
joinfields
(
self
.
buflist
,
''
)
self
.
buflist
=
[]
...
...
@@ -73,6 +73,9 @@ class StringIO:
newpos
=
self
.
len
else
:
newpos
=
i
+
1
if
length
is
not
None
:
if
self
.
pos
+
length
<
newpos
:
newpos
=
self
.
pos
+
length
r
=
self
.
buf
[
self
.
pos
:
newpos
]
self
.
pos
=
newpos
return
r
...
...
Lib/dos_8x3/test_opc.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -57,3 +57,38 @@ except AClass, v:
try
:
raise
BClass
,
a
except
TypeError
:
pass
print
'2.3 comparing function objects'
f
=
eval
(
'lambda: None'
)
g
=
eval
(
'lambda: None'
)
if
f
!=
g
:
raise
TestFailed
f
=
eval
(
'lambda a: a'
)
g
=
eval
(
'lambda a: a'
)
if
f
!=
g
:
raise
TestFailed
f
=
eval
(
'lambda a=1: a'
)
g
=
eval
(
'lambda a=1: a'
)
if
f
!=
g
:
raise
TestFailed
f
=
eval
(
'lambda: 0'
)
g
=
eval
(
'lambda: 1'
)
if
f
==
g
:
raise
TestFailed
f
=
eval
(
'lambda: None'
)
g
=
eval
(
'lambda a: None'
)
if
f
==
g
:
raise
TestFailed
f
=
eval
(
'lambda a: None'
)
g
=
eval
(
'lambda b: None'
)
if
f
==
g
:
raise
TestFailed
f
=
eval
(
'lambda a: None'
)
g
=
eval
(
'lambda a=None: None'
)
if
f
==
g
:
raise
TestFailed
f
=
eval
(
'lambda a=0: None'
)
g
=
eval
(
'lambda a=1: None'
)
if
f
==
g
:
raise
TestFailed
Lib/dos_8x3/test_reg.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -60,3 +60,51 @@ except regex.error:
print
'caught expected exception'
else
:
print
'expected regex.error not raised'
from
regex_tests
import
*
if
verbose
:
print
'Running regex_tests test suite'
for
t
in
tests
:
pattern
=
s
=
outcome
=
repl
=
expected
=
None
if
len
(
t
)
==
5
:
pattern
,
s
,
outcome
,
repl
,
expected
=
t
elif
len
(
t
)
==
3
:
pattern
,
s
,
outcome
=
t
else
:
raise
ValueError
,
(
'Test tuples should have 3 or 5 fields'
,
t
)
try
:
obj
=
regex
.
compile
(
pattern
)
except
regex
.
error
:
if
outcome
==
SYNTAX_ERROR
:
pass
# Expected a syntax error
else
:
# Regex syntax errors aren't yet reported, so for
# the official test suite they'll be quietly ignored.
pass
#print '=== Syntax error:', t
else
:
try
:
result
=
obj
.
search
(
s
)
except
regex
.
error
,
msg
:
print
'=== Unexpected exception'
,
t
,
repr
(
msg
)
if
outcome
==
SYNTAX_ERROR
:
# This should have been a syntax error; forget it.
pass
elif
outcome
==
FAIL
:
if
result
==-
1
:
pass
# No match, as expected
else
:
print
'=== Succeeded incorrectly'
,
t
elif
outcome
==
SUCCEED
:
if
result
!=-
1
:
# Matched, as expected, so now we compute the
# result string and compare it to our expected result.
start
,
end
=
obj
.
regs
[
0
]
found
=
s
[
start
:
end
]
groups
=
obj
.
group
(
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
)
vardict
=
vars
()
for
i
in
range
(
len
(
groups
)):
vardict
[
'g'
+
str
(
i
+
1
)]
=
str
(
groups
[
i
])
repl
=
eval
(
repl
)
if
repl
!=
expected
:
print
'=== grouping error'
,
t
,
repr
(
repl
)
+
' should be '
+
repr
(
expected
)
else
:
print
'=== Failed incorrectly'
,
t
Lib/dos_8x3/test_rot.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -7,7 +7,7 @@ A = 'spam and eggs'
B
=
'cheese shop'
a
=
r
.
encrypt
(
A
)
print
a
print
`a`
b
=
r
.
encryptmore
(
B
)
print
b
...
...
Lib/dos_8x3/test_soc.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -65,7 +65,7 @@ for optional in ("AF_UNIX",
):
missing_ok
(
optional
)
socktype
=
socket
.
socket_t
ype
socktype
=
socket
.
SocketT
ype
hostname
=
socket
.
gethostname
()
ip
=
socket
.
gethostbyname
(
hostname
)
hname
,
aliases
,
ipaddrs
=
socket
.
gethostbyaddr
(
ip
)
...
...
Lib/dos_8x3/test_thr.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -21,7 +21,7 @@ def task(ident):
delay
=
whrandom
.
random
()
*
numtasks
whmutex
.
release
()
if
verbose
:
print
'task'
,
ident
,
'will run for'
,
delay
,
'sec'
print
'task'
,
ident
,
'will run for'
,
round
(
delay
,
1
)
,
'sec'
time
.
sleep
(
delay
)
if
verbose
:
print
'task'
,
ident
,
'done'
...
...
@@ -89,7 +89,7 @@ def task2(ident):
delay
=
whrandom
.
random
()
*
numtasks
whmutex
.
release
()
if
verbose
:
print
'task'
,
ident
,
'will run for'
,
delay
,
'sec'
print
'task'
,
ident
,
'will run for'
,
round
(
delay
,
1
)
,
'sec'
time
.
sleep
(
delay
)
if
verbose
:
print
'task'
,
ident
,
'entering barrier'
,
i
...
...
Lib/dos_8x3/test_typ.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -183,9 +183,9 @@ if d <> {'a': 4, 'c': 3}: raise TestFailed, 'dict item deletion'
d
=
{
1
:
1
,
2
:
2
,
3
:
3
}
d
.
clear
()
if
d
!=
{}:
raise
TestFailed
,
'dict clear'
d
.
absorb
({
1
:
100
})
d
.
absorb
({
2
:
20
})
d
.
absorb
({
1
:
1
,
2
:
2
,
3
:
3
})
if
d
!=
{
1
:
1
,
2
:
2
,
3
:
3
}:
raise
TestFailed
,
'dict
absorb
'
d
.
update
({
1
:
100
})
d
.
update
({
2
:
20
})
d
.
update
({
1
:
1
,
2
:
2
,
3
:
3
})
if
d
!=
{
1
:
1
,
2
:
2
,
3
:
3
}:
raise
TestFailed
,
'dict
update
'
if
d
.
copy
()
!=
{
1
:
1
,
2
:
2
,
3
:
3
}:
raise
TestFailed
,
'dict copy'
if
{}
.
copy
()
!=
{}:
raise
TestFailed
,
'empty dict copy'
Lib/dos_8x3/tracebac.py
Dosyayı görüntüle @
ff712aa8
...
...
@@ -128,8 +128,11 @@ def format_exception_only(etype, value):
def
print_exc
(
limit
=
None
,
file
=
None
):
if
not
file
:
file
=
sys
.
stderr
print_exception
(
sys
.
exc_type
,
sys
.
exc_value
,
sys
.
exc_traceback
,
limit
,
file
)
try
:
etype
,
value
,
tb
=
sys
.
exc_info
()
print_exception
(
etype
,
value
,
tb
,
limit
,
file
)
finally
:
etype
=
value
=
tb
=
None
def
print_last
(
limit
=
None
,
file
=
None
):
if
not
file
:
...
...
@@ -143,8 +146,7 @@ def print_stack(f=None, limit=None, file=None):
try
:
raise
ZeroDivisionError
except
ZeroDivisionError
:
tb
=
sys
.
exc_traceback
f
=
tb
.
tb_frame
.
f_back
f
=
sys
.
exc_info
()[
2
]
.
tb_frame
.
f_back
print_list
(
extract_stack
(
f
,
limit
),
file
)
def
format_stack
(
f
=
None
,
limit
=
None
):
...
...
@@ -152,17 +154,15 @@ def format_stack(f=None, limit=None):
try
:
raise
ZeroDivisionError
except
ZeroDivisionError
:
tb
=
sys
.
exc_traceback
f
=
tb
.
tb_frame
.
f_back
return
format_list
(
extract_stack
(
t
,
limit
))
f
=
sys
.
exc_info
()[
2
]
.
tb_frame
.
f_back
return
format_list
(
extract_stack
(
f
,
limit
))
def
extract_stack
(
f
=
None
,
limit
=
None
):
if
f
is
None
:
try
:
raise
ZeroDivisionError
except
ZeroDivisionError
:
tb
=
sys
.
exc_traceback
f
=
tb
.
tb_frame
.
f_back
f
=
sys
.
exc_info
()[
2
]
.
tb_frame
.
f_back
if
limit
is
None
:
if
hasattr
(
sys
,
'tracebacklimit'
):
limit
=
sys
.
tracebacklimit
...
...
Lib/dos_8x3/userdict.py
Dosyayı görüntüle @
ff712aa8
# A more or less complete user-defined wrapper around dictionary objects
class
UserDict
:
def
__init__
(
self
):
self
.
data
=
{}
def
__repr__
(
self
):
return
repr
(
self
.
data
)
def
__cmp__
(
self
,
dict
):
if
type
(
dict
)
==
type
(
self
.
data
):
return
cmp
(
self
.
data
,
dict
)
else
:
return
cmp
(
self
.
data
,
dict
.
data
)
def
__len__
(
self
):
return
len
(
self
.
data
)
def
__getitem__
(
self
,
key
):
return
self
.
data
[
key
]
def
__setitem__
(
self
,
key
,
item
):
self
.
data
[
key
]
=
item
def
__delitem__
(
self
,
key
):
del
self
.
data
[
key
]
def
keys
(
self
):
return
self
.
data
.
keys
()
def
items
(
self
):
return
self
.
data
.
items
()
def
values
(
self
):
return
self
.
data
.
values
()
def
has_key
(
self
,
key
):
return
self
.
data
.
has_key
(
key
)
def
__init__
(
self
):
self
.
data
=
{}
def
__repr__
(
self
):
return
repr
(
self
.
data
)
def
__cmp__
(
self
,
dict
):
if
type
(
dict
)
==
type
(
self
.
data
):
return
cmp
(
self
.
data
,
dict
)
else
:
return
cmp
(
self
.
data
,
dict
.
data
)
def
__len__
(
self
):
return
len
(
self
.
data
)
def
__getitem__
(
self
,
key
):
return
self
.
data
[
key
]
def
__setitem__
(
self
,
key
,
item
):
self
.
data
[
key
]
=
item
def
__delitem__
(
self
,
key
):
del
self
.
data
[
key
]
def
clear
(
self
):
return
self
.
data
.
clear
()
def
copy
(
self
):
import
copy
return
copy
.
copy
(
self
)
def
keys
(
self
):
return
self
.
data
.
keys
()
def
items
(
self
):
return
self
.
data
.
items
()
def
values
(
self
):
return
self
.
data
.
values
()
def
has_key
(
self
,
key
):
return
self
.
data
.
has_key
(
key
)
def
update
(
self
,
other
):
if
type
(
other
)
is
type
(
self
.
data
):
self
.
data
.
update
(
other
)
else
:
for
k
,
v
in
other
.
items
():
self
.
data
[
k
]
=
v
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment