Re: port to PDOS (especially mainframe)

2021-04-14 Thread Paul Edwards
I have succeeded in producing a Python 3.3 executable
despite being built with a C library that only supports
C90. I had to provide my own mini-posix wrappers that
convert open() into fopen() etc.

With that in place, plus a compiler where char = wchar_t,
there were not a lot of changes required to the Python
mainline (see below).

However, the executable doesn't work yet. Here's the
current state:

C:\devel\python\Modules>python
Traceback (most recent call last):
  File "", line 1755, in _install
  File "", line 1726, in _setup
ImportError: importlib requires posix or nt
Fatal Python error: Py_Initialize: importlib install failed

Current thread 0x:


That error message comes from here:
C:\devel\python\Python>head importlib.h

which is not human readable.

It is generated by this code:
C:\devel\python\Lib\importlib>grep "posix or nt" _bootstrap.py

but I don't know what it needs to satisfy that.

It's a bit strange that it can only be posix or nt when VMS is supported in 3.3 
too.

BFN. Paul.




Index: Modules/main.c
===
RCS file: c:\cvsroot/python/Modules/main.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -r1.1.1.1 -r1.2
728a729
> #ifndef PUREISO 
738a740
> #endif
Index: Modules/signalmodule.c
===
RCS file: c:\cvsroot/python/Modules/signalmodule.c,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -r1.1.1.1 -r1.3
418a419
> #ifndef PUREISO
419a421
> #endif
429a432
> #ifndef PUREISO
433a437
> #endif
Index: Objects/longobject.c
===
RCS file: c:\cvsroot/python/Objects/longobject.c,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -r1.1.1.1 -r1.3
939,944d938
< #ifndef HAVE_LONG_LONG
< #   error "PyLong_FromVoidPtr: sizeof(void*) > sizeof(long), but no long long"
< #endif
< #if SIZEOF_LONG_LONG < SIZEOF_VOID_P
< #   error "PyLong_FromVoidPtr: sizeof(PY_LONG_LONG) < sizeof(void*)"
< #endif
948c942,944
< return PyLong_FromUnsignedLongLong((unsigned 
PY_LONG_LONG)(Py_uintptr_t)p);
---
> #if SIZEOF_VOID_P <= SIZEOF_LONG
> return PyLong_FromUnsignedLong((unsigned long)(Py_uintptr_t)p);
> #else
949a946,950
> #if SIZEOF_LONG_LONG < SIZEOF_VOID_P
> #   error "PyLong_FromVoidPtr: sizeof(long long) < sizeof(void*)"
> #endif
> return PyLong_FromUnsignedLongLong((unsigned 
> PY_LONG_LONG)(Py_uintptr_t)p);
> #endif /* SIZEOF_VOID_P <= SIZEOF_LONG */
986c987
< #ifdef HAVE_LONG_LONG
---
> #if 1 /*def HAVE_LONG_LONG */
996a998
> #ifdef HAVE_LONG_LONG
1037a1040
> #endif
1040a1044
> #ifdef HAVE_LONG_LONG
1066a1071
> #endif
1139a1145
> #ifdef HAVE_LONG_LONG
1187a1194
> #endif
1191a1199
> #ifdef HAVE_LONG_LONG
1223a1232
> #endif
1227a1237
> #ifdef HAVE_LONG_LONG
1256a1267
> #endif
1257a1269
> #ifdef HAVE_LONG_LONG
1291a1304
> #endif
1303a1317
> #ifdef HAVE_LONG_LONG
1389a1404
> #endif
Index: Objects/unicodeobject.c
===
RCS file: c:\cvsroot/python/Objects/unicodeobject.c,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -r1.1.1.1 -r1.3
2243c2243
< #ifdef HAVE_WCHAR_H
---
> #if defined(HAVE_WCHAR_H) || defined(PUREISO)
2865c2865
< #ifdef HAVE_WCHAR_H
---
> #if defined(HAVE_WCHAR_H) || defined(PUREISO)
9148c9148
< // TODO: honor direction and do a forward or backwards search
---
> /*TODO: honor direction and do a forward or backwards search */
Index: Parser/tokenizer.c
===
RCS file: c:\cvsroot/python/Parser/tokenizer.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -r1.1.1.1 -r1.2
1720a1721,1723
> #ifdef PUREISO
> return (NULL);
> #else
1758a1762
> #endif /* PUREISO */
Index: Python/fileutils.c
===
RCS file: c:\cvsroot/python/Python/fileutils.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -r1.1.1.1 -r1.2
40c40
< #ifdef HAVE_STAT
---
> #if 1 /* def HAVE_STAT */
279a280
> #ifdef HAVE_STAT
304a306
> #endif
Index: Python/getopt.c
===
RCS file: c:\cvsroot/python/Python/getopt.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -r1.1.1.1 -r1.2
33c33,35
< #include 
---
> #ifdef HAVE_WCHAR_H
> #include 
> #endif
Index: Python/pythonrun.c
===
RCS file: c:\cvsroot/python/Python/pythonrun.c,v
retrieving revision 1.1.1.1
retrieving revision 1.5
diff -r1.1.1.1 -r1.5
300a301,304
> /* Init Unicode implementation; relies on the codec registry */
> if (_PyUnicode_Init() < 0)
> Py_FatalError("Py_Initialize: can't initialize unicode");
> 
318,321d321
< /* Init Unicode implementation; relies on the codec registry */
< if (_PyUnicode_Init() < 0)
< Py_FatalError("Py_Initialize: can't initialize

Website

2021-04-14 Thread Rainyis
Hello,
I am Sergio Llorente, and I want to create a web about python. I
will publish apps, scripts.. made by python. I will like to put python in
the domain. The domain will be like all-about-python.com but in Spanish(
todosobrepython.com). Can I use it?

Thanks in advance,
Sergio
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Website

2021-04-14 Thread Paul Bryan
Yes.

On Wed, 2021-04-14 at 15:41 +0200, Rainyis wrote:
> Hello,
> I am Sergio Llorente, and I want to create a web about python. I
> will publish apps, scripts.. made by python. I will like to put
> python in
> the domain. The domain will be like all-about-python.com but in
> Spanish(
> todosobrepython.com). Can I use it?
> 
> Thanks in advance,
> Sergio

-- 
https://mail.python.org/mailman/listinfo/python-list


FileNotFoundError: [Errno 2] No such file or directory: ''

2021-04-14 Thread Quentin Bock
I receive this error when I try to open a file
The file (what I'm trying to open) is in the same folder as the program I'm
trying to open it from; why is it saying no such file or directory?

this is the only part of the code that causes the error

file = open('Egils Saga 1-15.txt', "r")

file.close()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: FileNotFoundError: [Errno 2] No such file or directory: ''

2021-04-14 Thread Dan Stromberg
On Wed, Apr 14, 2021 at 9:14 AM Quentin Bock  wrote:

> I receive this error when I try to open a file
> The file (what I'm trying to open) is in the same folder as the program I'm
> trying to open it from; why is it saying no such file or directory?
>
> this is the only part of the code that causes the error
>
> file = open('Egils Saga 1-15.txt', "r")
>
> file.close()
>

Python will try to open the file in the directory you are currently in,
rather than the directory your program is in.

Try cd'ing to the appropriate directory first.  Or specify a full to your
file in the open.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: FileNotFoundError: [Errno 2] No such file or directory: ''

2021-04-14 Thread jak

Il 14/04/2021 18:13, Quentin Bock ha scritto:

I receive this error when I try to open a file
The file (what I'm trying to open) is in the same folder as the program I'm
trying to open it from; why is it saying no such file or directory?

this is the only part of the code that causes the error

file = open('Egils Saga 1-15.txt', "r")

file.close()



>>> file = open('Egils Saga 1-15.txt', "r")
>>> file.read()
'Hello from Egils Saga 1-15.txt'
>>> file.close()

Try to check your 'current working directory':

>>> import os
>>> os.getcwd()
'D:\\tmp'# where the file is
>>>
--
https://mail.python.org/mailman/listinfo/python-list


Re: FileNotFoundError: [Errno 2] No such file or directory: ''

2021-04-14 Thread Dan Stromberg
Open a cmd.exe, command.exe or powershell, and:

cd c:\my\dir\ect\ory
Then run your script.

Or put an os.chdir(r'c:\my\dir\ect\ory') at the top of your script.

Or use file = open(r'c:\my\dir\ect\ory\Egils Saga 1-15.txt', 'r')

BTW, "file" means something to python other than just a variable name.  You
can replace it, as your code below (and my example above) does, but it
obscures the thing you're replacing.  That's why I like to use file_
instead of file.

On Wed, Apr 14, 2021 at 10:42 AM Quentin Bock  wrote:

> Okay, how exactly do I do that?
> Thanks
>
> On Wed, 14 Apr 2021 at 13:35, Dan Stromberg  wrote:
>
>>
>>
>> On Wed, Apr 14, 2021 at 9:14 AM Quentin Bock  wrote:
>>
>>> I receive this error when I try to open a file
>>> The file (what I'm trying to open) is in the same folder as the program
>>> I'm
>>> trying to open it from; why is it saying no such file or directory?
>>>
>>> this is the only part of the code that causes the error
>>>
>>> file = open('Egils Saga 1-15.txt', "r")
>>>
>>> file.close()
>>>
>>
>> Python will try to open the file in the directory you are currently in,
>> rather than the directory your program is in.
>>
>> Try cd'ing to the appropriate directory first.  Or specify a full to your
>> file in the open.
>>
>>
>>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ann: New Python curses book

2021-04-14 Thread Alan Gauld via Python-list
On 30/03/2021 12:12, Alan Gauld via Python-list wrote:
> I've just published, in Kindle and paperback formats,

I've just noticed that the kindle version has several indentation
problems in the code listings. I can't do anything to fix it
because it is all perfectly aligned in the Word file I submit,
it's caused somewhere in the Amazon conversion process. (In fact
it's possibly its OK on some Kindle devices/apps, just not
the web reader I was using!)

Hopefully the expected readership will be smart enough to:
a) figure it out from the context and
b) download the sample code which is correctly formatted.

The paper version should be fine (apart from one error
on p44 which has now been fixed!).

Apologies to anyone who got stung by this.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: port to PDOS (especially mainframe)

2021-04-14 Thread Alan Gauld via Python-list
On 14/04/2021 11:35, Paul Edwards wrote:
> I have succeeded in producing a Python 3.3 executable
...
> However, the executable doesn't work yet.
Late to this party but how big is the assembler?
It might be easier to translate the Python to C!
I've done that in the past and with the aid of a
few functions to mimic common Python constructs
(dicts, foreach() etc) it was verbose but not
too painful.

If its <5K? lines of Python it might be easier.

Just a thought.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ann: New Python curses book

2021-04-14 Thread Rich Shepard

On Wed, 14 Apr 2021, Alan Gauld via Python-list wrote:


The paper version should be fine (apart from one error on p44 which has
now been fixed!).


Alan,

What's the error and correction so I can change it in my dead tree version?

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: FileNotFoundError: [Errno 2] No such file or directory: ''

2021-04-14 Thread Michael F. Stemper

On 14/04/2021 12.55, Dan Stromberg wrote:

Open a cmd.exe, command.exe or powershell, and:

cd c:\my\dir\ect\ory
Then run your script.

Or put an os.chdir(r'c:\my\dir\ect\ory') at the top of your script.

Or use file = open(r'c:\my\dir\ect\ory\Egils Saga 1-15.txt', 'r')

BTW, "file" means something to python other than just a variable name.  You
can replace it, as your code below (and my example above) does, but it
obscures the thing you're replacing.  That's why I like to use file_
instead of file.


Personally, I'd use a meaningful name. For instance, I might do

saga = open(r'c:\my\dir\ect\ory\Egils Saga 1-15.txt', 'r')

or even

with open(r'c:\my\dir\ect\ory\Egils Saga 1-15.txt', 'r') as saga:

The latter form eliminates the need for saga.close(). (I'm sure that you
know that; it's directed at the OP.)

--
Michael F. Stemper
The FAQ for rec.arts.sf.written is at

Please read it before posting.
--
https://mail.python.org/mailman/listinfo/python-list


Re: port to PDOS (especially mainframe)

2021-04-14 Thread Paul Edwards
On Thursday, April 15, 2021 at 4:32:51 AM UTC+10, Alan Gauld wrote:
> On 14/04/2021 11:35, Paul Edwards wrote: 
> > I have succeeded in producing a Python 3.3 executable
> ...
> > However, the executable doesn't work yet.

> Late to this party but how big is the assembler?

Assuming the stuff in "asma" has no dependency
on the other .py files, it is 35,000 lines of code!

I think I might need a linker from them too. I haven't
seen the output of asma yet.

> It might be easier to translate the Python to C!

I would also have a maintenance problem going
that way.

I think other people would like Python to be available
on MVS/380 too, for other projects.

BTW, my Python is a 1.5 MB executable. That is
without optimization and without symbols.

BFN. Paul.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Website

2021-04-14 Thread Mladen Gogala via Python-list
On Wed, 14 Apr 2021 15:41:37 +0200, Rainyis wrote:

> Hello,
> I am Sergio Llorente, and I want to create a web about python. I will
> publish apps, scripts.. made by python. I will like to put python in the
> domain. The domain will be like all-about-python.com but in Spanish(
> todosobrepython.com). Can I use it?
> 
> Thanks in advance,
> Sergio

I give you my permission. May the Force be with you and your website.



-- 
Mladen Gogala
Database Consultant
https://dbwhisperer.wordpress.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: FileNotFoundError: [Errno 2] No such file or directory: ''

2021-04-14 Thread Eryk Sun
On 4/14/21, Quentin Bock  wrote:
>
> this is the only part of the code that causes the error
>
> file = open('Egils Saga 1-15.txt', "r")

Here's an app_abspath() function to resolve a filename against the
directory of the main script:

import os
import sys

def get_main_file():
if hasattr(sys, 'frozen'):
return sys.executable
main = getattr(sys.modules.get('__main__'), '__file__', '')
return os.path.abspath(main) if main else ''

def get_main_dir():
return os.path.dirname(get_main_file()) or os.getcwd()

def app_abspath(filename):
return os.path.join(get_main_dir(), filename)

file = open(app_abspath('Egils Saga 1-15.txt'), 'r')

In the frozen script case, sys.executable is the main 'script'. For a
"-c" command, there is no main file, so it uses the current working
directory.

Using the variable name "file" is fine so long as compatibility with
Python 2 isn't required. In Python 3, "file" is not a reserved keyword
and not the name of a builtin function or type.
-- 
https://mail.python.org/mailman/listinfo/python-list