Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re.match.func_code.co_filename returns "re.py" #46006

Closed
thekorn mannequin opened this issue Dec 19, 2007 · 9 comments
Closed

re.match.func_code.co_filename returns "re.py" #46006

thekorn mannequin opened this issue Dec 19, 2007 · 9 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@thekorn
Copy link
Mannequin

thekorn mannequin commented Dec 19, 2007

BPO 1665
Nosy @gvanrossum, @tiran

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2007-12-20.13:43:40.152>
created_at = <Date 2007-12-19.22:55:20.175>
labels = ['type-bug']
title = 're.match.func_code.co_filename returns "re.py"'
updated_at = <Date 2007-12-20.18:42:23.626>
user = 'https://bugs.python.org/thekorn'

bugs.python.org fields:

activity = <Date 2007-12-20.18:42:23.626>
actor = 'thekorn'
assignee = 'none'
closed = True
closed_date = <Date 2007-12-20.13:43:40.152>
closer = 'georg.brandl'
components = ['None']
creation = <Date 2007-12-19.22:55:20.175>
creator = 'thekorn'
dependencies = []
files = []
hgrepos = []
issue_num = 1665
keywords = []
message_count = 9.0
messages = ['58838', '58840', '58841', '58845', '58855', '58856', '58861', '58863', '58915']
nosy_count = 3.0
nosy_names = ['gvanrossum', 'christian.heimes', 'thekorn']
pr_nums = []
priority = 'normal'
resolution = 'works for me'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue1665'
versions = ['3rd party']

@thekorn thekorn mannequin added the type-bug An unexpected behavior, bug, or error label Dec 19, 2007
@thekorn
Copy link
Mannequin Author

thekorn mannequin commented Dec 19, 2007

re.match.func_code.co_filename returns "re.py"
I expect something like "/usr/lib/python2.5/re.py"

This causes issues in the "inspect"-module like:
>>> inspect.getabsfile(re.match)
>>> '<current-dir>/re.py'

Sorry, this is my first python-bugreport, please ping me if you need any
further details.

Markus

@gvanrossum
Copy link
Member

I can't reproduce this.

How did you install Python?

Python 2.5.2a0 (release25-maint, Nov 27 2007, 14:00:00) 
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.match.func_code.co_filename
'/usr/local/lib/python2.5/re.py'
>>>

@thekorn
Copy link
Mannequin Author

thekorn mannequin commented Dec 19, 2007

Thanks for your fast reply.
I'm using the python package of ubuntu-feisty,
$ python
Python 2.5.1 (r251:54863, Oct  5 2007, 13:50:07) 
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.match.func_code.co_filename
're.py'
>>> 

So maybe it's ubuntu-specific!?

@gvanrossum
Copy link
Member

Then I suggest you talk to the Ubuntu developers or whoever packaged
Python 2.5.1 for it.

@tiran
Copy link
Member

tiran commented Dec 20, 2007

I'm able to reproduce the problem on Ubuntu. It's probably caused by
their compile step in python2.5.postinst:

    cd /usr/lib/python2.5
    files=$(dpkg -L python2.5 | sed -n

'/\.py$/s,^/usr/lib/python2.5/,,p')
/usr/bin/python2.5 /usr/lib/python2.5/py_compile.py $files
if grep -sq '^byte-compile[^#]*optimize'
/etc/python/debian_config; then
/usr/bin/python2.5 -O /usr/lib/python2.5/py_compile.py $files
fi

It's compiling the py files relative to /usr/lib/python2.5. Please note
that the behavior of py_compile.py is intended. The relative path is
useful for people who pack the compiled files into a zip file or egg file.

@gvanrossum
Copy link
Member

Well, if they do that, they apparently break inspect.py. Should they
be doing that? Why are they doing that? Can you contact the Ubuntu
folks about this?

@tiran
Copy link
Member

tiran commented Dec 20, 2007

Guido van Rossum wrote:

Guido van Rossum added the comment:

Well, if they do that, they apparently break inspect.py. Should they
be doing that? Why are they doing that? Can you contact the Ubuntu
folks about this?

No, they shouldn't. It may be plain ignorance or they have a hidden
agenda. I'm going to contact the Debian maintainers. I'm sure the Ubuntu
guys have copied the behavior from Debian.

Christian

@tiran
Copy link
Member

tiran commented Dec 20, 2007

I proposed to the maintainer that he should change one line to

dpkg -L python2.5 | sed -n '/\.py$/p'

In the mean time you can easily fix the issue with:

sudo find /usr/lib/python2.5 -name '*.py[co]' -delete
sudo python2.5 /usr/lib/python2.5/compileall.py /usr/lib/python2.5/
sudo python2.5 -O /usr/lib/python2.5/compileall.py /usr/lib/python2.5/

@thekorn
Copy link
Mannequin Author

thekorn mannequin commented Dec 20, 2007

Thanks a lot, this works.

Markus

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants