[issue44070] Regression with relative paths in sys.path in python 3.8.10

2021-05-07 Thread Andy Fiddaman


Andy Fiddaman  added the comment:

I've just found this while investigating a regression with my project following 
update to 3.9.5. It took me some time to discover that the new test failures 
were due to __file__ now being fully qualified when it wasn't before.

As far as I can tell so far it is just breaking the tests, not the software 
(https://github.com/omniosorg/pkg5) but this doesn't feel like a change that 
should be made in a minor release.

--
nosy: +omnios

___
Python tracker 

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



[issue44070] Regression with relative paths in sys.path in python 3.8.10

2021-05-07 Thread James Saryerwinnie


James Saryerwinnie  added the comment:

> What's the actual scenario that this broke?

I only noticed this because a project that I work on 
(https://github.com/aws/chalice/) started failing CI for seemingly unrelated 
changes.  A specific test run is here: 
https://github.com/jamesls/chalice/runs/2529906754.  This didn't actually break 
the framework itself, just the tests for the framework.  Chalice imports your 
application to figure out what resources to deploy to AWS, so the functional 
tests need to setup/teardown misc. applications and re-import them fresh for 
each test.

Turns out the GitHub action I was using switched their Python 3.8 from 3.8.9 to 
3.8.10 so I started looking into why this failed.  My takeaway from this is to 
stop using relative imports in sys.path (I don't recall us having a specific 
reason to do this other than it worked).  I figured I'd file an issue as I'm 
not actually sure if this consequence was intentional (I only saw bpo-43105 
mentioned in the changelog), and was surprised this behavior changed in a patch 
release.

--

___
Python tracker 

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



[issue44070] Regression with relative paths in sys.path in python 3.8.10

2021-05-07 Thread Steve Dower


Steve Dower  added the comment:

It's almost certainly due to that change, though I'd be interested to see a 
more realistic repro.

For the repro shown, you really ought to be clearing the importer cache as well 
when you remove a search path (as implied by chdir with a relative path on 
sys.path) and delete from sys.modules. The new abspath is only applied to the 
full path to the module, so the cache is still for the module, and not for the 
sys.path entry.

What's the actual scenario that this broke?

--

___
Python tracker 

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



[issue44070] Regression with relative paths in sys.path in python 3.8.10

2021-05-07 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

without inspecting the code: I wonder if this is related to the same change as 
https://bugs.python.org/issue44061 ?

--
nosy: +gregory.p.smith

___
Python tracker 

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



[issue44070] Regression with relative paths in sys.path in python 3.8.10

2021-05-07 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
keywords: +3.10regression, 3.8regression, 3.9regression
priority: normal -> high

___
Python tracker 

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



[issue44070] Regression with relative paths in sys.path in python 3.8.10

2021-05-07 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
nosy: +brett.cannon

___
Python tracker 

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



[issue44070] Regression with relative paths in sys.path in python 3.8.10

2021-05-07 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
nosy: +steve.dower

___
Python tracker 

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



[issue44070] Regression with relative paths in sys.path in python 3.8.10

2021-05-07 Thread James Saryerwinnie


New submission from James Saryerwinnie :

There was a change in behavior in Python 3.8.10 when using relative paths in 
sys.path.  It appears that the paths are now converted to absolute paths that 
are cached and can cause import errors in some cases.

Repro:

$ cat repro.sh
#!/bin/bash
python --version
mkdir -p /tmp/repro/{A,B}/testproject
echo "msg = 'from A'" > /tmp/repro/A/testproject/app.py
echo "msg = 'from B'" > /tmp/repro/B/testproject/app.py
python -c "
import sys, os, shutil
os.chdir('/tmp/repro/A')
sys.path.append('testproject')
import app
print(app)
print(app.msg)

os.chdir('/tmp/repro/B')
shutil.rmtree('/tmp/repro/A')
del sys.modules['app']
import app
print(app)
print(app.msg)
"
rm -rf /tmp/repro




On Python 3.8.9 I get:

$ ./repro.sh
Python 3.8.9

from A

from B

On Python 3.8.10 I get:

$ ./repro.sh
Python 3.8.10

from A
Traceback (most recent call last):
  File "", line 12, in 
ModuleNotFoundError: No module named 'app'


I haven't confirmed this (I can't work out the frozen bootstrap stuff), but 
this might be caused by https://bugs.python.org/issue43105, whose patch does 
seem to be converting paths to absolute paths.

--
components: Library (Lib)
messages: 393212
nosy: James.Saryerwinnie
priority: normal
severity: normal
status: open
title: Regression with relative paths in sys.path in python 3.8.10
type: behavior
versions: Python 3.10, Python 3.11, Python 3.8, Python 3.9

___
Python tracker 

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