Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-14 Thread Mike Dewhirst via Python-list
In Windows the provided methods for running complex command lines are either a 
batch file or a shortcut.Someone very kindly pointed out to me in this thread 
that there is a PEP for py.exe. I don't use py.exe originally because I didn't 
trust it believing it was a new-fangled Microsoft trick. I did read that PEP 
but it has no relevance for my mixed Windows/Linux environments. On reflection 
I now believe I won't use py.exe because it introduces an unnecessary layer of 
indirection.The  bottom line is that you still need to know which Python a 
particular set of circumstances demands and if you use py.exe you then need to 
also understand how it chooses and how it interprets shebang lines written for 
your Linux environment. And if that isn't your situation I have jumped to the 
wrong conclusion.I have found no problem in Windows when I use shebang lines in 
scripts intended for execution in both Linux and Windows. They are ignored 
unless you use py.exe.My advice is to give up py.exe unless your use case 
mandates shebang lines in Windows.M--(Unsigned mail from my phone)
 Original message From: Sibylle Koczian via Python-list 
 Date: 14/1/24  23:59  (GMT+10:00) To: 
python-list@python.org Subject: Re: Python 3.12.1, Windows 11: shebang line 
#!/usr/bin/env python3
  doesn't work any more Am 09.01.2024 um 12:36 schrieb Barry Scott via 
Python-list:> > >> On 7 Jan 2024, at 15:09, Sibylle Koczian via Python-list 
 wrote: Oh, and the two Windows and Python versions 
are on two different computers. Will remove the "/env" from my shebang 
lines, even if I don't understand what's happening.> > Thanks for the details.> 
> Only thing I can think of is that "python" may be defaulting to mean python 
2.> If you use "#!/usr/bin/env python3" it may work on both.No, it doesn't. 
That's the form I started with. When it didn't work I thought "python3" might 
be too old, because Python 2 is dead for so long.> > Did you creates a py.ini 
file to configure py.exe?> > See if you have %userappdata%\py.ini on either 
windows 10 or windows 11.> If so what is its contents?No to both.> > I've tried 
with and without a py.ini and cannot duplicate what you see.> It really seems 
strange. Only thing I can think of - and I don't really believe in that idea: 
as far as I know in Windows 11 the handling of PATH has changed. My Python 
isn't on the path, perhaps that is it. A shebang line without "/env" doesn't 
check the path, right?Thank you for helping,Sibylle-- 
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-29 Thread Mike Dewhirst via Python-list

On 29/12/2023 12:09 pm, Félix An via Python-list wrote:

On 2023-12-25 12:36, Mike Dewhirst wrote:


3. You cannot trust Microsoft. You can trust Python Software 
Foundation. Python from PSF works the same in all environments - or 
if not it is a bug. Python from Microsoft is tweaked to satisfy their 
aforementioned strategy of locking in users to Windows.




I strongly disagree with this.


Not sure which part of the above you strongly disagree with. I might 
seem a bit OTT with "You cannot trust Microsoft" but I did put it in a 
specific context.


PSF does try to make Python work identically in all operating systems it 
supports. The OP was using py.exe which I discovered (just now - and it 
is why I'm writing this) exists on my Windows 10 machine. I have never 
installed any Python other than personally downloaded from the 
python.org website - therefore py.exe must have come from PSF!


I had assumed the OP had installed Python from the Microsoft shop and 
that's where py.exe must have come from.


I learn something every day.

I don't get all the irrational hate for Microsoft that exists within 
the Linux community.


Perhaps you are too young to remember when Steve Ballmer was head of 
Microsoft?


He specifically and loudly hated Linux and developed the anti-linux 
culture/strategy within Microsoft. If memory serves correctly he called 
it a virus. That was in the context of trying to get rid of Linux in 
Europe (Germany I think) where it had gained a small municipal foothold. 
Microsoft eventually succeeded in reversing that public mistake.


In recent years, Microsoft has made great contributions to the 
everyday life of Linux users. VS Code is based on open source and 
available on Linux, .NET is now on Linux, Windows has WSL2 and Visual 
Studio Linux development tools to help you develop software for Linux, 
SQL Server (despite still being commercial software except for the 
Express and Developer versions) is on Linux, etc.


I only use Linux on servers without GUI. I have used Windows desktop 
since it was released because most of my clients used it. I had no 
choice. I have been watching what they do for decades.


I agree they appear to have become more civilised in recent years.

M

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.



OpenPGP_signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-25 Thread Mike Dewhirst via Python-list
Well spotted Chris. 4 was a generalisation based on my own 
circumstances.However, I'm not wrong about Microsoft motivationsM--(Unsigned 
mail from my phone)
 Original message From: Chris Angelico via Python-list 
 Date: 25/12/23  15:57  (GMT+10:00) To: Michael Torrie 
via Python-list  Subject: Re: Python 3.12.1, Windows 
11: shebang line #!/usr/bin/env python3
  doesn't work any more On Mon, 25 Dec 2023 at 15:42, Mike Dewhirst via 
Python-list wrote:>> Apologies for top posting - my 
phone seems unable to do otherwise.>> Here's my view - which may not be 
popular.You're right about that part, anyhow :)> 4. Shebang lines are pretty 
much redundant now that most python interpreters are run from venvsStrongly 
dispute that. The rest. you're entitled to your opinions(they happen to be 
wrong, but you're entitled to them :) ), but thisis a statement of fact that I 
would need to see some evidence for.ChrisA-- 
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-24 Thread Mike Dewhirst via Python-list
Apologies for top posting - my phone seems unable to do otherwise.

Here's my view - which may not be popular.

1. Py.exe is an awful idea. 

2. Installing python in %PROGRAMFILES% is not a good idea

3. Installing Python from a Microsoft shop or server is a bad idea

4. Shebang lines are pretty much redundant now that most python interpreters 
are run from venvs

5. Shebang lines have never had a place in Windows

TL;DR

1. Py.exe is not a standard python thing and learning to rely on it is 
following Microsoft's marketing strategy. That strategy has served them 
brilliantly since the 1980s. They make their environment just different enough 
to force users to invest brainspace to make it work and thereby lock-in their 
users with their own muscle-memory. Very subtle. Not.

2. Installing Python in Microsoft's preferred location wasn't always 
"standard". Python downloaded from python.org always defaulted to C:\PythonXXX. 
I'm not saying that was a perfect location but at least it was (in my case 
still is) nicely visible for researching multiple different pythons. Putting 
deep in Program files does nothing other than hide it. 

3. You cannot trust Microsoft. You can trust Python Software Foundation. Python 
from PSF works the same in all environments - or if not it is a bug. Python 
from Microsoft is tweaked to satisfy their aforementioned strategy of locking 
in users to Windows.

4. Shebang lines are a fallback if you don't wish to type the interpreter 
location before typing your script name. You must know your interpreter 
location to get the shebang line right. Shebangs were never intended as primary 
devices. They are linux/unix things.

5. Shebangs on Windows are a new opportunity for Microsoft to plough its own 
furrow. They are difficult to handle simply because of 4 above.

To finish this rant, I believe it is far better to aim for standardisation 
rather than subtle and annoying differences deliberately designed to supplant 
standards in favour of market dominance.

Merry Christmas all

Cheers

Mike




On 24 December 2023 3:35:42 am AEDT, Michael Torrie via Python-list 
 wrote:
>On 12/22/23 20:56, Thomas Passin via Python-list wrote:
>> It's just better not to make assumptions about which version of Python 
>> will be running. Just specify it yourself when you can, and then you can 
>> be sure.
>
>Precisely, which is why the shebang is so useful, even on Windows with
>py launcher.  For example, set the shebang to:
>
>#!/usr/bin/python3.6
>
>And py launcher will always try to run it with Python 3.6.
>
>-- 
>https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Code improvement question

2023-11-16 Thread Mike Dewhirst via Python-list

On 16/11/2023 9:34 am, Rimu Atkinson via Python-list wrote:





Why don't you use re.findall?

re.findall(r'\b[0-9]{2,7}-[0-9]{2}-[0-9]{2}\b', txt)


I think I can see what you did there but it won't make sense to me - 
or whoever looks at the code - in future.


That answers your specific question. However, I am in awe of people 
who can just "do" regular expressions and I thank you very much for 
what would have been a monumental effort had I tried it.


I feel the same way about regex. If I can find a way to write 
something without regex I very much prefer to as regex usually adds 
complexity and hurts readability.


You might find https://regex101.com/ to be useful for testing your 
regex. You can enter in sample data and see if it matches.


If I understood what your regex was trying to do I might be able to 
suggest some python to do the same thing. Is it just removing numbers 
from text?


The for loop, "for bit in bits" etc, could be written as a list 
comprehension.


pieces = [bit if len(bit) > 6 else "" for bit in bits]

For devs familiar with other languages but new to Python this will 
look like gibberish so arguably the original for loop is clearer, 
depending on your team.


It's worth making the effort to get into list comprehensions though 
because they're awesome.


I agree qualitatively 100% but quantitively perhaps I agree 80% where 
readability is easy.


I think that's what you are saying anyway.








That little re.sub() came from ChatGPT and I can understand it 
without too much effort because it came documented


I suppose ChatGPT is the answer to this thread. Or everything. Or 
will be.


I am doubtful. We'll see!

R





--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.



OpenPGP_signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Code improvement question

2023-11-16 Thread Mike Dewhirst via Python-list

On 15/11/2023 3:08 pm, MRAB via Python-list wrote:

On 2023-11-15 03:41, Mike Dewhirst via Python-list wrote:

On 15/11/2023 10:25 am, MRAB via Python-list wrote:

On 2023-11-14 23:14, Mike Dewhirst via Python-list wrote:
I'd like to improve the code below, which works. It feels clunky to 
me.


I need to clean up user-uploaded files the size of which I don't 
know in

advance.

After cleaning they might be as big as 1Mb but that would be super 
rare.

Perhaps only for testing.

I'm extracting CAS numbers and here is the pattern xx-xx-x up to
xxx-xx-x eg., 1012300-77-4

def remove_alpha(txt):

      """  r'[^0-9\- ]':

      [^...]: Match any character that is not in the specified set.

      0-9: Match any digit.

      \: Escape character.

      -: Match a hyphen.

      Space: Match a space.

      """

  cleaned_txt = re.sub(r'[^0-9\- ]', '', txt)

      bits = cleaned_txt.split()

      pieces = []

      for bit in bits:

      # minimum size of a CAS number is 7 so drop smaller 
clumps of digits


      pieces.append(bit if len(bit) > 6 else "")

      return " ".join(pieces)


Many thanks for any hints


Why don't you use re.findall?

re.findall(r'\b[0-9]{2,7}-[0-9]{2}-[0-9]{2}\b', txt)


I think I can see what you did there but it won't make sense to me - or
whoever looks at the code - in future.

That answers your specific question. However, I am in awe of people who
can just "do" regular expressions and I thank you very much for what
would have been a monumental effort had I tried it.

That little re.sub() came from ChatGPT and I can understand it without
too much effort because it came documented

I suppose ChatGPT is the answer to this thread. Or everything. Or 
will be.



\b  Word boundary
[0-9]{2,7}  2..7 digits
-   "-"
[0-9]{2}    2 digits
-   "-"
[0-9]{2}    2 digits
\b  Word boundary

The "word boundary" thing is to stop it matching where there are 
letters or digits right next to the digits.


For example, if the text contained, say, "123456789-12-1234", you 
wouldn't want it to match because there are more than 7 digits at the 
start and more than 2 digits at the end.



Thanks

I know I should invest some brainspace in re. Many years ago at a Perl 
conferenceI did buy a coffee mug completely covered with a regex cheat 
sheet. It currently holds pens and pencils on my desk. And spiders now I 
look closely!


Then I took up Python and re is different.

Maybe I'll have another look ...

Cheers

Mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.



OpenPGP_signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Code improvement question

2023-11-14 Thread Mike Dewhirst via Python-list

On 15/11/2023 10:25 am, MRAB via Python-list wrote:

On 2023-11-14 23:14, Mike Dewhirst via Python-list wrote:

I'd like to improve the code below, which works. It feels clunky to me.

I need to clean up user-uploaded files the size of which I don't know in
advance.

After cleaning they might be as big as 1Mb but that would be super rare.
Perhaps only for testing.

I'm extracting CAS numbers and here is the pattern xx-xx-x up to
xxx-xx-x eg., 1012300-77-4

def remove_alpha(txt):

      """  r'[^0-9\- ]':

      [^...]: Match any character that is not in the specified set.

      0-9: Match any digit.

      \: Escape character.

      -: Match a hyphen.

      Space: Match a space.

      """

  cleaned_txt = re.sub(r'[^0-9\- ]', '', txt)

      bits = cleaned_txt.split()

      pieces = []

      for bit in bits:

      # minimum size of a CAS number is 7 so drop smaller clumps 
of digits


      pieces.append(bit if len(bit) > 6 else "")

      return " ".join(pieces)


Many thanks for any hints


Why don't you use re.findall?

re.findall(r'\b[0-9]{2,7}-[0-9]{2}-[0-9]{2}\b', txt)


I think I can see what you did there but it won't make sense to me - or 
whoever looks at the code - in future.


That answers your specific question. However, I am in awe of people who 
can just "do" regular expressions and I thank you very much for what 
would have been a monumental effort had I tried it.


That little re.sub() came from ChatGPT and I can understand it without 
too much effort because it came documented


I suppose ChatGPT is the answer to this thread. Or everything. Or will be.

Thanks

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


Code improvement question

2023-11-14 Thread Mike Dewhirst via Python-list

I'd like to improve the code below, which works. It feels clunky to me.

I need to clean up user-uploaded files the size of which I don't know in 
advance.


After cleaning they might be as big as 1Mb but that would be super rare. 
Perhaps only for testing.


I'm extracting CAS numbers and here is the pattern xx-xx-x up to 
xxx-xx-x eg., 1012300-77-4


def remove_alpha(txt):

    """  r'[^0-9\- ]':

    [^...]: Match any character that is not in the specified set.

    0-9: Match any digit.

    \: Escape character.

    -: Match a hyphen.

    Space: Match a space.

    """

cleaned_txt = re.sub(r'[^0-9\- ]', '', txt)

    bits = cleaned_txt.split()

    pieces = []

    for bit in bits:

    # minimum size of a CAS number is 7 so drop smaller clumps of digits

    pieces.append(bit if len(bit) > 6 else "")

    return " ".join(pieces)


Many thanks for any hints

Cheers

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


Re: Help

2023-11-07 Thread Mike Dewhirst via Python-list

On 7/11/2023 9:02 am, Jason Friedman via Python-list wrote:

On Sun, Nov 5, 2023 at 1:23 PM office officce via Python-list <
python-list@python.org> wrote:


which python version is better to be used and how to make sure it works on
my window 10 because i downloaded it and it never worked so I uninstall to
do that again please can you give me the steps on how it will work perfectly


1. Download from https://python.org (not Microsoft) and always choose 
the 64-bit stable version


2. Choose the installation location as C:\Python311 (avoid the default)

4. Accept other recommended installation options especially to include 
Python on the path (if offered)


Guaranteed to work. Also, you will never have to uninstall. Install the 
next version in C:\Python312 etc


In due course, investigate virtual environments so you can work on 
projects simultaneously using different versions of Python or different 
versions of various Python libraries.


Good luck

Mike





If you are just starting out, the most recent version is 3.12 and is
probably your best choice.

When you say it never worked, can you describe in more detail what you did
and what error messages you encountered?

This mailing list does not accept screenshots.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.



OpenPGP_signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking if email is valid

2023-11-02 Thread Mike Dewhirst via Python-list
If i wanted an email verifier I would look at open source frameworks and see 
how they do it. Django comes to mind.--(Unsigned mail from my phone)
 Original message From: Michael Torrie via Python-list 
 Date: 3/11/23  07:23  (GMT+10:00) To: 
python-list@python.org Subject: Re: Checking if email is valid On 11/2/23 
00:42, Simon Connah via Python-list wrote:> Basically I'm writing unit tests 
and one of them passess in a string > with an invalid email address. I need to 
be able to check the string > to see if it is a valid email so that the unit 
test passess.If you truly have managed to code an RFC-compliant verifier, I 
commend you.> Valid as in conforms to the standard. Although having looked at 
the> standard that might be more difficult than originally planned.You'll have 
to read the relevant RFCs.  Lots of corner cases!  From whatI can see virtually 
no one on the internet gets it right, judging by thenumber of times I have 
valid email addresses flagged as not valid bypoor algorithms.-- 
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: regarding installation of python version

2023-10-09 Thread Mike Dewhirst via Python-list
Look in Windows Settings, About, Advanced system settings, Environment 
variables and you will see two sets of variables. One for the system and one 
set for yourself.Select Path and click [Edit]Carefully remove all references to 
Python in both sets.In theory you can now install a new Python and it will 
update your environment variables and that will be the Python you 
use.Otherwise, find the Python executable (python.exe) you wish to use and call 
it in your terminal using its full path.Good luckMike--(Unsigned mail from my 
phone)
 Original message From: "Thri sowmya.G via Python-list" 
 Date: 10/10/23  04:43  (GMT+10:00) To: 
python-list@python.org Subject: regarding installation of python version        
The problem is how many times I have uninstalled the python version but   
always it is showing the  same version  after the installation  of new   
version too  .But in all control panel and file explorer at everywhere the   
system showing that the old  version got uninstalled  but again in command   
prompt or terminal it is in  same old version. I hope I will get a   solution 
from you.       
    
   Thank you.    -- 
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


zoneinfo and tzdata

2023-08-09 Thread Mike Dewhirst via Python-list
The zoneinfo module does not work on Windows unless you have installed 
tzdata.


On Ubuntu that data seems to exist already. Not sure how or why but it 
obviously isn't there in a Windows virtualenv unless deliberately installed.


I just spent a bit of time trying to switch from pytz to zoneinfo in 
Django without luck. I then asked and greatly embarrassed ChatGPT which 
kept apologizing when I fed back all the zoneinfo errors its advice caused.


It wasn't until I read the docs that I saw zoneinfo would get timezone 
data from tzdata if the real info wasn't where it first looked.


As soon as I installed tzdata, ChatGPT's advice started to work. When I 
reported this, it was very grateful and assured me my generosity in 
bothering to correct it would be very beneficial for other users having 
similar problems.


Might I suggest that if zoneinfo comes up empty-handed it should raise 
an error saying no timezone information was found?


Currently, it just nominates the timezone key you attempt to use. Behind 
the scenes it surely knows there are no such keys. In that case it might 
suggest installing tzdata.


Cheers

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


Re: Isn't TypeError built in?

2021-12-25 Thread Mike Dewhirst via Python-list
Thanks Peter ... the problem was all mine.Can't quite remember what it was 
exactly but I introduced a bug in my own code and it manifested down there in 
the bowels of the snake.I suppose that indicates a possible kink to be ironed 
out and if that interests you I am happy to retrace my steps and describe 
it.Fyi, there was nothing out of kilter in the machine. It was in production 
and is stable.CheersMike--(Unsigned mail from my phone)
 Original message From: "Peter J. Holzer"  
Date: 26/12/21  06:19  (GMT+10:00) To: python-list@python.org Subject: Re: 
Isn't TypeError built in? On 2021-12-13 12:22:28 +1100, Mike Dewhirst via 
Python-list wrote:> Obviously something is wrong elsewhere but I'm not sure 
where to look.> Ubuntu 20.04 with plenty of RAM.[...]> [Mon Dec 13 
01:15:49.885659 2021] [mpm_event:notice] [pid 1033:tid> 140446449658944] 
AH00489: Apache/2.4.41 (Ubuntu) SVN/1.13.0 OpenSSL/1.1.1f> mod_wsgi/4.6.8 
Python/3.8 configured -- resuming normal operations> [Mon Dec 13 
01:15:49.885664 2021] [core:notice] [pid 1033:tid> 140446449658944] AH00094: 
Command line: '/usr/sbin/apache2'> Exception ignored in: > Traceback (most recent call last):>   File 
"/usr/local/lib/python3.8/dist-packages/asgiref/local.py", line 96,> in 
__del__> NameError: name 'TypeError' is not definedDid you upgrade the OS 
recently and do you use virtual environents withmod_wsgi?"Impossible" errors 
like the above are common when the virtualenvironment was built with a 
different (older) version of the Pythoninterpreter than the one trying to use 
it. Nuking and rebuilding thevirtual environment is usually the quickest way to 
fix it.    hp--    _  | Peter J. Holzer    | Story must make more sense 
than reality.|_|_) |    || |   | h...@hjp.at |    -- 
Charles Stross, "Creative writing__/   | http://www.hjp.at/ |   
challenge!"-- https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Isn't TypeError built in?

2021-12-13 Thread Mike Dewhirst via Python-list

On 13/12/2021 12:42 pm, Chris Angelico wrote:

On Mon, Dec 13, 2021 at 12:31 PM Mike Dewhirst via Python-list
  wrote:

Obviously something is wrong elsewhere but I'm not sure where to look.
Ubuntu 20.04 with plenty of RAM.

  def __del__(self):
  try:
  for context_obj in self._context_refs:
  try:
  delattr(context_obj, self._attr_name)
  except AttributeError:
  pass

  except TypeError:# THIS IS LINE 96 IN THE APACHE2 ERROR
LOG BELOW

  # WeakSet.__iter__ can crash when interpreter is shutting
down due
  # to _IterationGuard being None.
  pass

[Mon Dec 13 01:15:49.875993 2021] [mpm_event:notice] [pid 1033:tid
140446449658944] AH00493: SIGUSR1 received.  Doing graceful restart
[Mon Dec 13 01:15:49.878443 2021] [so:warn] [pid 1033] AH01574: module
dav_module is already loaded, skipping
[Mon Dec 13 01:15:49.885659 2021] [mpm_event:notice] [pid 1033:tid
140446449658944] AH00489: Apache/2.4.41 (Ubuntu) SVN/1.13.0
OpenSSL/1.1.1f mod_wsgi/4.6.8 Python/3.8 configured -- resuming normal
operations
[Mon Dec 13 01:15:49.885664 2021] [core:notice] [pid 1033:tid
140446449658944] AH00094: Command line: '/usr/sbin/apache2'
Exception ignored in: 
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/asgiref/local.py", line
96, in __del__
NameError: name 'TypeError' is not defined
Exception ignored in: 
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/asgiref/local.py", line
96, in __del__
NameError: name 'TypeError' is not defined

Any hints welcome ...

During interpreter shutdown, all kinds of things can go weird. The
order that things get destroyed isn't always clearly defined.

Is it possible to do the cleanup work before interpreter shutdown?
Alternatively: maybe take a local reference to the exception types you
need to refer to (just "AttributeError = AttributeError" at top level
should do it), which should keep them alive longer (I think). Worst
case, capture *all* exceptions, then look at e.__class__.__name__ and
match on that.

ChrisA


OK - not solved but resolved anyway.

The Django project was failing on the new server and working fine in dev.

The problem seems to be a mis-export from an old subversion repo.The 
project was being reconstituted on a new staging server from a reloaded 
svn dump from the old (ancient) svn server to the new svn server on the 
same machine.


Resolution "happened" when I updated the (c) notice in all source files 
and recommitted to the new server and re-exported from that. The repo 
looks fine. The log is all there back to the beginning. As a test I have 
deployed from an earlier revision and that all works. It's either a 
miracle or I did something else (which I didn't notice) which fixed it.


Thanks to everyone for thinking about this.

Cheers

Mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.



OpenPGP_signature
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Isn't TypeError built in?

2021-12-12 Thread Mike Dewhirst via Python-list
Obviously something is wrong elsewhere but I'm not sure where to look. 
Ubuntu 20.04 with plenty of RAM.


    def __del__(self):
    try:
    for context_obj in self._context_refs:
    try:
    delattr(context_obj, self._attr_name)
    except AttributeError:
    pass

    except TypeError:        # THIS IS LINE 96 IN THE APACHE2 ERROR 
LOG BELOW


    # WeakSet.__iter__ can crash when interpreter is shutting 
down due

    # to _IterationGuard being None.
    pass

[Mon Dec 13 01:15:49.875993 2021] [mpm_event:notice] [pid 1033:tid 
140446449658944] AH00493: SIGUSR1 received.  Doing graceful restart
[Mon Dec 13 01:15:49.878443 2021] [so:warn] [pid 1033] AH01574: module 
dav_module is already loaded, skipping
[Mon Dec 13 01:15:49.885659 2021] [mpm_event:notice] [pid 1033:tid 
140446449658944] AH00489: Apache/2.4.41 (Ubuntu) SVN/1.13.0 
OpenSSL/1.1.1f mod_wsgi/4.6.8 Python/3.8 configured -- resuming normal 
operations
[Mon Dec 13 01:15:49.885664 2021] [core:notice] [pid 1033:tid 
140446449658944] AH00094: Command line: '/usr/sbin/apache2'

Exception ignored in: 
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/asgiref/local.py", line 
96, in __del__

NameError: name 'TypeError' is not defined
Exception ignored in: 
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/asgiref/local.py", line 
96, in __del__

NameError: name 'TypeError' is not defined

Any hints welcome ...

Thanks

Mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.



OpenPGP_signature
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


pythonpapers.org domain name to lapse in November

2021-10-04 Thread Mike Dewhirst via Python-list
The board of editors of the Python Papers has decided to let the 
pythonpapers.org domain name to lapse.


It will not be renewed in November.

Anyone interested in it can get in touch.

Cheers

Mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.



OpenPGP_signature
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML Considered Harmful

2021-09-24 Thread Mike Dewhirst via Python-list
I had to use XML once because that was demanded by the receiving machine over 
which I had no say.I wouldn't use it otherwise because staring at it makes you 
dizzy.I would want to know how the data are derived from the multiple sources 
and transmitted to the collating platform before pontificating.Then I would 
ignore any potential future enhancements and choose the easiest possible 
mechanism. I have used json with python and been delighted at the ease of 
converting data into dicts and even arbitrary nesting where data values can 
also be dicts etc.Good luck--(Unsigned mail from my phone)
 Original message From: dn via Python-list 
 Date: 24/9/21  15:42  (GMT+10:00) To: 
python-list@python.org Subject: Re: XML Considered Harmful On 24/09/2021 14.07, 
Stefan Ram wrote:> dn  writes:>> With that, why 
not code it as Python expressions, and include the module?> >   This might 
create a code execution vulnerability if such >   files are exchanged between 
multiple parties.The OP's spec, as quoted earlier(!), reads:"It's my own 
research, so I can give myself the data in any format thatI like."Whither 
"files are exchanged" and/or "multiple parties"? Are theseanticipations of 
problems that may/won't ever apply? aka YAGNI.Concern about such an approach 
*is* warranted.However, the preceding question to be considered during the 
design-stageis: 'does such concern apply?'. The OP describes full and unique 
agency.Accordingly, "KISS"!NB my personal choice would likely be JSON or YAML, 
but see reservations(eg @Chris) - and with greater relevance: shouldn't we 
consider the OP's'learning curve'?(such deduced only from OP's subsequent 
reactions/responses 'here' -with any and all due apologies)-- Regards,=dn-- 
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list