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

Add __enter__ and __exit__ methods to StringIO/cStringIO classes #48289

Closed
peppergrower mannequin opened this issue Oct 4, 2008 · 3 comments
Closed

Add __enter__ and __exit__ methods to StringIO/cStringIO classes #48289

peppergrower mannequin opened this issue Oct 4, 2008 · 3 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@peppergrower
Copy link
Mannequin

peppergrower mannequin commented Oct 4, 2008

BPO 4039
Nosy @loewis, @benjaminp

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 2008-10-04.15:49:25.809>
created_at = <Date 2008-10-04.11:06:09.999>
labels = ['interpreter-core', 'type-feature']
title = 'Add __enter__ and __exit__ methods to StringIO/cStringIO classes'
updated_at = <Date 2008-10-04.15:49:25.807>
user = 'https://bugs.python.org/peppergrower'

bugs.python.org fields:

activity = <Date 2008-10-04.15:49:25.807>
actor = 'benjamin.peterson'
assignee = 'none'
closed = True
closed_date = <Date 2008-10-04.15:49:25.809>
closer = 'benjamin.peterson'
components = ['Interpreter Core']
creation = <Date 2008-10-04.11:06:09.999>
creator = 'peppergrower'
dependencies = []
files = []
hgrepos = []
issue_num = 4039
keywords = []
message_count = 3.0
messages = ['74309', '74310', '74315']
nosy_count = 3.0
nosy_names = ['loewis', 'benjamin.peterson', 'peppergrower']
pr_nums = []
priority = 'normal'
resolution = 'duplicate'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue4039'
versions = ['Python 2.7']

@peppergrower
Copy link
Mannequin Author

peppergrower mannequin commented Oct 4, 2008

Currently, StringIO objects do not have __enter__ and __exit__ methods
associated with them. As a result, the 'with' statement won't work
properly on StringIO objects in a construction like the following,
though they can otherwise be manipulated like files:

with obj.open_file(...) as f:
    ... 

(I brought up this behavior first on comp.lang.python,* and the above
example was borrowed from Hrvoje Niksic.) To allow StringIO objects to
be used more interchangeably with actual file objects, could __enter__
and __exit__ methods be added?

Thanks,
peppergrower

http://groups.google.com/group/comp.lang.python/browse_thread/thread/6bdf65bce431e404/a5dc64f43147f4dd?lnk=gst

@peppergrower peppergrower mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Oct 4, 2008
@loewis
Copy link
Mannequin

loewis mannequin commented Oct 4, 2008

Certainly not for 2.5 or 2.6. Targetting this as 2.7.

@benjaminp
Copy link
Contributor

This is a duplicate of bpo-1286.

@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
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant