Skip to content

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

Closed

Description

@thekorn
mannequin
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']

Activity

  1. added
    type-bug
    on Dec 19, 2007
  2. thekorn commented on Dec 19, 2007

    thekornmannequin
    MannequinAuthor

    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

  3. gvanrossum commented on Dec 19, 2007

    @gvanrossum
    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'
    >>>
  4. thekorn commented on Dec 19, 2007

    thekornmannequin
    MannequinAuthor
    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!?

  5. gvanrossum commented on Dec 19, 2007

    @gvanrossum
    Member

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

  6. tiran commented on Dec 20, 2007

    @tiran
    Member

    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.

  7. gvanrossum commented on Dec 20, 2007

    @gvanrossum
    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?

  8. tiran commented on Dec 20, 2007

    @tiran
    Member

    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

  9. tiran commented on Dec 20, 2007

    @tiran
    Member

    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/

  10. thekorn commented on Dec 20, 2007

    thekornmannequin
    MannequinAuthor

    Thanks a lot, this works.

    Markus

  11. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions