[issue16864] sqlite3.Cursor.lastrowid isn't populated when executing a SQL REPLACE statement

2015-06-10 Thread Alex Lord

Alex Lord added the comment:

Adding a patch for 3.6 since 3.5 is in beta.

--
versions: +Python 3.6 -Python 3.5
Added file: http://bugs.python.org/file39677/replace_lastrowid_3_6.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16864
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16864] sqlite3.Cursor.lastrowid isn't populated when executing a SQL REPLACE statement

2015-05-19 Thread Alex Lord

Alex Lord added the comment:

Oh, alright. That makes a lot of sense. Sorry for being dense. I should have 
read the docs on subtest.

All lines are under 80 characters and I modified the unit test to use subtest.

Thanks for taking the time to walk me through this.

--
Added file: http://bugs.python.org/file39425/sqlite_review_2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16864
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16864] sqlite3.Cursor.lastrowid isn't populated when executing a SQL REPLACE statement

2015-05-17 Thread Alex Lord

Alex Lord added the comment:

There was a bunch of things wrong with that patch.

In addition to the issues you brought up in the review I was mixing up what the 
actual problem is

REPLACE INTO is an alias for INSERT OR REPLACE. INSERT OR REPLACE was correctly 
setting the lastrowid values but REPLACE INTO was not setting the last rowid 
value. I changed the documentation modifications to reflect this.

In addition I cleaned up the unit tests. The unit tests were kind of a mess 
because I was trying to figure out what the problem was and never refactored 
after getting a reproduction.

 I at first went down the path of making the tests use a for loop like you 
suggested

for statement in [INSERT OR REPLACE, REPLACE]:
sql = {} INTO test(id, unique_test) VALUES (?, ?).format(
statement)
self.cu.execute(sql, (1, foo))
self.assertEqual(self.cu.lastrowid, 1)
self.cu.execute(sql, (1, foo))$
self.assertEqual(self.cu.lastrowid, 1) 

Which I don't think is as nice as a cleaned up unrolled version

self.cu.execute(INSERT OR REPLACE INTO test(id, unique_test) VALUES (?, 
?), (1, bar,))
self.assertEqual(self.cu.lastrowid, 1)
self.cu.execute(INSERT OR REPLACE INTO test(id, unique_test) VALUES (?, 
?), (1, bar,))
self.assertEqual(self.cu.lastrowid, 1)
self.cu.execute(REPLACE INTO test(id, unique_test) VALUES (?, ?), (1, 
bar,))
self.assertEqual(self.cu.lastrowid, 1)

I've created a patch that fixes all of the issues brought up in the code review 
and is just generally much cleaner.

--
Added file: http://bugs.python.org/file39411/sqlite_after_review_1.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16864
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16864] sqlite3.Cursor.lastrowid isn't populated when executing a SQL REPLACE statement

2015-05-13 Thread Alex Lord

Changes by Alex Lord lostdogs...@gmail.com:


Added file: http://bugs.python.org/file39367/sqlite_lastrowid_35_updated_2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16864
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16864] sqlite3.Cursor.lastrowid isn't populated when executing a SQL REPLACE statement

2015-05-13 Thread Alex Lord

Changes by Alex Lord lostdogs...@gmail.com:


Added file: http://bugs.python.org/file39366/sqlite_lastrowid_35_updated.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16864
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16864] sqlite3.Cursor.lastrowid isn't populated when executing a SQL REPLACE statement

2015-05-10 Thread Alex Lord

Alex Lord added the comment:

Went back to test to see if the other statements are covered already. Unit 
tests show that lastrowid is set properly no matter what form of sqlite insert 
statement is used.

sqlite_lastrowid_35_v2.patch contains the doc changes, unit test changes, and 
code change.

I believe that the latest version of this patch is ready for a code review by a 
core dev.

--
Added file: http://bugs.python.org/file39339/sqlite_lastrowid_35_v2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16864
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16864] sqlite3.Cursor.lastrowid isn't populated when executing a SQL REPLACE statement

2015-05-10 Thread Alex Lord

Alex Lord added the comment:

Thanks for Alex_gayner and lifeless. They pointed out the sqlite3_last_row_id 
is part of the sqlite3 module itself (not cpython).

https://www.sqlite.org/c3ref/last_insert_rowid.html

According the documentation we can expect that if a constraint stops an 
insertion then the lostrowid is not modified. As such the changes required to 
add full INSERT OR CONDITION support for last row id is unit tests for each 
statement and changing the conditional to recognize all insert cases.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16864
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16864] sqlite3.Cursor.lastrowid isn't populated when executing a SQL REPLACE statement

2015-05-10 Thread Alex Lord

Alex Lord added the comment:

Updated the patch to have a versionchanged for lastrowid in 
Doc/Library/sqlite3.rst and Doc/whatsnew/3.5.rst

One thing of note is that I wasn't able to get the indentation to be on the 
same level for sqlite3.rst (it would either intent the description text or the 
versionchange text).

Now that I'm actually starting to understand the dbapi and sqlite3 I've come to 
the conclusion that the lastrowid method should update the lastrowid for the 
INSERT OR ROLLBACK, INSERT OR ABORT, INSERT OR FAIL, INSERT OR IGNORE 
statements as well as the INSERT and INSERT OR REPLACE statements. 

I'm unsure how hard or simple supporting those statements will be

The code in question is

 704 Py_DECREF(self-lastrowid);$
 705 if (!multiple  statement_type == STATEMENT_INSERT) {$
 706 sqlite_int64 lastrowid;$
 707 Py_BEGIN_ALLOW_THREADS$
 708 lastrowid = sqlite3_last_insert_rowid(self-connection-db);$
 709 Py_END_ALLOW_THREADS$
 710 self-lastrowid = _pysqlite_long_from_int64(lastrowid);

And the difficulty will be if sqlite3_last_insert_rowid (line 708) does or 
doesn't return a row id if the OR STATEMENT portion of those inserts are 
triggered.

The Problem I'm having is that when I tried to find sqlite3_last_insert_rowid 
in the Modules/_sqlite directory I got nothing

$ grep -r sqlite3_last_insert_rowid Modules/_sqlite/
Modules/_sqlite//cursor.c:lastrowid = 
sqlite3_last_insert_rowid(self-connection-db);

When I pulled the grep out to the entire cpython repository 

$ grep -r sqlite3_last_insert_rowid .
Binary file 
./build/lib.macosx-10.10-x86_64-3.5-pydebug/_sqlite3.cpython-35dm-darwin.so 
matches
Binary file ./build/lib.macosx-10.10-x86_64-3.5-pydebug/_sqlite3.so matches
Binary file 
./build/temp.macosx-10.10-x86_64-3.5-pydebug/Users/alexlord/mercurial/cpython/Modules/_sqlite/cursor.o
 matches
./Modules/_sqlite/cursor.c:lastrowid = 
sqlite3_last_insert_rowid(self-connection-db);

I still didn't find anything and I'm not sure where to go from here.

--
Added file: http://bugs.python.org/file39336/sqlite_lastrowid_35.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16864
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24104] Use after free in xmlparser_setevents (2)

2015-05-09 Thread Alex Lord

Alex Lord added the comment:

../cpython/python.exe test_xmlparser_setevents.py
__del__ 1
__del__ 3
Segmentation fault: 11

Confirmation on 3.5.0a4 Python 3.5.0a4+

--
nosy: +Alex.Lord

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24104
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18262] ZipInfo.external_attr are not documented

2015-04-16 Thread Alex Lord

Alex Lord added the comment:

Any follow up on this?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18262
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21250] sqlite3 doesn't have unit tests for 'insert or [algorithm]' functionality.

2015-04-15 Thread Alex Lord

Alex Lord added the comment:

I've added a set of tests which test the insert or [algorithm] branch of 
sqlite. It took some getting used to python.sqlite3's transaction model but I 
think I have a much better understanding now.

--
keywords: +patch
Added file: http://bugs.python.org/file39052/sqlite_tests.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21250
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21250] sqlite3 doesn't have unit tests for 'insert or [algorithm]' functionality.

2015-04-15 Thread Alex Lord

Changes by Alex Lord lostdogs...@gmail.com:


--
components: +Library (Lib)

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21250
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23939] test_get_platform_osx failure on Python 3.5.0a0 osx 10.6

2015-04-13 Thread Alex Lord

Alex Lord added the comment:

Ah, Alright. I thought that hg up would bring me up to speed. Sorry for that.

--
status: pending - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23939
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23939] test_get_platform_osx failure on Python 3.5.0a0 osx 10.6

2015-04-13 Thread Alex Lord

Changes by Alex Lord lostdogs...@gmail.com:


--
components: +Macintosh
nosy: +ned.deily, ronaldoussoren

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23939
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23940] test__supports_universal_builds failure on Python 3.5.0a0 osx 10.6

2015-04-13 Thread Alex Lord

New submission from Alex Lord:

On a fresh clone of cpython 3.5.0a0 if you run

$ ./configure --with-pydebug  make -j2
$ ./python.exe -m test.test__osx_support -j3

on osx 10.10.2 (14C109) these two test failures are reported.


==
FAIL: test__supports_universal_builds (__main__.Test_OSXSupport)
--
Traceback (most recent call last):
  File /Users/alexlord/mercurial/cpython/Lib/test/test__osx_support.py, 
line 113, in test__supports_universal_builds
_osx_support._supports_universal_builds())
AssertionError: False != True

This turned out to be a problem with the line 12 in test_osx_support.py

self.assertEqual(platform.mac_ver()[0].split('.') = ['10', '4'],$
 _osx_support._supports_universal_builds())$

Specifically the section

platform.mac_ver()[0].split('.') = ['10', '4']

Which reduced to

['10', '10', '2'] = ['10', '4] which evaluated to False.

To fix this I imported distutils.version.StrictVersion and added these three 
lines.

+mac_version = StrictVersion(platform.mac_ver()[0])
+test_if_greater_version = StrictVersion('10.4')
+self.assertEqual(mac_version = test_if_greater_version,

--
files: test__supports_universal_builds.patch
keywords: patch
messages: 240758
nosy: Alex.Lord
priority: normal
severity: normal
status: open
title: test__supports_universal_builds failure on Python 3.5.0a0 osx 10.6
Added file: 
http://bugs.python.org/file38968/test__supports_universal_builds.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23940
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23940] test__supports_universal_builds failure on Python 3.5.0a0 osx 10.6

2015-04-13 Thread Alex Lord

Changes by Alex Lord lostdogs...@gmail.com:


--
components: +Macintosh
nosy: +ned.deily, ronaldoussoren

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23940
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23939] test_get_platform_osx failure on Python 3.5.0a0 osx 10.6

2015-04-13 Thread Alex Lord

New submission from Alex Lord:

On a fresh clone of cpython 3.5.0a0 if you run

$ ./configure --with-pydebug  make -j2
$ ./python.exe -m test.test__osx_support -j3

on osx 10.10.2 (14C109) these two test failures are reported.

==
FAIL: test_get_platform_osx (__main__.Test_OSXSupport)
--
Traceback (most recent call last):
  File /Users/alexlord/mercurial/cpython/Lib/test/test__osx_support.py, 
line 272, in test_get_platform_osx
self.assertEqual(('macosx', '10.6', 'fat'), result)
AssertionError: Tuples differ: ('macosx', '10.6', 'fat') != ('macosx', 
'10.6', ' ')

First differing element 2:
fat


- ('macosx', '10.6', 'fat')
? ^^^

+ ('macosx', '10.6', ' ')
? ^


--
Ran 14 tests in 0.354s


Doing a little more digging I found that this if statement is the one failing.

if ((macrelease + '.') = '10.4.' and$
 '-arch' in cflags.strip()):

Specifically this line 

(macrelease + '.') = '10.4'

I used distutils.version.StrictVersion to solve this comparison error.

which is failing because

'10.10' = '10.4' # This fails because the character 4 is greater than 1.

--
files: test_get_platform_osx.patch
keywords: patch
messages: 240741
nosy: Alex.Lord
priority: normal
severity: normal
status: open
title: test_get_platform_osx failure on Python 3.5.0a0 osx 10.6
versions: Python 3.5
Added file: http://bugs.python.org/file38962/test_get_platform_osx.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23939
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22212] zipfile.py fails if zlib.so module fails to build.

2014-09-07 Thread Alex Lord

Alex Lord added the comment:

Just adding that I have also run into this problem.

--
nosy: +Alex.Lord

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22212
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16864] sqlite3.Cursor.lastrowid isn't populated when executing a SQL REPLACE statement

2014-04-17 Thread Alex Lord

Alex Lord added the comment:

Have a unit test that replicates this bug. Working on the C code to fix it 
right now.

--
nosy: +Alex.Lord

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16864
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16864] sqlite3.Cursor.lastrowid isn't populated when executing a SQL REPLACE statement

2014-04-17 Thread Alex Lord

Alex Lord added the comment:

Patch that fixes Issue16864. Follows Jim Minters suggestion.

Unit test will reproduce the issue without the c modifications. C modifications 
fix the issue.

--
keywords: +patch
Added file: http://bugs.python.org/file34953/Issue16864_py35.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16864
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21250] sqlite3 doesn't have unit tests for 'insert or [algorithm]' functionality.

2014-04-16 Thread Alex Lord

New submission from Alex Lord:

In Lib/sqlite3/tests/dbapi.py there are no unit tests which test out sqlite3's 
'insert or [algorithm].' These algorithms are also referred to as SQL 'insert 
on conflict.'

More details at,
https://www.sqlite.org/lang_conflict.html

Not having unit tests for these features, especially 'insert or rollback,' 
seems like an easy way for timing and threading bugs to get lost in the 
database api.

--
components: Tests
messages: 216448
nosy: Alex.Lord
priority: normal
severity: normal
status: open
title: sqlite3 doesn't have unit tests for 'insert or [algorithm]' 
functionality.
type: enhancement
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21250
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21250] sqlite3 doesn't have unit tests for 'insert or [algorithm]' functionality.

2014-04-16 Thread Alex Lord

Alex Lord added the comment:

Yes, I'm going to work on one after I fix Issue16864 today.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21250
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18262] ZipInfo.external_attr are not documented

2014-04-14 Thread Alex Lord

Alex Lord added the comment:

Here's a documentation patch for 2.7 that informs the users that Zipfile.extra 
and Zipfile.extraall don't save permissions and that Zipfile.writestr will use 
ZipInfo.extra_attr or default to chmod permission set of 0600.

--
keywords: +patch
nosy: +Alex.Lord
versions:  -Python 2.6, Python 3.1, Python 3.2, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file34858/Issue18262_27.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18262
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18262] ZipInfo.external_attr are not documented

2014-04-14 Thread Alex Lord

Alex Lord added the comment:

And here's the 3.4 and 3.5 patch

--
Added file: http://bugs.python.org/file34859/Issue18262_34_35.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18262
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com