[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2021-02-19 Thread Brett Cannon


Brett Cannon  added the comment:

Since this is still open I would assume it never made it in.

--

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2021-02-19 Thread Brian Hulette


Brian Hulette  added the comment:

Hey there, I just came across this bug when looking into a problem with 
corrupted pyc files. Was the patch ever applied? I'm still seeing the original 
behavior in Python 3.7.

Thanks!

--
nosy: +hulettbh

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2016-09-12 Thread Eric Snow

Eric Snow added the comment:

I was going to ask Ned, but I'm fine with holding off until 3.7. :)

--

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2016-09-12 Thread Brett Cannon

Brett Cannon added the comment:

I don't think we should try and squeeze this in for 3.6 since we have now hit 
beta and this is a feature since this is changing semantics that date back to 
Python 2. I'm going to go ahead and change the target to 3.7.

--
versions: +Python 3.7 -Python 3.6

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2016-09-12 Thread Eric Snow

Changes by Eric Snow :


Removed file: http://bugs.python.org/file44601/issue28007.diff

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2016-09-12 Thread Eric Snow

Changes by Eric Snow :


Added file: http://bugs.python.org/file44604/issue28007.diff

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2016-09-12 Thread Eric Snow

Eric Snow added the comment:

Here's a patch to soften the impact of pyc-related problems.

Note:
* Each pyc-related case that previously caused import to fail now results in an 
ImportWarning.  This applies to both reading and writing .pyc files.
* Each warning has __cause__ set to the caught exception.
* Some cases where the exception was already being swallowed now result in a 
warning while others are still swallowed.
* The tests verify that the warnings, with appropriate causes, are issued.
* The tests verify that existing bad .pyc file get overwritten.
* importlib._bootstrap_external.StaleBytecodeError is new.  It should surface 
only from SourcelessFileLoader.
* SourcelessFileLoader is not changed.

--
keywords: +patch
Added file: http://bugs.python.org/file44601/issue28007.diff

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2016-09-09 Thread Eric Snow

Changes by Eric Snow :


--
assignee:  -> eric.snow

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2016-09-09 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

On Sep 09, 2016, at 08:30 PM, Terry J. Reedy wrote:

>I think we should definitely fall back to using the .py file.  A cache is an
>implementation convenience, not a language feature.

+1.  If the cache is corrupt, it should be ignored and recreated.  There are
of course situations where that may not be possible though, e.g. if the .pyc
is on a read-only file system or the user doesn't have permission to write the
.pyc.  Still in those cases, if the .py is okay, but the .pyc is not, we
should do a source import.  I believe we already don't fall over if the .pyc
isn't writable, so let's keep that.  Although I don't think it's worth it, we
could add some extra knobs to warn about this case, or to be strict about not
allowing source imports.

--

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2016-09-09 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I think we should definitely fall back to using the .py file.  A cache is an 
implementation convenience, not a language feature.

A student using an all-users install typically does not have admin access to 
delete bad .pyc files.  In Windows, a user install is by default hidden in the 
hidden %APPDATA% directory (location somewhat Windows version dependent).  Even 
I did not know until recently how to access files there.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2016-09-07 Thread R. David Murray

R. David Murray added the comment:

That makes sense to me as a use case for warnings only.

--

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2016-09-07 Thread Nick Coghlan

Nick Coghlan added the comment:

I run into this kind of problem when switching back and forth between running 
things directly on my laptop and running them as a mounted volume in a 
container, since the permissions and SELinux labels on the cache can get messed 
up.

However, in those cases, writing back to the cache will also fail (since it's a 
"those are not your files, hands off" permissions problem).

So I'd be a fan of downgrading problems with the .pyc cache to warnings in 
general - if we read it and that fails, OK, we'll revert to using the source. 
If we try to write it, and that fails, well that's potentially OK too - writing 
to the cache is to speed up the *next* invocation of the module, and whether or 
not we actually care about that is going to be situational.

--

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2016-09-07 Thread Sye van der Veen

Sye van der Veen added the comment:

Consider a process that is terminated while writing a large .pyc file.  
Currently a user can only fix this by deleting the .pyc file, which requires 
knowing where to look.  A developer can be expected to know this, but the end 
user of their application certainly would not.

.pyc files are a cache.  When your cache is corrupted, you recreate it.

--

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2016-09-07 Thread R. David Murray

R. David Murray added the comment:

I agree, I don't think it is worth it.  If we did do it, there should be a 
warning, and things should still fail if the new .pyc file can't be written to 
replace the corrupt one.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2016-09-07 Thread Eric Snow

New submission from Eric Snow:

As pointed out in #16384, a bad .pyc file will cause a module to fail 
importing.  Sometimes the .py file is okay, however.  The question posed in the 
other issue is if it would be desirable to fall back to the .py file.

FWIW, I don't think it's worth it.

--
components: Interpreter Core
messages: 274872
nosy: barry, brett.cannon, eric.snow, ncoghlan, syeberman
priority: normal
severity: normal
stage: needs patch
status: open
title: Bad .pyc files prevent import of otherwise valid .py files.
type: behavior
versions: Python 3.6

___
Python tracker 

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