From: SourceForge.net <no...@so...> - 2006-02-02 23:29:25
|
Bugs item #1421812, was opened at 2006-02-01 22:06 Message generated for change (Comment added) made by laukpe You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112867&aid=1421812&group_id=12867 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: Jython 2.2a and 2.1 imports directories as modules Initial Comment: Jython 2.2a and Jython 2.1 will import a directory even if it does not contain a __init__.py file in it. Moreover - these directories will override builtins and modules from JYTHON_HOME/Lib such as sys. example: mkdir sys ./jython import sys will import the wrong module. This is quite severe. ---------------------------------------------------------------------- Comment By: Pekka Laukkanen (laukpe) Date: 2006-02-03 01:29 Message: Logged In: YES user_id=1379331 I see. Will that work also with directories with __init__.py (e.g. x/x/__init__.py)? ---------------------------------------------------------------------- Comment By: Samuele Pedroni (pedronis) Date: 2006-02-03 00:59 Message: Logged In: YES user_id=61408 This feature is there to enable importing java packages from sys.path and is there since a long time. Bug in 2.2 not with standing is going to stay in some form. Notice that overall python module/packages in 2.1 take precedence over java ones, so even with the setup: x/ (empty dir) x.py import x would import the Python module x. The 2.1 behavior should be reinstantiated in 2.2. I'm sorry so far I didn't manage to look to the import refactorings that happened in 2.2, it seems some things got broken. ---------------------------------------------------------------------- Comment By: Pekka Laukkanen (laukpe) Date: 2006-02-03 00:36 Message: Logged In: YES user_id=1379331 It seems that in 2.1 builtin modules do take precedence and thus this is not so big a problem there. Anyway, since you are not working only with builtins this behaviour can pretty easily bite you even in that case. Consider for example that you are building a tool called 'robot' (we are) and in your code do things like 'import robot' (we do that too). Now if your user creates a directory 'robot' where she places something related to the framework (our user did) and runs the framework so that this directory is in PYTHONPATH before your framework module (yes, she did that too) you are going to get some pretty weird and hard to debug error messages (as we did). ---------------------------------------------------------------------- Comment By: Samuele Pedroni (pedronis) Date: 2006-02-01 22:52 Message: Logged In: YES user_id=61408 notice that importing dir without __init__ is part of the java package importing support. OTOH builtin modules should take precedence. I cannot reproduce the problem with 2.1. Is sadly there in 2.2a, in general the re-worked importing mechanism needs much more testing. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112867&aid=1421812&group_id=12867 |