8000 Add _winapi.GetACP and enable test_unicode on windows (#5547) · RustPython/RustPython@1f3a967 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1f3a967

Browse files
authored
Add _winapi.GetACP and enable test_unicode on windows (#5547)
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
1 parent 31c5c3e commit 1f3a967

File tree

6 files changed

+6
-18
lines changed

6 files changed

+6
-18
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ env:
2222
# test_os: many failing tests
2323
# test_pathlib: support.rmtree() failing
2424
# test_posixpath: OSError: (22, 'The filename, directory name, or volume label syntax is incorrect. (os error 123)')
25-
# test_unicode: AttributeError: module '_winapi' has no attribute 'GetACP'
2625
# test_venv: couple of failing tests
2726
WINDOWS_SKIPS: >-
2827
test_glob
@@ -31,7 +30,6 @@ env:
3130
test_rlcompleter
3231
test_pathlib
3332
test_posixpath
34-
test_unicode
3533
test_venv
3634
# configparser: https://github.com/RustPython/RustPython/issues/4995#issuecomment-1582397417
3735
# socketserver: seems related to configparser crash.

Lib/test/test_charmapcodec.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def codec_search_function(encoding):
2626
codecname = 'testcodec'
2727

2828
class CharmapCodecTest(unittest.TestCase):
29-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
3029
def test_constructorx(self):
3130
self.assertEqual(str(b'abc', codecname), 'abc')
3231
self.assertEqual(str(b'xdef', codecname), 'abcdef')
@@ -43,14 +42,12 @@ def test_encodex(self):
4342
self.assertEqual('dxf'.encode(codecname), b'dabcf')
4443
self.assertEqual('dxfx'.encode(codecname), b'dabcfabc')
4544

46-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
4745
def test_constructory(self):
4846
self.assertEqual(str(b'ydef', codecname), 'def')
4947
self.assertEqual(str(b'defy', codecname), 'def')
5048
self.assertEqual(str(b'dyf', codecname), 'df')
5149
self.assertEqual(str(b'dyfy', codecname), 'df')
5250

53-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
5451
def test_maptoundefined(self):
5552
self.assertRaises(UnicodeError, str, b'abc\001', codecname)
5653

Lib/test/test_codecs.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,6 @@ def test_decode(self):
18271827
self.assertEqual(codecs.decode(b'[\xff]', 'ascii', errors='ignore'),
18281828
'[]')
18291829

1830-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
18311830
def test_encode(self):
18321831
self.assertEqual(codecs.encode('\xe4\xf6\xfc', 'latin-1'),
18331832
b'\xe4\xf6\xfc')
@@ -1846,7 +1845,6 @@ def test_register(self):
18461845
self.assertRaises(TypeError, codecs.register)
18471846
self.assertRaises(TypeError, codecs.register, 42)
18481847

1849-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; AttributeError: module '_winapi' has no attribute 'GetACP'")
18501848
def test_unregister(self):
18511849
8000 name = "nonexistent_codec_name"
18521850
search_function = mock.Mock()
@@ -1859,28 +1857,23 @@ def test_unregister(self):
18591857
self.assertRaises(LookupError, codecs.lookup, name)
18601858
search_function.assert_not_called()
18611859

1862-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
18631860
def test_lookup(self):
18641861
self.assertRaises(TypeError, codecs.lookup)
18651862
self.assertRaises(LookupError, codecs.lookup, "__spam__")
18661863
self.assertRaises(LookupError, codecs.lookup, " ")
18671864

1868-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
18691865
def test_getencoder(self):
18701866
self.assertRaises(TypeError, codecs.getencoder)
18711867
self.assertRaises(LookupError, codecs.getencoder, "__spam__")
18721868

1873-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
18741869
def test_getdecoder(self):
18751870
self.assertRaises(TypeError, codecs.getdecoder)
18761871
self.assertRaises(LookupError, codecs.getdecoder, "__spam__")
18771872

1878-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
18791873
def test_getre 6D40 ader(self):
18801874
self.assertRaises(TypeError, codecs.getreader)
18811875
self.assertRaises(LookupError, codecs.getreader, "__spam__")
18821876

1883-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
18841877
def test_getwriter(self):
18851878
self.assertRaises(TypeError, codecs.getwriter)
18861879
self.assertRaises(LookupError, codecs.getwriter, "__spam__")
@@ -1939,7 +1932,6 @@ def test_undefined(self):
19391932
self.assertRaises(UnicodeError,
19401933
codecs.decode, b'abc', 'undefined', errors)
19411934

1942-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
19431935
def test_file_closes_if_lookup_error_raised(self):
19441936
mock_open = mock.mock_open()
19451937
with mock.patch('builtins.open', mock_open) as file:
@@ -3287,7 +3279,6 @@ def test_multiple_args(self):
32873279
self.check_note(RuntimeError('a', 'b', 'c'), msg_re)
32883280

32893281
# http://bugs.python.org/issue19609
3290-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
32913282
def test_codec_lookup_failure(self):
32923283
msg = "^unknown encoding: {}$".format(self.codec_name)
32933284
with self.assertRaisesRegex(LookupError, msg):
@@ -3523,8 +3514,6 @@ def test_incremental(self):
35233514
False)
35243515
self.assertEqual(decoded, ('abc', 3))
35253516

3526-
# TODO: RUSTPYTHON
3527-
@unittest.expectedFailure
35283517
def test_mbcs_alias(self):
35293518
# Check that looking up our 'default' codepage will return
35303519
# mbcs when we don't have a more specific one available

Lib/test/test_tokenize.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,6 @@ def test_utf8_normalization(self):
12371237
found, consumed_lines = detect_encoding(rl)
12381238
self.assertEqual(found, "utf-8")
12391239

1240-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
12411240
def test_short_files(self):
12421241
readline = self.get_readline((b'print(something)\n',))
12431242
encoding, consumed_lines = detect_encoding(readline)
@@ -1316,7 +1315,6 @@ def readline(self):
13161315
ins = Bunk(lines, path)
13171316
detect_encoding(ins.readline)
13181317

1319-
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
13201318
def test_open_error(self):
13211319
# Issue #23840: open() must close the binary file on error
13221320
m = BytesIO(b'#coding:xxx')

vm/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ features = [
125125
workspace = true
126126
features = [
127127
"Win32_Foundation",
128+
"Win32_Globalization",
128129
"Win32_Networking_WinSock",
129130
"Win32_Security",
130131
"Win32_Storage_FileSystem",

vm/src/stdlib/winapi.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ mod _winapi {
119119
Ok(HANDLE(target))
120120
}
121121

122+
#[pyfunction]
123+
fn GetACP() -> u32 {
124+
unsafe { windows_sys::Win32::Globalization::GetACP() }
125+
}
126+
122127
#[pyfunction]
123128
fn GetCurrentProcess() -> HANDLE {
124129
unsafe { windows::Win32::System::Threading::GetCurrentProcess() }

0 commit comments

Comments
 (0)
0