Commit 0c6fdf06 authored by Stefan Behnel's avatar Stefan Behnel

avoid useless lookup of unknown encoding (fixes compiler crash)

--HG--
extra : transplant_source : %D5%D9Izb%7F%E6%AF%91%9A2j%25%FC%27%85%7CFs5
parent 4189b42b
...@@ -2668,7 +2668,7 @@ class OptimizeBuiltinCalls(Visitor.MethodDispatcherTransform): ...@@ -2668,7 +2668,7 @@ class OptimizeBuiltinCalls(Visitor.MethodDispatcherTransform):
return node return node
encoding, encoding_node, error_handling, error_handling_node = parameters encoding, encoding_node, error_handling, error_handling_node = parameters
if isinstance(string_node, ExprNodes.UnicodeNode): if encoding and isinstance(string_node, ExprNodes.UnicodeNode):
# constant, so try to do the encoding at compile time # constant, so try to do the encoding at compile time
try: try:
value = string_node.value.encode(encoding, error_handling) value = string_node.value.encode(encoding, error_handling)
...@@ -2681,7 +2681,7 @@ class OptimizeBuiltinCalls(Visitor.MethodDispatcherTransform): ...@@ -2681,7 +2681,7 @@ class OptimizeBuiltinCalls(Visitor.MethodDispatcherTransform):
return ExprNodes.BytesNode( return ExprNodes.BytesNode(
string_node.pos, value=value, type=Builtin.bytes_type) string_node.pos, value=value, type=Builtin.bytes_type)
if error_handling == 'strict': if encoding and error_handling == 'strict':
# try to find a specific encoder function # try to find a specific encoder function
codec_name = self._find_special_codec_name(encoding) codec_name = self._find_special_codec_name(encoding)
if codec_name is not None: if codec_name is not None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment