Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pypy\interpreter\astcompiler\astbuilder.py:901:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <pypy.interpreter.astcompiler.astbuilder.ASTBuilder object at 0x043b7610>
- power_node = Nonterminal(type=311, children=[Nonterminal(type=267, children=[Non
- terminal(type=266, children=[Terminal(type=3, value="u'\\U00012345'")])])])
- def handle_power(self, power_node):
- > atom_expr = self.handle_atom_expr(power_node.get_child(0))
- pypy\interpreter\astcompiler\astbuilder.py:1018:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <pypy.interpreter.astcompiler.astbuilder.ASTBuilder object at 0x043b7610>
- atom_node = Nonterminal(type=267, children=[Nonterminal(type=266, children=[Term
- inal(type=3, value="u'\\U00012345'")])])
- def handle_atom_expr(self, atom_node):
- start = 0
- num_ch = atom_node.num_children()
- if atom_node.get_child(0).type == tokens.AWAIT:
- start = 1
- > atom_expr = self.handle_atom(atom_node.get_child(start))
- pypy\interpreter\astcompiler\astbuilder.py:997:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <pypy.interpreter.astcompiler.astbuilder.ASTBuilder object at 0x043b7610>
- atom_node = Nonterminal(type=266, children=[Terminal(type=3, value="u'\\U0001234
- 5'")])
- def handle_atom(self, atom_node):
- first_child = atom_node.get_child(0)
- first_child_type = first_child.type
- if first_child_type == tokens.NAME:
- name = first_child.get_value()
- if name == "None":
- w_singleton = self.space.w_None
- elif name == "True":
- w_singleton = self.space.w_True
- elif name == "False":
- w_singleton = self.space.w_False
- else:
- name = self.new_identifier(name)
- return ast.Name(name, ast.Load, first_child.get_lineno(),
- first_child.get_column())
- return ast.NameConstant(w_singleton, first_child.get_lineno(),
- first_child.get_column())
- #
- elif first_child_type == tokens.STRING:
- > return fstring.string_parse_literal(self, atom_node)
- pypy\interpreter\astcompiler\astbuilder.py:1254:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- astbuilder = <pypy.interpreter.astcompiler.astbuilder.ASTBuilder object at 0x043
- b7610>
- atom_node = Nonterminal(type=266, children=[Terminal(type=3, value="u'\\U0001234
- 5'")])
- def string_parse_literal(astbuilder, atom_node):
- space = astbuilder.space
- encoding = astbuilder.compile_info.encoding
- joined_pieces = []
- fmode = False
- for i in range(atom_node.num_children()):
- child = atom_node.get_child(i)
- try:
- w_next = parsestring.parsestr(
- > space, encoding, child.get_value())
- pypy\interpreter\astcompiler\fstring.py:348:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- space = StdObjSpace, encoding = 'utf-8', s = "u'\\U00012345'"
- def parsestr(space, encoding, s):
- """Parses a string or unicode literal, and return usually
- a wrapped value. If we get an f-string, then instead return
- an unparsed but unquoted W_FString instance.
- If encoding=None, the source string is ascii only.
- In other cases, the source string is in utf-8 encoding.
- When a bytes string is returned, it will be encoded with the
- original encoding.
- Yes, it's very inefficient.
- Yes, CPython has very similar code.
- """
- # we use ps as "pointer to s"
- # q is the virtual last char index of the string
- ps = 0
- quote = s[ps]
- rawmode = False
- unicode_literal = True
- saw_u = False
- saw_f = False
- # string decoration handling
- if quote == 'b' or quote == 'B':
- ps += 1
- quote = s[ps]
- unicode_literal = False
- elif quote == 'u' or quote == 'U':
- ps += 1
- quote = s[ps]
- saw_u = True
- elif quote == 'r' or quote == 'R':
- ps += 1
- quote = s[ps]
- rawmode = True
- elif quote == 'f' or quote == 'F':
- ps += 1
- quote = s[ps]
- saw_f = True
- if not saw_u:
- if quote == 'r' or quote == 'R':
- ps += 1
- quote = s[ps]
- rawmode = True
- elif quote == 'b' or quote == 'B':
- ps += 1
- quote = s[ps]
- unicode_literal = False
- elif quote == 'f' or quote == 'F':
- ps += 1
- quote = s[ps]
- saw_f = True
- if quote != "'" and quote != '"':
- raise_app_valueerror(space,
- 'Internal error: parser passed unquoted literal
- ')
- ps += 1
- q = len(s) - 1
- if s[q] != quote:
- raise_app_valueerror(space, 'Internal error: parser passed unmatched
- '
- 'quotes in literal')
- if q-ps >= 4 and s[ps] == quote and s[ps+1] == quote:
- # triple quotes
- ps += 2
- if s[q-1] != quote or s[q-2] != quote:
- raise_app_valueerror(space, 'Internal error: parser passed '
- 'unmatched triple quotes in literal'
- )
- q -= 2
- if unicode_literal and not rawmode: # XXX Py_UnicodeFlag is ignored for
- now
- assert 0 <= ps <= q
- if saw_f:
- return W_FString(s[ps:q], rawmode)
- if encoding is None:
- substr = s[ps:q]
- else:
- unicodehelper.check_utf8_or_raise(space, s, ps, q)
- substr = decode_unicode_utf8(space, s, ps, q)
- r = unicodehelper.decode_unicode_escape(space, substr)
- v, length, pos = r
- > return space.newutf8(v, length)
- pypy\interpreter\pyparser\parsestring.py:99:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = StdObjSpace, utf8s = '\xf0\x92\x8d\x85', length = 1
- def newutf8(self, utf8s, length):
- assert isinstance(utf8s, str)
- > return W_UnicodeObject(utf8s, length)
- pypy\objspace\std\objspace.py:405:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = W_UnicodeObject('\xf0\x92\x8d\x85'), utf8str = '\xf0\x92\x8d\x85'
- length = 1
- def __init__(self, utf8str, length):
- if not we_are_translated():
- typecheck(self, utf8str, length) # rpython.rlib.objectmodel
- > return __init___original(self, utf8str, length)
- <677-codegen C:\pypy\rpython\tool\sourcetools.py:292>:5:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = W_UnicodeObject('\xf0\x92\x8d\x85'), utf8str = '\xf0\x92\x8d\x85'
- length = 1
- @enforceargs(utf8str=str)
- def __init__(self, utf8str, length):
- assert isinstance(utf8str, bytes)
- # TODO: how to handle surrogates
- assert length >= 0
- self._utf8 = utf8str
- self._length = length
- self._index_storage = rutf8.null_storage()
- if not we_are_translated():
- try:
- # best effort, too expensive to handle surrogates
- ulength = len(utf8str.decode('utf8'))
- except:
- ulength = length
- > assert ulength == length
- E assert 2 == 1
- pypy\objspace\std\unicodeobject.py:47: AssertionError
- ========================== short test summary info ===========================
- FAIL pypy/module/_cffi_backend/test/test_ffi_obj.py::AppTestFFIObj::()::test_cha
- r32_t
- ==================== 1 failed, 45 passed in 77.59 seconds ====================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement