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

Call to open('filename.txt') with a single parameter fails #33

Closed
csev opened this issue Jan 23, 2013 · 7 comments
Closed

Call to open('filename.txt') with a single parameter fails #33

csev opened this issue Jan 23, 2013 · 7 comments

Comments

@csev
Copy link
Contributor

csev commented Jan 23, 2013

If you do not provide 'r' as the second parameter on an open, Skulpt will fail with a

todo; haven't implemented non-read opens

But the open should be a read open. The problem is that the line in src/builtins.py that would solve this:

if (mode === undefined) mode = "r";

Is wrong and should be:

if (mode === undefined) mode = new Sk.builtin.str("r");

I have fixed this in the old repo here

http://code.google.com/r/drchuck-skulpt-mods/source/detail?r=85c1f4b4a8757c6f5c4b8ba190311b3dbc9b701e

I will fork this repo, make the fix, and submit a pull request.

This is the first of a number of small fixes that I have already done in the Google Code repo that I will be bringing across to the Github repo. Comments welcome.

@bnmnetp
Copy link
Contributor

bnmnetp commented Jan 23, 2013

Thanks!
Sorry for your duplicated effort. I don't really think about the google code repo as we've been doing development here on github for quite some time. I did create a README and add it to the google code repo redirecting traffic here.

@csev
Copy link
Contributor Author

csev commented Jan 23, 2013

I could not find anything in the checked out repo - I was suggesting a readme in the actual code tree.

No big deal on the duplicate effort. It may be just as well - I did all my learning on the Google code repo so I should be better prepared here. And I waayyy prefer git and github so I applaud the move and am glad to come here and find real activity.

@bnmnetp
Copy link
Contributor

bnmnetp commented Jan 23, 2013

That could be because I just created and pushed the README this morning.

Brad

Brad Miller
http://reputablejournal.com

On Jan 23, 2013, at 12:35 PM, Charles Severance notifications@github.com wrote:

I could not find anything in the checked out repo - I was suggesting a readme in the actual code tree.

No big deal on the duplicate effort. It may be just as well - I did all my learning on the Google code repo so I should be better prepared here. And I waayyy prefer git and github so I applaud the move and am glad to come here and find real activity.


Reply to this email directly or view it on GitHub.

@csev
Copy link
Contributor Author

csev commented Jan 23, 2013

Love it! Now I can go back to fixing open() :)

@csev
Copy link
Contributor Author

csev commented Jan 23, 2013

This is Issue 118 on Google Code.

csev added a commit to csev/skulpt that referenced this issue Jan 23, 2013
Make open('filename') without the second parameter work.

There is no unit test because I don't know how to set it up.  The way I
test this in a browser is without this change, the following code:

h = open("mbox-short.txt")
print len(h.read())

Throws "todo; haven't implemented non-read opens"

With this fix the code works.
@csev
Copy link
Contributor Author

csev commented Jan 24, 2013

This is fixed in

https://github.com/bnmnetp/skulpt/pull/39

@bnmnetp bnmnetp closed this as completed Jan 24, 2013
@venkatvkv
Copy link

Hi Charles,
I am one your students attending The Python class.
I tried doing the Assignment 7.1 online on pr4e.dr-chuck.com.

Use words.txt as the file name

fname = raw_input("Enter file name: ")
fh = open(fname,'r')
fout = open('words.txt','w')

for line in fh:
temp = line.upper()
fout.write(temp)
fout.close()
I tried fopen with and without 'r', but the error "todo; haven't implemented non-read opens" is still present.
if you have few mins, plz let me know that am I doing something wrong in opening the file ?
Thanks
Venkat

albertjan pushed a commit to albertjan/skulpt that referenced this issue Jun 27, 2017
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

No branches or pull requests

3 participants