megamanfx / grit-i18n

Automatically exported from code.google.com/p/grit-i18n
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

codecs.open with encoding seems unstable #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
On at least one version of Python (2.6.4 on Windows), when running [grit build] 
on files that contain Unicode characters, I get errors like the stack trace 
below.  Switching to a regular file open and util.WrapOutputStream seems to fix 
the issue.

Traceback (most recent call last):
  File "D:\src\tb/googleclient/tools/new_grit.py", line 56, in <module>
    grit.grit_runner.Main(['-h', 'transconsole.base.FP'] + args)
  File "D:\src\tb/googleclient/tools\..\..\google3\third_party\py\grit\grit_runner.py", line 274, in Main
    toolobject.Run(options, args[1:])
  File "D:\src\tb/googleclient/tools\..\..\google3\third_party\py\grit\tool\build.py", line 110, in Run
    self.Process()
  File "D:\src\tb/googleclient/tools\..\..\google3\third_party\py\grit\tool\build.py", line 255, in Process
    self.ProcessNode(self.res, output, outfile)
  File "D:\src\tb/googleclient/tools\..\..\google3\third_party\py\grit\tool\build.py", line 181, in ProcessNode
    RcBuilder.ProcessNode(child, output_node, outfile)
  File "D:\src\tb/googleclient/tools\..\..\google3\third_party\py\grit\tool\build.py", line 181, in ProcessNode
    RcBuilder.ProcessNode(child, output_node, outfile)
  File "D:\src\tb/googleclient/tools\..\..\google3\third_party\py\grit\tool\build.py", line 181, in ProcessNode
    RcBuilder.ProcessNode(child, output_node, outfile)
  File "D:\src\tb/googleclient/tools\..\..\google3\third_party\py\grit\tool\build.py", line 173, in ProcessNode
    output_dir=base_dir)
  File "D:\src\tb/googleclient/tools\..\..\google3\third_party\py\grit\format\rc.py", line 432, in Format
    filename = os.path.abspath(item.FileForLanguage(lang, output_dir))
  File "D:\src\tb/googleclient/tools\..\..\google3\third_party\py\grit\node\structure.py", line 301, in FileForLanguage
    file_object.write(file_contents)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xbb' in position 
10833: ordinal not in range(128)

Original issue reported on code.google.com by joi@chromium.org on 24 Jul 2012 at 3:57

GoogleCodeExporter commented 9 years ago
Fixed in r60.

Original comment by joi@chromium.org on 24 Jul 2012 at 4:51