Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iolib: fix different behavior in read function #456

Merged
merged 1 commit into from
Dec 12, 2023

Conversation

0x501D
Copy link
Contributor

@0x501D 0x501D commented Sep 28, 2023

$ lua
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio

file = "/tmp"
fd, _, code = io.open(file, "r")
_, _, ecode = fd:read(1)
print(ecode)
21

gopher-lua throws an exception:
read /tmp: is a directory
stack traceback:
[G]: in function 'read'
extra/wrapper.lua:17: in function 'exec'
:1: in main chunk
[G]: ?

This patch results in behavior similar to the vanilla lua implementation.

Closes #455

@coveralls
Copy link

coveralls commented Sep 28, 2023

Coverage Status

coverage: 89.623% (+0.06%) from 89.566%
when pulling 5b5b27f on 0x501D:gh-455-fix-read
into da9f439 on yuin:master.

@0x501D 0x501D force-pushed the gh-455-fix-read branch 2 times, most recently from 8d78ab6 to f90ee64 Compare September 28, 2023 13:54
$ lua
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> file = "/tmp"
> fd, _, code = io.open(file, "r")
> _, _, ecode = fd:read(1)
> print(ecode)
21
>

gopher-lua throws an exception:
        read /tmp: is a directory
stack traceback:
        [G]: in function 'read'
        extra/wrapper.lua:17: in function 'exec'
        <string>:1: in main chunk
        [G]: ?

This patch results in behavior similar to the vanilla lua
implementation.

Closes yuin#455
@yuin yuin merged commit 2348fd0 into yuin:master Dec 12, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

different behavior in read function
3 participants