473,789 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create a writeable buffer?

I'm trying to create an object (as a C extension) to support the buffer
interface and was getting "TypeError: buffer is read-only" errors. So I
had a look at the array object and it has the same problem:

$ python
>>import array
a=array.array ('c', ['a', 'b', 'c'])
a
array('c', 'abc')
>>a[0]
'a'
>>a[0]='d'
a
array('c', 'dbc')
>>buf=buffer( a)
buf[0]
'd'
>>buf[0]='e'
TypeError: buffer is read-only

The array is a mutable (writable) object, and the array implements the
buffer interface and provides a 'getwritebuf' method.
(Python-2.4.4/Modules/arraymodule.c has an array_buffer_ge twritebuf())
so why does it give "TypeError: buffer is read-only"?

Steve
Nov 20 '06 #1
0 1787

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2128
by: Jerry | last post by:
Hi All: Is there any way I can get my script to be able to create and CHMOD folders and files??? I always get the following error: mkdir(TESTDIR): Permission denied in /usr/www/users... Is there a way I can enable the script to do all that by placing a ..htaccess file which contains some permissive directives?
1
2222
by: lawrence k | last post by:
I'm trying to write some RSS feeds. I've created a folder called rss, and it lives in the same directory as my scripts. I run the script and get no result. I put in a is_writeable() check and it says the path is not writeable. I chmod to 777 and get the same result. I fun fileperms on the folder and it comes back 777. I'm not sure what else to check. I'm getting this: > we will try to write the string to rss/cms.xml > perms are: 16895...
1
4236
by: Marco Shaw | last post by:
Is there something built-in to .net to determine if a directory is writeable by the current user? I want to write a Windows Powershell script that needs to write to a directory. I can certainly do something in PSH to get the current user, then determine if the ACLs will allow writing, but perhaps .net has a one-liner? I know I can also just use PSH to try to write to the dir, then retrive the error value. Still, wondering if there's...
4
3959
by: aki | last post by:
Hi all, i am writing codes for implementing network protocols. i have written a method which is receiving a packet from network. i have assumed that the packet i will receive will be of type char*. i need to test my method and for that i want to create a network buffer which will contain a packet of format as-> example of Configuration req packet uint8_t code;
1
1748
by: jaleel | last post by:
In a windows application I have an xml file which is readable and writeable. I wnat to ensure that this file is writeable if it is set to read-only. I am doing my work using the code: Dim afpXmlDocumnet As XmlDocument = New XmlDocument afpXmlDocumnet.Load(filename)
3
2068
by: Tim Kelley | last post by:
Is there a way to determine if a CD/DVD is writeable? I have looked at using WMI (Win32_CDROMDrive) but it did not have any luck. Thanks.
3
4488
by: 100grand | last post by:
Modify the Inventory Program to use a GUI. The GUI should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory of that product. In addition, the GUI should display the value of the entire inventory, the additional attribute, and the restocking fee. Here is my Inventory program from 1 to 3: package...
5
2769
by: Gruik | last post by:
Hi people, I'm currently working on python embedding with C++. My goal is that the C++ part handle files writing/reading so that the Python part only works with buffers. I succeeded in buffer exchanges. The problem is that some of the files I read/write are python files so that, before embedding, I imported them as modules when I needed them.
2
43962
by: jarea | last post by:
I have read quite a bit about this error but I have yet to find the solution to my problem. I am trying to execute the following mysql statement: alter table line_items add constraint fk_line_item_products foreign key (product_id) references products(id) I have also tried the following statement with the same result:
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.