python3.4 + ubuntu14.04 LTS + gummworld2= OSError: [Errno 29] Illegal seek

6 views
Skip to first unread message

Jay Hopping

unread,
Jan 29, 2016, 4:00:02 PM1/29/16
to Gummworld2
As stated in the subject, I am running linux with python3.4 and all of the examples are failing with the following error:

Traceback (most recent call last):
  File "30_renderer_dirty.py", line 41, in <module>
    import gummworld2
  File "../gamelib/gummworld2/__init__.py", line 42, in <module>
    sys.stdout = os.fdopen(sys.stdout.fileno(), 'a', buf_arg)
  File "/usr/lib/python3.4/os.py", line 980, in fdopen
    return io.open(fd, *args, **kwargs)
OSError: [Errno 29] Illegal seek


Gummworld2 was downloaded yesterday on 1/27.  Filename:  gummbum-gummworld2-9c672c159962.zip

I started learning python (and tcl) last summer and just recently started learning pygame primarily using the books at inventwithpython.com.  So...  despite my time on google, I wasn't able to figure out what is wrong.  I'm hoping someone here does though I believe you are developing on windows.  at least I think I saw a post somewhere.  Anyway, here's the code from __init__.py for your convenience:


import os
import sys

# Unbuffered IO for Python 2.6, 2.7, and 3.x
buf_arg
= 0
if sys.version_info[0] == 3:
    buf_arg
= 1
    os
.environ['PYTHONUNBUFFERED'] = '1'
sys
.stdout.flush()
sys
.stderr.flush()
sys
.stdout = os.fdopen(sys.stdout.fileno(), 'a', buf_arg)
sys
.stderr = os.fdopen(sys.stderr.fileno(), 'a', buf_arg)

I've tried tweaking the code but no luck.   I was able to comment the entire section out and run the examples.

btw:  if I'm understanding it correctly, you are turning of the stream buffering for the stdout and stderr streams.  Why?


Thank you,
Jay



B W

unread,
Jan 29, 2016, 5:39:13 PM1/29/16
to Gummworld2
Hi, Jay,

It is not gummworld2 that is raising this exception, it is a line in the Python os module.


Traceback (most recent call last):
  File "30_renderer_dirty.py", line 41, in <module>
    import gummworld2
  File "../gamelib/gummworld2/__init__.py", line 42, in <module>
    sys.stdout = os.fdopen(sys.stdout.fileno(), 'a', buf_arg)
  File "/usr/lib/python3.4/os.py", line 980, in fdopen
    return io.open(fd, *args, **kwargs)

OSError: [Errno 29] Illegal seek

I am not sure why this is happening in Linux. It may be a bug in Python.

The good news is you can work around it easily.

Just edit gamelib/gummworld2/__init__.py and comment these lines near the top of the file:


buf_arg = 0
if sys.version_info[0] == 3:
    buf_arg = 1
    os.environ['PYTHONUNBUFFERED'] = '1'
sys.stdout.flush()
sys.stderr.flush()
sys.stdout = os.fdopen(sys.stdout.fileno(), 'a', buf_arg)
sys.stderr = os.fdopen(sys.stderr.fileno(), 'a', buf_arg)

You can also wrap this code in a "try: except: pass" block to handle the error and continue on.

The only thing these lines do is turn off buffering for stdout and stderr, so that e.g. print() statements flush after every line.

I will put this section of code in an exception handler, and generate a new release. I can't say when I will get around to this, so I encourage you to use the workaround in the meantime.

Gumm


--
You received this message because you are subscribed to the Google Groups "Gummworld2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gummworld2+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jay Hopping

unread,
Jan 29, 2016, 11:04:45 PM1/29/16
to Gummworld2
Ok, Thanks.  Thats just what I had done to work through the examples.  Thank you for the quick reply.
Jay
Reply all
Reply to author
Forward
0 new messages