Age | Commit message (Collapse) | Author |
|
THIS IS AN INCOMPATIBLE LANGUAGE CHANGE; see below
This change defines a 'bytes' data type, an immutable string of
bytes. In this Go implementation of Starlark, ordinary strings
are also strings of bytes, so the behavior of the two is very similar.
However, that is not required by the spec. Other implementations of
Starlark, notably in Java, may use strings of UTF-16 codes for the
ordinary string type, and thus need a distinct type for byte strings.
See testdata/bytes.star for a tour of the API, and some remaining
questions. See the attached issue for an outline of the proposed
spec change. A Java implementation is underway, but is greatly
complicated by Bazel's unfortunate misdecoding of UTF-8 files as
Latin1.
The string.elems iterable view is now indexable.
The old syntax.quote function (which was in fact not used
except in tests) has been replaced by syntax.Quote,
which is similar to Go's strconv.Quote.
This change removes go.starlark.net.lib.proto.Bytes.
IMPORTANT: string literals that previously used hex escapes
\xXX or octal escapes \OOO to denote byte values greater than 127
will now result in a compile error advising you to use \u
escapes instead if you want the UTF-8 encoding of a code point
in the range U+80 to U+FF. A string literal can no longer
denote invalid text, such as the 1-element string formerly
written "\xff".
Updates https://github.com/bazelbuild/starlark/issues/112
Fixes https://github.com/google/starlark-go/issues/222
|
|
Clarify spec on this issue.
Fixes https://github.com/google/starlark-go/issues/278
Also, fix semantic merge conflict in testdata/json.star tests that
relied on "\u" being interpreted as "\\u", causing tests to fail.
|
|
This change causes Starlark, like Go, to reject backslashes that
are not part of an escape sequence. Previously they were treated
literally, so \ ( would encode a two-character string.
Many programs rely on this, especially for regular expressions and
shell commands, and will be broken by this change, but the fix is simple:
double each errant backslash.
Python does not yet enforce this behavior, but since 3.6
has emitted a deprecation warning for it.
Also, document string escapes.
Related issues:
- Google issue b/34519173: "bazel: Forbid undefined escape sequences in strings"
- bazelbuild/starlark#38: Starlark spec: String escapes
- bazelbuild/buildtools#688: Bazel: Fix string escapes
- bazelbuild/bazel#8380: Bazel incompatible_restrict_string_escapes: Restrict string escapes
|
|
Fixes #95
|
|
Fixes #85
|
|
Change-Id: Iebd0e040ff674b2f9da39bf5242c8afaa7f4ddc8
|
|
|