Skip to content

Commit f449c59

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "hacking: Remove references to encoding"
2 parents 03e58a4 + f00e14f commit f449c59

1 file changed

Lines changed: 1 addition & 47 deletions

File tree

HACKING.rst

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -32,57 +32,11 @@ use the alternate 4 space indent. With the first argument on the succeeding
3232
line all arguments will then be vertically aligned. Use the same convention
3333
used with other data structure literals and terminate the method call with
3434
the last argument line ending with a comma and the closing paren on its own
35-
line indented to the starting line level.
35+
line indented to the starting line level. ::
3636

3737
unnecessarily_long_function_name(
3838
'string one',
3939
'string two',
4040
kwarg1=constants.ACTIVE,
4141
kwarg2=['a', 'b', 'c'],
4242
)
43-
44-
Text encoding
45-
-------------
46-
47-
Note: this section clearly has not been implemented in this project yet, it is
48-
the intention to do so.
49-
50-
All text within python code should be of type 'unicode'.
51-
52-
WRONG:
53-
54-
>>> s = 'foo'
55-
>>> s
56-
'foo'
57-
>>> type(s)
58-
<type 'str'>
59-
60-
RIGHT:
61-
62-
>>> u = u'foo'
63-
>>> u
64-
u'foo'
65-
>>> type(u)
66-
<type 'unicode'>
67-
68-
Transitions between internal unicode and external strings should always
69-
be immediately and explicitly encoded or decoded.
70-
71-
All external text that is not explicitly encoded (database storage,
72-
commandline arguments, etc.) should be presumed to be encoded as utf-8.
73-
74-
WRONG:
75-
76-
infile = open('testfile', 'r')
77-
mystring = infile.readline()
78-
myreturnstring = do_some_magic_with(mystring)
79-
outfile.write(myreturnstring)
80-
81-
RIGHT:
82-
83-
infile = open('testfile', 'r')
84-
mystring = infile.readline()
85-
mytext = mystring.decode('utf-8')
86-
returntext = do_some_magic_with(mytext)
87-
returnstring = returntext.encode('utf-8')
88-
outfile.write(returnstring)

0 commit comments

Comments
 (0)