Conversation
raff
left a comment
There was a problem hiding this comment.
Looks pretty good to me, but I would clean it up and make it more idomatic (I have added some notes).
Also, if possible the errors should be as close as possible to the error reported by CPython (I think the types are correct but the messages are different, unless you did it right but the messages have changed between Python 3.4 and Python 3.9, that is what I tried).
|
Hi,
Thanks! |
|
Thanks for the updates. Regarding stdin, see how I did it for the "print" builtin: Maybe it would be worth extracting a method that can be used to print to stdout, or you can |
|
Regarding the error messages as far as I know there isn't an easy way to get the messages from CPython, the best way may be to write a test that you can run through both Cpython and gpython and compare (I think that's what the pytest stuff is supposed to do, with the files in the "tests" folder for each module. |
|
Hi, Thanks |
Codecov Report
@@ Coverage Diff @@
## master #169 +/- ##
==========================================
- Coverage 73.71% 72.64% -1.08%
==========================================
Files 73 73
Lines 11982 11920 -62
==========================================
- Hits 8833 8659 -174
- Misses 2545 2672 +127
+ Partials 604 589 -15
Continue to review full report at Codecov.
|
sbinet
left a comment
There was a problem hiding this comment.
hi,
thanks for the PR.
please find below a first run of comments and suggestions.
(I'll try to come back at it in the coming days, but I am a bit under the weather this days...)
|
Hi @sbinet, Thanks for your review. I have resolved all of them, but the last one, specifically this one,
I think that for simplicity for calling it in embedded module functions, it is very simple to pass the Any other things I need to implement? And when will this PR be ready to merge? It is getting quite long... 54 commits. Also, after i'm done with this, what other task can I take up? Im looking to contribute more. Thanks! |
py/util.go
Outdated
| if strings.Contains(v, "\n") { | ||
| _, err = Call(write, Tuple{String(v)}, nil) // do not write a space | ||
| if err != nil { | ||
| return 1, err | ||
| } | ||
| } else { | ||
| _, err = Call(write, Tuple{String(v + " ")}, nil) | ||
| if err != nil { | ||
| return 1, err | ||
| } | ||
| } |
There was a problem hiding this comment.
actually, this whole loop could be re-written as:
line := strings.Join(args, " ") + "\n"
_, err := Call(write, Tuple{String(line)}, nil)?
I must admit I don't completely understand the strings.Contains(v, "\n") dance above :}
|
Hello, Thanks for your review. I have resolved all but the last one, specifically:
About this:
It is because if we add a space between each argument, and if the argument has a newline, the newline will start with a space. An example would be: # CPython
>>> print("hello\n","second line")
# output
hello
second lineYou would see that the # ...
hello
second line # the line will start with a space.Thanks! |
|
ok. with which OS/CPython-version are you seeing this behaviour? |
|
Hello, |
|
Although I do see that in every other enviroment it works like you said, so i suggest we just implement |
|
@sbinet Thanks for your ping, I resolved the merge conflict. |
sbinet
left a comment
There was a problem hiding this comment.
LGTM.
could you send yet another PR against the go-python/license, adding yourself to the AUTHORS and/or CONTRIBUTORS files?
then I'll merge this PR in.
thanks a lot for sticking with us.
|
(don't worry about the merge conflicts. I'll handle them) |
|
Love it! Awesome work, gents! |
Signed-off-by: Sebastien Binet <binet@cern.ch>
|
ping? |
|
pong? |
|
needs go-python/license#18 |
author glaukiol1 <glaukiol1@gmail.com> committer Sebastien Binet <binet@cern.ch>
|
done :) |
OS Module
I added some of the basic functions/globals of the OS module, these include;
I also added a
py.Printlnfunction, in which you can find the definition for inpy/utils.py. It looks something like thisThis is my first contribution to gpython, so please give me feedback and other things I should add.
The first two commits were tests i made to figure out how to create a module; I was going to make a JSON module, but then I saw that gpython didnt have an OS module, and I thought that was more important than a JSON module at this time.
I've also included
os.test.py, a file which you can run with gpython to check if the OS module is working properly.Thanks!