[issue45934] python curses newterm implementation

2021-12-06 Thread Julius Hamilton

Julius Hamilton  added the comment:

I’m currently planning on studying the C code for initscr and newterm so I can 
really understand how they work.

I’ll post any updates about this soon.

Thanks.

--

___
Python tracker 
<https://bugs.python.org/issue45934>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45934] python curses newterm implementation

2021-12-05 Thread Julius Hamilton

Julius Hamilton  added the comment:

I’m trying to patch this bug.

Here are my current working questions:

1. What is the relationship between an fd (file descriptor) and a terminal?
What software / hardware component goes to “fd 0” to receive input from it?
Is there a GNU Screen command to receive stdin from “fd n”, fd 3 for
example?

2. Looking at the source code:

def initscr():
import _curses, curses
# we call setupterm() here because it raises an error
# instead of calling exit() in error cases.
setupterm(term=_os.environ.get("TERM", "unknown"),
fd=_sys.__stdout__.fileno())
stdscr = _curses.initscr()
for key, value in _curses.__dict__.items():
if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'):
setattr(curses, key, value)
return stdscr

- why does initscr() begin by importing _curses and curses? Precompiled C
curses and non-compiled C or is the second importing Python? How can a
module be importing itself?

- they call “setupterm”, a C curses function, because it raises an error if
there’s a problem in case of just quitting. But how so, specifically? Do
the errors get detected at stderr and then the terminal raises another
error or something? I’m not clear on the details. Plus, why can they call
this function without referring to the enclosing package, curses.setupterm?
Is that a C thing that all functions are automatically added to the
namespace?

- Someone wrote that “initscr” actually calls “newterm”, in the code. So I
guess I should look at the C newterm code, see how it works and see if a
direct implementation is possible.

(I said in an email I would double post an email I sent but instead I’m
posting more specific questions here related to that email. Also, I’m still
studying an email Guido sent, so apologies for any redundant questions
here.)

Thanks,
Julius

On Sun 5. Dec 2021 at 00:01, Éric Araujo  wrote:

>
> Change by Éric Araujo :
>
>
> --
> stage:  -> needs patch
> versions:  -Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9
>
> ___
> Python tracker 
> <https://bugs.python.org/issue45934>
> ___
>

--

___
Python tracker 
<https://bugs.python.org/issue45934>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45934] python curses newterm implementation

2021-12-05 Thread Julius Hamilton

Julius Hamilton  added the comment:

I’m trying to patch this bug.

Here are my current working questions:

1. What is the relationship between an fd (file descriptor) and a terminal? 
What software / hardware component goes to “fd 0” to receive input from it? Is 
there a GNU Screen command to receive stdin from “fd n”, fd 3 for example?

2. Looking at the source code:

def initscr():
import _curses, curses
# we call setupterm() here because it raises an error
# instead of calling exit() in error cases.
setupterm(term=_os.environ.get("TERM", "unknown"),
  fd=_sys.__stdout__.fileno())
stdscr = _curses.initscr()
for key, value in _curses.__dict__.items():
if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'):
setattr(curses, key, value)

return stdscr

- why does initscr() begin by importing _curses and curses? Precompiled C 
curses and non-compiled C or is the second importing Python? How can a module 
be importing itself?

- they call “setupterm”, a C curses function, because it raises an error if 
there’s a problem in case of just quitting. But how so, specifically? Do the 
errors get detected at stderr and then the terminal raises another error or 
something? I’m not clear on the details. Plus, why can they call this function 
without referring to the enclosing package, curses.setupterm? Is that a C thing 
that all functions are automatically added to the namespace?

- Someone wrote that “initscr” actually calls “newterm”, in the code. So I 
guess I should look at the C newterm code, see how it works and see if a direct 
implementation is possible.


(I said in an email I would double post an email I sent but instead I’m posting 
more specific questions here related to that email. Also, I’m still studying an 
email Guido sent, so apologies for any redundant questions here.)

Thanks,
Julius

--

___
Python tracker 
<https://bugs.python.org/issue45934>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45934] python curses newterm implementation

2021-12-04 Thread Julius Hamilton


Change by Julius Hamilton :


--
nosy: +Guido.van.Rossum, juliushamilton100

___
Python tracker 
<https://bugs.python.org/issue45934>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com