- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
➜
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2008-09-01 16:03 by Frostburn, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 14679 | closed | nanjekyejoannah, 2019-07-16 16:16 | |
| PR 14679 | closed | nanjekyejoannah, 2019-07-16 16:16 | |
| PR 15072 | open | vstinner, 2019-08-01 15:53 |
| Messages (3) | ||
|---|---|---|
| msg72266 - (view) | Author: Pyry Pakkanen (Frostburn) | Date: 2008-09-01 16:03 |
I was expecting that the API function PyArg_ParseTuple(args, "y#:foo", &cp, &size) would accept a bytearray and implicitly convert it to bytes. Currently it throws the error: TypeError: foo() argument 1 must be bytes or read-only buffer, not bytearray |
||
| msg72270 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2008-09-01 16:17 |
Yes, you must use y* instead: see http://docs.python.org/dev/3.0/c-api/arg.html y# would not be safe to use with bytearray since another thread could mutate the bytearray in-between, possibly reallocating the internal buffer (to shrink or grow it), and lead to a segfault when your thread uses the obsolete pointer. IMO, the documentation should mention that the '*' codes (y*, s*, etc.) must be used in preference to the '#' codes, which are there for backwards compatibility. |
||
| msg72273 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2008-09-01 16:45 |
Documented in r66113. |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:38 | admin | set | github: 48003 |
| 2019-08-01 15:53:55 | vstinner | set | pull_requests: + pull_request14819 |
| 2019-07-16 16:16:40 | nanjekyejoannah | set | pull_requests: + pull_request14591 |
| 2019-07-16 16:16:40 | nanjekyejoannah | set | pull_requests: + pull_request14590 |
| 2019-07-11 15:27:08 | ZackerySpytz | set | pull_requests: - pull_request14485 |
| 2019-07-09 19:36:49 | nanjekyejoannah | set | pull_requests: + pull_request14485 |
| 2008-09-01 16:45:49 | georg.brandl | set | status: open -> closed resolution: fixed messages: + msg72273 |
| 2008-09-01 16:17:12 | pitrou | set | versions:
+ Python 2.6 nosy: + georg.brandl, pitrou title: bytearray incompatible with bytes -> bytearray incompatible with y# messages: + msg72270 assignee: georg.brandl components: + Documentation |
| 2008-09-01 16:03:42 | Frostburn | create |
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements

