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

linecache.getline() Returning Error #57076

Closed
JordanMeyer mannequin opened this issue Aug 31, 2011 · 2 comments
Closed

linecache.getline() Returning Error #57076

JordanMeyer mannequin opened this issue Aug 31, 2011 · 2 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@JordanMeyer
Copy link
Mannequin

JordanMeyer mannequin commented Aug 31, 2011

BPO 12867
Nosy @ned-deily

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 2011-08-31.07:21:29.656>
created_at = <Date 2011-08-31.04:29:22.717>
labels = ['type-bug', 'library']
title = 'linecache.getline() Returning Error'
updated_at = <Date 2011-08-31.07:21:29.654>
user = 'https://bugs.python.org/JordanMeyer'

bugs.python.org fields:

activity = <Date 2011-08-31.07:21:29.654>
actor = 'ned.deily'
assignee = 'none'
closed = True
closed_date = <Date 2011-08-31.07:21:29.656>
closer = 'ned.deily'
components = ['Library (Lib)']
creation = <Date 2011-08-31.04:29:22.717>
creator = 'Jordan.Meyer'
dependencies = []
files = []
hgrepos = []
issue_num = 12867
keywords = []
message_count = 2.0
messages = ['143247', '143250']
nosy_count = 2.0
nosy_names = ['ned.deily', 'Jordan.Meyer']
pr_nums = []
priority = 'normal'
resolution = 'works for me'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue12867'
versions = ['Python 3.2']

@JordanMeyer
Copy link
Mannequin Author

JordanMeyer mannequin commented Aug 31, 2011

In trying to use the linecache.getline() function to extra data from a plain-text database format that I'm building. Every time I make a call to it (even from the interpreter directly) I get an error like the one below. I believe the problem lies in the linecache module itself.

Traceback (most recent call last):
  File "/Users/jordanmeyer/Documents/Python/eFlashcard/alpha/0.1a2/eFlashcard_0.1a2.py", line 59, in <module>
    eFlashcard_main()
  File "/Users/jordanmeyer/Documents/Python/eFlashcard/alpha/0.1a2/eFlashcard_0.1a2.py", line 17, in eFlashcard_main
    eFlashcard_build()
  File "/Users/jordanmeyer/Documents/Python/eFlashcard/alpha/0.1a2/eFlashcard_0.1a2.py", line 31, in eFlashcard_build
    while str(linecache.getline(lib_file, lib_index, module_globals=None)) != '':
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/linecache.py", line 15, in getline
    lines = getlines(filename, module_globals)
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/linecache.py", line 41, in getlines
    return updatecache(filename, module_globals)
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/linecache.py", line 76, in updatecache
    if not filename or (filename.startswith('<') and filename.endswith('>')):
AttributeError: '_io.TextIOWrapper' object has no attribute 'startswith'

@JordanMeyer JordanMeyer mannequin added type-crash A hard crash of the interpreter, possibly with a core dump stdlib Python modules in the Lib dir labels Aug 31, 2011
@ned-deily
Copy link
Member

The linecache module functions take a filename string as an argument, not a file object. Try:

   linecache.getlines("/path/to/filename", lineno)

http://docs.python.org/py3k/library/linecache.html

@ned-deily ned-deily added type-bug An unexpected behavior, bug, or error and removed type-crash A hard crash of the interpreter, possibly with a core dump labels Aug 31, 2011
@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
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant