This commit is contained in:
K. Lange 2021-01-18 20:45:07 +09:00
parent abfaa50bee
commit 7c230c3d12
3 changed files with 5 additions and 4 deletions

View File

@ -309,7 +309,7 @@ Default arguments can be specified as follows:
def greet(name="world"):
print("Hello, " + name + "!")
greet()
gree("user")
greet("user")
# → Hello, world!
# Hello, user!
```
@ -882,7 +882,7 @@ As in the _Loops_ section above, an iterator may return a series of tuples which
```py
class TupleGenerator:
def __iter__():
let up = 0, down = 0, limit = 5
let up, down, limit = 0, 0, 5
def _():
if limit-- == 0: return _
return (up++,down--)

View File

@ -2409,6 +2409,7 @@ KrkFunction * krk_compile(const char * src, int newScope, char * fileName) {
string(parser.previous.type == TOKEN_BIG_STRING);
krk_attachNamedObject(&vm.module->fields, "__doc__",
(KrkObj*)AS_STRING(currentChunk()->constants.values[currentChunk()->constants.count-1]));
emitByte(OP_POP); /* string() actually put an instruction for that, pop its result */
consume(TOKEN_EOL,"Garbage after docstring");
} else {
krk_attachNamedValue(&vm.module->fields, "__doc__", NONE_VAL());

4
vm.c
View File

@ -2053,8 +2053,8 @@ static int charIn(char c, const char * str) {
*/
static KrkValue _string_strip_shared(int argc, KrkValue argv[], int which) {
if (!IS_STRING(argv[0])) return NONE_VAL();
if (AS_STRING(argv[0])->type != KRK_STRING_ASCII) {
krk_runtimeError(vm.exceptions.notImplementedError, "str.strip() not implemented for Unicode strings");
if (argc > 1 && IS_STRING(argv[1]) && AS_STRING(argv[1])->type != KRK_STRING_ASCII) {
krk_runtimeError(vm.exceptions.notImplementedError, "str.strip() not implemented for Unicode strip lists");
return NONE_VAL();
}
size_t start = 0;