Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fa004ad

Browse files
committed
Show '\011', '\012', and '\015' as '\t', '\n', '\r' in strings.
Switch from octal escapes to hex escapes for other nonprintable characters.
1 parent 726b78e commit fa004ad

13 files changed

Lines changed: 221 additions & 205 deletions

File tree

Doc/lib/liblinecache.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ \section{\module{linecache} ---
4141
\begin{verbatim}
4242
>>> import linecache
4343
>>> linecache.getline('/etc/passwd', 4)
44-
'sys:x:3:3:sys:/dev:/bin/sh\012'
44+
'sys:x:3:3:sys:/dev:/bin/sh\n'
4545
\end{verbatim}

Doc/lib/liblocale.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ \section{\module{locale} ---
265265
>>> import locale
266266
>>> loc = locale.setlocale(locale.LC_ALL) # get current locale
267267
>>> locale.setlocale(locale.LC_ALL, 'de') # use German locale
268-
>>> locale.strcoll('f\344n', 'foo') # compare a string containing an umlaut
268+
>>> locale.strcoll('f\xe4n', 'foo') # compare a string containing an umlaut
269269
>>> locale.setlocale(locale.LC_ALL, '') # use user's preferred locale
270270
>>> locale.setlocale(locale.LC_ALL, 'C') # use default (C) locale
271271
>>> locale.setlocale(locale.LC_ALL, loc) # restore saved locale

Doc/lib/libmd5.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ \section{\module{md5} ---
2525
>>> m.update("Nobody inspects")
2626
>>> m.update(" the spammish repetition")
2727
>>> m.digest()
28-
'\273d\234\203\335\036\245\311\331\336\311\241\215\360\377\351'
28+
'\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9'
2929
\end{verbatim}
3030

3131
More condensed:
3232

3333
\begin{verbatim}
3434
>>> md5.new("Nobody inspects the spammish repetition").digest()
35-
'\273d\234\203\335\036\245\311\331\336\311\241\215\360\377\351'
35+
'\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9'
3636
\end{verbatim}
3737

3838
\begin{funcdesc}{new}{\optional{arg}}

Doc/lib/libparser.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ \subsubsection{Information Discovery}
432432
(297,
433433
(298,
434434
(299,
435-
(300, (3, '"""Some documentation.\012"""'))))))))))))))))),
435+
(300, (3, '"""Some documentation.\n"""'))))))))))))))))),
436436
(4, ''))),
437437
(4, ''),
438438
(0, ''))
@@ -537,7 +537,7 @@ \subsubsection{Information Discovery}
537537
>>> found
538538
1
539539
>>> vars
540-
{'docstring': '"""Some documentation.\012"""'}
540+
{'docstring': '"""Some documentation.\n"""'}
541541
\end{verbatim}
542542

543543
Once specific data can be extracted from a location where it is

Doc/lib/libpyexpat.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,11 @@ \subsection{Example \label{expat-example}}
272272
Start element: child1 {'name': 'paul'}
273273
Character data: 'Text goes here'
274274
End element: child1
275-
Character data: '\012'
275+
Character data: '\n'
276276
Start element: child2 {'name': 'fred'}
277277
Character data: 'More text'
278278
End element: child2
279-
Character data: '\012'
279+
Character data: '\n'
280280
End element: parent
281281
\end{verbatim}
282282

Doc/lib/librotor.tex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ \section{\module{rotor} ---
6868
>>> import rotor
6969
>>> rt = rotor.newrotor('key', 12)
7070
>>> rt.encrypt('bar')
71-
'\2534\363'
71+
'\xab4\xf3'
7272
>>> rt.encryptmore('bar')
73-
'\357\375$'
73+
'\xef\xfd$'
7474
>>> rt.encrypt('bar')
75-
'\2534\363'
76-
>>> rt.decrypt('\2534\363')
75+
'\xab4\xf3'
76+
>>> rt.decrypt('\xab4\xf3')
7777
'bar'
78-
>>> rt.decryptmore('\357\375$')
78+
>>> rt.decryptmore('\xef\xfd$')
7979
'bar'
80-
>>> rt.decrypt('\357\375$')
81-
'l(\315'
80+
>>> rt.decrypt('\xef\xfd$')
81+
'l(\xcd'
8282
>>> del rt
8383
\end{verbatim}
8484

Doc/lib/libstruct.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ \section{\module{struct} ---
168168
\begin{verbatim}
169169
>>> from struct import *
170170
>>> pack('hhl', 1, 2, 3)
171-
'\000\001\000\002\000\000\000\003'
172-
>>> unpack('hhl', '\000\001\000\002\000\000\000\003')
171+
'\x00\x01\x00\x02\x00\x00\x00\x03'
172+
>>> unpack('hhl', '\x00\x01\x00\x02\x00\x00\x00\x03')
173173
(1, 2, 3)
174174
>>> calcsize('hhl')
175175
8

Doc/tut/tut.tex

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -801,39 +801,31 @@ \subsection{Unicode Strings \label{unicodeStrings}}
801801
other ways of creating Unicode strings on the basis of a known
802802
encoding.
803803

804-
The builtin \function{unicode()}\bifuncindex{unicode} provides access
804+
The built-in function \function{unicode()}\bifuncindex{unicode} provides access
805805
to all registered Unicode codecs (COders and DECoders). Some of the
806806
more well known encodings which these codecs can convert are
807807
\emph{Latin-1}, \emph{ASCII}, \emph{UTF-8} and \emph{UTF-16}. The latter two
808-
are variable length encodings which permit to store Unicode characters
809-
in 8 or 16 bits. Python uses UTF-8 as default encoding. This becomes
810-
noticeable when printing Unicode strings or writing them to files.
808+
are variable-length encodings which store Unicode characters
809+
in blocks of 8 or 16 bits. To print a Unicode string or write it to a file,
810+
you must convert it to a string with the \method{encode()} method.
811811

812812
\begin{verbatim}
813813
>>> u"äöü"
814814
u'\344\366\374'
815-
>>> str(u"äöü")
815+
>>> u"äöü".encode('UTF-8')
816816
'\303\244\303\266\303\274'
817817
\end{verbatim}
818818

819819
If you have data in a specific encoding and want to produce a
820820
corresponding Unicode string from it, you can use the
821-
\function{unicode()} builtin with the encoding name as second
821+
\function{unicode()} function with the encoding name as second
822822
argument.
823823

824824
\begin{verbatim}
825825
>>> unicode('\303\244\303\266\303\274','UTF-8')
826826
u'\344\366\374'
827827
\end{verbatim}
828828

829-
To convert the Unicode string back into a string using the original
830-
encoding, the objects provide an \method{encode()} method.
831-
832-
\begin{verbatim}
833-
>>> u"äöü".encode('UTF-8')
834-
'\303\244\303\266\303\274'
835-
\end{verbatim}
836-
837829

838830
\subsection{Lists \label{lists}}
839831

Lib/test/output/test_cfgparser

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ Value interpolation too deeply recursive:
2424

2525
Testing for parsing errors...
2626
Caught expected exception: File contains parsing errors: <???>
27-
[line 2]: ' extra-spaces: splat\012'
27+
[line 2]: ' extra-spaces: splat\n'
2828
Caught expected exception: File contains parsing errors: <???>
29-
[line 2]: ' extra-spaces= splat\012'
29+
[line 2]: ' extra-spaces= splat\n'
3030
Caught expected exception: File contains parsing errors: <???>
31-
[line 2]: 'option-without-value\012'
31+
[line 2]: 'option-without-value\n'
3232
Caught expected exception: File contains parsing errors: <???>
33-
[line 2]: ':value-without-option-name\012'
33+
[line 2]: ':value-without-option-name\n'
3434
Caught expected exception: File contains parsing errors: <???>
35-
[line 2]: '=value-without-option-name\012'
35+
[line 2]: '=value-without-option-name\n'
3636
Caught expected exception: File contains no section headers.
3737
file: <???>, line: 1
38-
'No Section!\012'
38+
'No Section!\n'
3939

4040
Testing query interface...
4141
[]

Lib/test/output/test_cookie

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Set-Cookie: chips=ahoy;
66
Set-Cookie: vienna=finger;
77
chips 'ahoy' 'ahoy'
88
Set-Cookie: chips=ahoy;
9-
<SimpleCookie: keebler='E=mc2; L="Loves"; fudge=\012;'>
9+
<SimpleCookie: keebler='E=mc2; L="Loves"; fudge=\n;'>
1010
Set-Cookie: keebler="E=mc2; L=\"Loves\"; fudge=\012;";
11-
keebler 'E=mc2; L="Loves"; fudge=\012;' 'E=mc2; L="Loves"; fudge=\012;'
11+
keebler 'E=mc2; L="Loves"; fudge=\n;' 'E=mc2; L="Loves"; fudge=\n;'
1212
Set-Cookie: keebler="E=mc2; L=\"Loves\"; fudge=\012;";
1313
Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme;
1414

0 commit comments

Comments
 (0)